Approximately original material
Forget it, so how to build your own python project
The following are prerequisites for installation
Build a python environment if needed
# Install python if needed $ pythonz install py_version # virtualenv environment construction $ cd path_to_virtualenv_dir $ virtualenv -p `pythonz locate py_version` virtualenv_dir_name # pythonz installation contents confirmation $ pythonz list virtualenv activate $ . path_to_virtualenv_dir/virtualenv_dir_name/bin/activate virtualenv deactivate $ deactivate
# python project storage directory $ mkdir projects # Create project directory $ mkdir prj_name ; cd prj_name # Initialization $ mkdir bin pkg_name test docs touch pkg_name/__init__.py tests/__init__.py
Create the following files in prj_name / setup.py
try: from setuptools import setup except ImportError: from distutils.core import setup config = { 'description': 'My Project', 'author': 'My Name', 'url': 'URL to get it at.', 'download_url': 'Where to download it.', 'author_email': 'My email.', 'version': '0.1', 'install_requires': ['nose'], 'packages': ['NAME'], 'scripts': [], 'name': 'projectname' } setup(**config)
Set up dependent libraries under install_requires
$ python setup.py develop # Verification $ pip list
Add tests to prj_name / tests / pkg_name_tests.py
from nose.tools import * import pkg_name def setup(): print "SETUP!" def teardown(): print "TEAR DOWN!" def test_basic(): print "I RAN!"
Operation check
$ nosetest
The directory structure is as follows
prj_name/ pkg_name/ __init__.py bin/ docs/ setup.py tests/ pkg_name_tests.py __init__.py
Recommended Posts