New Project Checklist¶
The following checklist is designed to help set up and complete a new python programming project and host it on PyPI.
Placing the source code on GitHub or Bitbucket will make the source code and documentation available to others.
Before You Start Programming¶
- Check that your project’s name is available on PyPI. Go to https://pypi.python.org/pypi and use the search feature to verify that your desired project name is available. When you decide on an available name, you can create a repository and register it with PyPI.
- Also look for a project that already does what you intend to do.
- You may be able to contribute to an existing project instead of reinventing the wheel ;-).
- Set up the project on GitHub or Bitbucket (I recommend GitHub).
- For GitHub (see New GitHub Project)
- setup Read the Docs automatic doc creation
- setup Travis CI for automatic unittests with different Linux python versions
- on Bitbucket (see https://bitbucket.org/)
- Bitbucket appears to have fewer features than GitHub.
- documentation is often just the README.rst file, there is no direct access to Travis CI or Read the Docs
- Run
PyHatch
to create the project folder and supporting files - Use the URL for either GitHub or Bitbucket project as
project url
in pyhatch GUI. - If using ReadTheDocs, you might want to use the ReadTheDocs url in pyhatch GUI.
- Use the URL for either GitHub or Bitbucket project as
- Optionally delete
examples
subdirectory - PyHatch creates an
examples
subdirectory that you may choose not to use.
- PyHatch creates an
- Optionally delete
- Optionally create a new
logo
image file (PNG, GIF, JPEG, SVG, etc.) PyHatch creates a logo called
generic_logo.svg
located in the /docs/_static subdirectoryThe current logo is a 210x62 pixel SVG file. An image file of similar characteristics would work well in the Sphinx-generated HTML pages.
To change the logo, look in the file
/docs/conf.py
and change the line:html_logo = "./_static/generic_logo.svg" to html_logo = "./_static/<your new image file name>"
- Optionally create a new
- Run
- Register yourself with PyPI (If you haven’t already)
- See https://pypi.python.org/pypi?%3Aaction=register_form to get a username and password
- Configure your
.pypirc
file to make register and upload to PyPI easier. - Edit the username and password in the
.pypirc
file thatPyHatch
creates PyHatch
leaves only place-holders for username and password
- Edit the username and password in the
- Move
.pypirc
to your home directory after editing. See PyPI Configuration File for guidance.
- Configure your
- Register you package with PyPI (Python Package Index)
- The preferred way to register your package is by filling the web form at: https://pypi.python.org/pypi?%3Aaction=submit_form
- for testPyPI see: https://testpypi.python.org/pypi?%3Aaction=submit_form
- If the web form is too “clunky” for you, then you can use your
setup.py
file, with the command: python setup.py register
for PyPI- For testPyPI:
python setup.py register -r https://testpypi.python.org/pypi
- or with
.pypirc
file:python setup.py register -r testpypi
- or with
- For testPyPI:
- If the web form is too “clunky” for you, then you can use your
- Edit the
tox.ini
and.travis.yml
files to match the python versions you want to support - Tox Automation is excellent for checking multiple versions of python on your development machine.
- Travis CI is excellent for checking multiple versions of python on generic Linux machines when you check your code into GitHub.
- Edit the
- Edit
MANIFEST.in
andsetup.py
(This is the first of perhaps many edits) - The
packages=find_packages(...)
option withinsetup.py
and theMANIFEST.in
file both fill very similar roles in specifying what files will be distributed with your code. - See https://docs.python.org/2/distutils/sourcedist.html#manifest for an understanding of how to specify files to distribute.
- See https://docs.python.org/2/distutils/sourcedist.html#the-manifest-in-template for guidelines on how to make a
MANIFEST.in
file.
- The
- Edit
The Programming Cycle¶
- Start programming and developing the code
- Use Tox Automation and tk_nosy to constantly validate the code during development
- Tox Automation makes the virtualenv setup easy for different python versions
- Tox needs accurate
requirements.txt
file - Tox needs accurate
install_requires
option withinsetup.py
- Tox needs accurate
- tk_nosy makes TDD (Test Driven Development) easy
- better still, try TDDD (Test Driven Documented Development)
- tk_nosy uses
nosetests
to run unittests. By defaultcoverage
is turned on. To turncoverage
off, edit the setup.cfg file under thenosetests
header. Changewith-coverage
from one to zero (1 to 0).
- Use Pylint on each python file to constantly measure code quality
- The right IDE should do this automatically
- Use sphinx to keep documentation current with code
- Constantly Work the Documentation
- Whether just a README.rst or a full sphinx HTML site, keep editing and re-editing the documentation.
- Consider using the
sphinxy.py
script located in thedocs
subdirectory. sphinxy.py
rebuilds the HTML docs every time a*.rst
file changes. It can make the documentation development cycle a little more convenient.- Note that
sphinxy.py
also changes the file system date for all*.rst
files
- Note that
- Consider using the
- Consider a
QuickStart
section in your docs (a quick install and use section)
- In addition to the Pylint already run on your code, consider running cheesecake to verify your code’s “readiness”.
- Cheesecake is more demanding and makes more value judgments than Pylint.
Upload to PyPI (or testPyPI)¶
- Run Tox Automation before uploading to PyPI
- This will test
pip
installs of package dependencies in the tox virtual environment. - Make sure that your
tox.ini
file dependencies (deps
) are the same as in yoursetup.py
andrequirements.txt
files.
- This will test
- Set the correct version number of the code
- Open the file
_version.py
and edit the version number at the bottom of the file - for example change __version__ = ‘0.0.1’
- to __version__ = ‘0.0.2’
- Open the file
Commit to GitHub with comment like:
git add . git commit -m "Release 0.0.2"
- Create
HISTORY.rst
by runninghistory_from_github_api.py
- The above commit will help make
HISTORY.rst
current - See Making History.rst for guidance
- The above commit will help make
- Create
- Verify the docs
- Whether just a README.rst or a full sphinx HTML site, re-read the documentation.
- If using ReadTheDocs:
- include a link to ReadTheDocs in README.rst
- include a link back to GitHub repository somewhere in ReadTheDocs
- If you skipped this step before, Register you package with PyPI (Python Package Index)
- Run
python setup.py register
- For testPyPI:
python setup.py register -r https://testpypi.python.org/pypi
- For testPyPI:
- Run
- With
.pypirc
file can usepython setup.py register -r pypi
- or
python setup.py register -r testpypi
on testPyPI
- or
- With
- Check the site
http://pypi.python.org/pypi/<projectname>
- Make sure that
Home Page:
links to your GitHub or Bitbucket source code repository.
- Make sure that
- Check the site
- Create release file
- Run `` python setup.py sdist``
- Examine
MyProject.tar.gz
orMyProject.zip
- Make sure the included files are what you want
- Edit
MANIFEST.in
- Edit packages=find_packages(…) within
setup.py
- Edit
- Examine
- Create
wheel
for upload to PyPI python setup.py sdist bdist_wheel
- Create
Warning
Twine is now the preferred way to register and upload projects. The following setup.py
approach has been abandoned for python versions < 2.7.13
If twine is not available or if you are on Windows (Windows version is buggy right now) upload your package to PyPI as follows:
python setup.py register -r pypi python setup.py sdist bdist_wheel upload -r pypi OR for testPyPI python setup.py register -r testpypi python setup.py sdist bdist_wheel upload -r testpypi
Note
Twine is now the preferred way to register and upload projects for python version < 2.7.13
If twine is available (it’s more secure than setup.py upload) and your
.pypirc
file is properly located and formatted, then try to upload package to PyPI using:twine upload dist/* OR for testPyPI twine upload -r testpypi dist/*
Test installing your project from PyPI (and/or testPyPI):
pip install <package name> OR for testPyPI pip install -i https://testpypi.python.org/pypi <package name> OR for testPyPI with PyPI_ Dependencies pip install -i https://testpypi.python.org/pypi <package name> --extra-index-url https://pypi.python.org/pypi
- Run unittests on the install with a virtualenv or clean virtual machine.
- Either
nosetests
orpy.test
should work
- Either
- Test the
entry_points
command fromsetup.py
. - Should be able to simply run
my_command
from command line environment.
- Should be able to simply run
- Test the
Check the three main web pages for your project:
The Code at: https://github.com/<github user name>/<package name> The Docs at: http://<package name>.readthedocs.org/en/latest/ PyPI page at: https://pypi.python.org/pypi/<package name>
- Let the world know what you’ve done.
- Announce your project on https://mail.python.org/mailman/listinfo/python-announce-list