python.org
The new www.python.org!
Getting going
Requires ✨Python 3.3!✨ (brew install python3)
You'll want a virtualenv. Python 3.3 actually includes virtualenv built-in, so you can do:
$ pyvenv-3.3 <env>
$ source <env>/bin/activate
(etc)
But you can also use your existing virtualenv/wrapper:
$ mkvirtualenv --python=python3.3 <env>
And then it's the standard:
$ pip install -r requirements.txt
$ ./manage.py syncdb
You may need to specify the pip version, even with the virtualenv activated:
$ pip-3.3 install -r requirements.txt
This expects a local database named "python.org". If you need to change it:
$ export DATABASE_URL=postgres://user:pass@host:port/dbname
To compile and compress static media, you will need compass and yui-compressor:
$ gem install bundler
$ bundle install
$ brew install yuicompressor
NOTE: On OSX you may need to adjust your PATH to be able to find the sass binary, etc.
Python 3.3 and OSX 10.8.2
Homebrew's recipe for python3.3 has some difficulty installing distribute and pip in a virtualenv. The python.org installer for OSX may work better, if you're having trouble.
Using Vagrant
You can ignore the above instructions by using Vagrant. After installing:
$ vagrant up
$ vagrant ssh
The box will be provisioned by Chef with Python 3.3, a virtualenv set up with requirements installed, and a database ready to use. The virtualenv is activated upon login. You will need to run ./manage.py createsuperuser to use the admin.
Running tests
$ pip install -r dev-requirements.txt
$ coverage run manage.py test
$ coverage report
Generate an HTML report with coverage html if you like.
Troubleshooting
If you hit an error getting this repo setup, file a pull request with helpful information so others don't have similar problems.
Freetype not found
_imagingft.c:60:10: fatal error: 'freetype/fterrors.h' file not found
#include <freetype/fterrors.h>
^
1 error generated.
error: command 'clang' failed with exit status 1
If you've installed freetype (brew install freetype), you may need
to symlink version 2 into location for version 1 as mentioned by this
Stack Overflow
question.
Freetype 2.5.3 is known to work with this repository.
ln -s /usr/local/include/freetype2 /usr/local/include/freetype
Cheatsheet for Front End devs that know enough to be dangerous
But not really enough to remember all these CLI commands by heart.
Spinning up a VM
- Open Terminal.app
cd ~/github/pythonsource ENV/bin/activate- Maybe you need to install requirements?
pip install -r requirements.txt export DATABASE_URL="postgres://localhost/python.org"./manage.py runserver 0.0.0.0:8000(or whatever port you run at)
Nuke the DB!
- Do steps 1-4 above.
export PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"dropdb python.orgcreatedb python.org./manage.py syncdb./manage.py migrate- Install data below if you like.
Other Useful Commands
Create a super user (for a new DB):
./manage.py createsuperuser
Import calendars:
./manage.py import_ics_calendars
Want to save some data from your DB before nuking it, and then load it back in?
./manage.py dumpdata --format=json --indent=4 [app-name] > fixtures/[app-name].json
Load a specific fixture:
./manage.py loaddata fixtures/[name].json
Load all fixture files:
find ./fixtures -name "*.json" -exec ./manage.py loaddata {} \;
List All the active DBs:
psql -U postgres -c -l
esq from window... q
If Postgres can't connect to your localhost DB, put this in pydotorg/settings/local.py:
DATABASES = {
'default': dj_database_url.config(default='postgres://localhost:{port#}/{DBName, probably python.org}')
}
Go into PSQL and dump a DB backup:
cd /Applications/Postgres.app/Contents/MacOS/bin
./pg_dump <db_name> > path/to/file.name
./pg_dump python.org > ~/github/python/development.dump
Reload a DB dump from a file:
./pg_restore -d <db_name> <path-to-file>
./pg_restore --clean -d python.org ~/github/python/preview.dump
See here for the --clean methods http://www.postgresql.org/docs/9.2/static/app-pgrestore.html
