A little bit of foobar in your life
Project description
pyfoobar
A Python project template that highlights some best practices in Python packaging. Can be used as a GitHub template for your new Python project.
Best practices
-
The name of the git repo should be the PyPi name of the package should be what you you type as
import mypackagename
. That means no hyphens in package names! -
Your package should be a one-trick pony. Nobody wants to install a huge toolbox if all they need is the image converter in it.
-
After
import yourpackagename
, people should be able to callyourpackagename.__version__
plus some other meta data. This helps with debugging. -
Use linting and formatting, include those in your integration tests. black is a formatter that I like because you cannot configure it -- black is black. Good linters are flake8 or pylint.
-
Once you have tests in order, make sure they are executed with every git push. Two popular CI services that run your tests are travis and circleci. This repository contains the config files for each of the two.
-
Make sure that nobody can push to master. On GitHub, go to Settings -> Branches -> Add rule and select Require status checks to pass before merging and Include administrators. Development happens in pull requests, this makes sure that nobody -- including yourself -- ever accidentally pushes something broken to master.
-
Use a tool for measuring test coverage. codecov is one, and the circleci config submits the data to it.
-
Bitches love badges. If you have CI set up, want to show test coverage, or advertise the availability on PyPi, do so using a badge at the top of your README. Check out shields.io for what's available.
What you can do with this template
First run
find . -type f -name "*.py" -o -name Makefile -o -name "*.yml" -print0 | xargs -0 sed -i 's/pyfoobar/your-project-name/g'
and rename the folder pyfoobar
to customize the name.
There is a simple Makefile
that can help you with certain tasks:
-
Run
make black
to apply black formatting. -
Run
make lint
to run flake8 linting -
Run
make publish
to- tag your project on git (
make tag
) - upload your package to PyPi (
make upload
)
After publishing, people can install your package with
pip3 install --user pyfoobar
- tag your project on git (
Testing
To run the pyfoobar unit tests, check out this repository and type
pytest
License
pyfoobar is published under the MIT license.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pyfoobar-0.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2dd3c81c5ba44f9b963281b17ae179e34ca29ffc5eae8ef44cc3f82334140ee4 |
|
MD5 | 5a7141255b558451a1941aa3b71cb6a5 |
|
BLAKE2b-256 | 160a62b65684dcadfef37c4ee8526fdbea20757d0e169a2b1dbb8f043f2c347a |