wiki:python/Development/Project

Distribute, Distribute/Zip hack, Distribute/distutils, Distribute/setuptools, Project, virtualenv


Create new python project enviroment

Root path

$ mkdir [PROJECT NAME]
$ cd [PROJECT NAME]
$ hg init

Development paths

$ mkdir scripts
$ mkdir [APPLICATION NAME]

Within [PROJECT NAME]/scripts/ all these scripts should stored in which are needed to start your application. By example a simple start script named start_my_app can look like this:

#!/usr/bin/env python

import my_application

if __name__ == '__main__':
    my_application.app.start()

Be sure that the shebang is #!/usr/bin/env python instead of #!/usr/bin/python! This ensures a virtual installed application is using the modules within your virtualenv paths instead of the system wide paths. See more Installing an application/module for testing purposes and read this.

Create setup.py

Do not postpone this until tomorrow... ;-)

Within [PROJECT NAME]/ create a file setup.py with this minimal content:

from distutils.core import setup

import my_application

setup(name='my_app',
      py_modules=['my_application.app'],
      scripts=['scripts/start_my_app']
     )

Create .hgignore

syntax: glob
.hgignore
session
tags
VIRTUAL
build
*.pyc
*.swp

Create virtualenv paths

$ cd [PROJECT NAME]
$ virtualenv [VIRTUALENV NAME]

First commit

$ hg add
$ hg comm -m 'create projects enviroment'
Last modified 4 years ago Last modified on May 15, 2015, 10:45:59 AM