|
1 | 1 | Installing
|
2 | 2 | ==========
|
3 | 3 |
|
4 |
| -**NOTE:** The Python.org website is built using Django and Python 3 |
| 4 | +Using Vagrant |
| 5 | +------------- |
5 | 6 |
|
6 |
| -It can be installed much like any other Django site. |
| 7 | +You can ignore the below instructions by using Vagrant. After installing:: |
7 | 8 |
|
8 |
| -TODO |
| 9 | + $ vagrant up |
| 10 | + $ vagrant ssh |
| 11 | + |
| 12 | +The box will be provisioned by Chef with Python 3.3, a virtualenv set up with |
| 13 | +requirements installed, and a database ready to use. The virtualenv is |
| 14 | +activated upon login. |
| 15 | + |
| 16 | +.. note:: You will need to run ``./manage.py createsuperuser`` to use the admin. |
| 17 | + |
| 18 | + |
| 19 | +Getting started |
| 20 | +--------------- |
| 21 | + |
| 22 | +You'll want a virtualenv. Python 3.3 actually includes virtualenv built-in, so |
| 23 | +you can do:: |
| 24 | + |
| 25 | + $ pyvenv-3.3 <env> |
| 26 | + $ source <env>/bin/activate |
| 27 | + |
| 28 | +But you can also use your existing virtualenv and virtualenvwrapper:: |
| 29 | + |
| 30 | + $ virtualenv --python=python3.3 <env> |
| 31 | + $ mkvirtualenv --python=python3.3 <env> |
| 32 | + |
| 33 | +And then you'll need to install dependencies:: |
| 34 | + |
| 35 | + $ pip install -r dev-requirements.txt |
| 36 | + |
| 37 | +If you want to install the default Read the Docs theme, you can do:: |
| 38 | + |
| 39 | + $ pip install -r docs-requirements.txt |
| 40 | + |
| 41 | +.. note:: For deployment, you can just use ``requirements.txt``. |
| 42 | + |
| 43 | +In your development environment, you won't need a production ready database, so |
| 44 | +you can use Sqlite3:: |
| 45 | + |
| 46 | + $ export DATABASE_URL=sqlite:///pydotorg.db |
| 47 | + |
| 48 | +You can also add the following setting to ``pydotorg/settings/local.py``:: |
| 49 | + |
| 50 | + DATABASES = { |
| 51 | + 'default': dj_database_url.parse('sqlite:///pydotorg.db') |
| 52 | + } |
| 53 | + |
| 54 | +Not it's time to run migrations:: |
| 55 | + |
| 56 | + $ ./manage.py migrate |
| 57 | + |
| 58 | +To compile and compress static media, you will need *compass* and |
| 59 | +*yui-compressor*:: |
| 60 | + |
| 61 | + $ gem install bundler |
| 62 | + $ bundle install |
| 63 | + |
| 64 | +.. note:: |
| 65 | + |
| 66 | + To install *yui-compressor*, use your OS's package manager or download it |
| 67 | + directly then add the executable to your ``PATH``. |
| 68 | + |
| 69 | +To load all fixture files:: |
| 70 | + |
| 71 | + $ invoke load_fixtures |
| 72 | + |
| 73 | +or:: |
| 74 | + |
| 75 | + $ ./manage.py loaddata fixtures/*.json |
| 76 | + |
| 77 | +If you want to load a specific fixture, use its application name:: |
| 78 | + |
| 79 | + $ ./manage.py loaddata downloads boxes |
| 80 | + |
| 81 | +Finally, start the development server:: |
| 82 | + |
| 83 | + $ ./manage.py runserver |
| 84 | + |
| 85 | + |
| 86 | +Running tests |
| 87 | +------------- |
| 88 | + |
| 89 | +To run the test suite:: |
| 90 | + |
| 91 | + $ ./manage.py test |
| 92 | + |
| 93 | +To generate coverage report:: |
| 94 | + |
| 95 | + $ coverage run manage.py test |
| 96 | + $ coverage report |
| 97 | + |
| 98 | +Generate an HTML report with ``coverage html`` if you like. |
| 99 | + |
| 100 | + |
| 101 | +Building documentation |
| 102 | +---------------------- |
| 103 | + |
| 104 | +To build this documentation locally:: |
| 105 | + |
| 106 | + $ make -C docs/ htmlview |
| 107 | + |
| 108 | +If you don't want to open the browser automatically, you can do:: |
| 109 | + |
| 110 | + $ make -C docs/ html |
| 111 | + |
| 112 | + |
| 113 | +Useful commands |
| 114 | +--------------- |
| 115 | + |
| 116 | +* Create a super user (for a new DB):: |
| 117 | + |
| 118 | + $ ./manage.py createsuperuser |
| 119 | + |
| 120 | +* Want to save some data from your DB before nuking it, and then load it back |
| 121 | + in?:: |
| 122 | + |
| 123 | + $ ./manage.py dumpdata --format=json --indent=4 $APPNAME > fixtures/$APPNAME.json |
| 124 | + |
| 125 | + |
| 126 | +Troubleshooting |
| 127 | +--------------- |
| 128 | + |
| 129 | +If you hit an error getting this repo setup, file a pull request with helpful |
| 130 | +information so others don't have similar problems. |
| 131 | + |
| 132 | +Python 3.3 and OSX 10.8.2 |
| 133 | +^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 134 | + |
| 135 | +Homebrew's recipe for Python 3.3 has some difficulty installing distribute |
| 136 | +and pip in a virtualenv. The `python.org installer for OSX <https://www.python.org/download/>`_ |
| 137 | +may work better, if you're having trouble. |
| 138 | + |
| 139 | +Freetype not found on OSX |
| 140 | +^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 141 | + |
| 142 | +:: |
| 143 | + |
| 144 | + _imagingft.c:60:10: fatal error: 'freetype/fterrors.h' file not found |
| 145 | + #include <freetype/fterrors.h> |
| 146 | + ^ |
| 147 | + 1 error generated. |
| 148 | + error: command 'clang' failed with exit status 1 |
| 149 | + |
| 150 | +If you've installed *freetype* (``brew install freetype``), you may need |
| 151 | +to symlink version 2 into location for version 1 as mentioned by `this |
| 152 | +Stack Overflow |
| 153 | +question <http://stackoverflow.com/questions/20325473/error-installing-python-image-library-using-pip-on-mac-os-x-10-9>`_. |
| 154 | + |
| 155 | +Freetype 2.5.3 is known to work with this repository:: |
| 156 | + |
| 157 | + $ ln -s /usr/local/include/freetype2 /usr/local/include/freetype |
0 commit comments