This here is an example project I constructed from scratch (as opposed to using a cookiecutter template) to get familiar with Travis CI running pytest and pytest-cov, with tox as a Travis frontend, PyUp to automagically manage dependencies and their security, and Coveralls to track code coverage. I'm also using CodeClimate to track code quality. Of course, if the package doesn't adhere to PEP8 and consistent formatting then flake8 and Black will prevent the Travis build from passing.
Now let's get writing a hit Python package ;)
The Travis build config in .travis.yml
tells Travis to build on Linux and OSX and specifies distribution(s) for each Python env. .travis.yml
is mostly a wrapper around tox.ini
- whereas tox itself sets up the python venvs inside Travis and runs pytest to execute tests found in ./tests
against the substring module provided in the find_substrings package located at ./src/find_substrings
. Tox also covers all other aspects of the python environment config.
Next, we use twine to automatically upload the find_substrings package to PyPI, after which anyone can install it by running pip install find_substrings
to install all python modules in ./src
and their dependencies as configured in setup.py
Alternatively, a requirements.txt
file is included so users can manually install dependencies using pip install -r requirements.txt
- For a one-click solution not relying on the package's setup.py
, users can run a shell script command such as virtualenv .env && source .env/bin/activate && pip install -r requirements.txt
- Add documentation with Sphinx
- Use pre-commit to automatically run pre-configured hooks on commits before merging e.g. to automatically format with Black.
- Publish to PyPI with Twine