setup.py is located)install the package from the command line:
# activate your environment
source activate class # linux/macos
activate class # windows
# install the package in development mode
pip install -e .now in any python session within this environment you can import your package functions, e.g.:
from awesome import module
module.hello()or call functions listed in the setup.py -> entry_points directly from the command-line:
helloany code changes you make will be automatically reflected in the command-line calls and after each new import of the package in a python session - but don’t use the console for testing!
pytest tests/test_package.py from the command line (you may have to pip install pytest first) - take a look at the tests/test_package.py file to see what it checkspytest src/awesome/module.py --doctest-modulestox from the command line (you may have to pip install tox first)tox -e py36 - take a look at the tox.ini to see how it is setup and use tox -l to find the list of available testing environmentssphinx-build sphinx docs form the command line (you may have to pip install sphinx sphinx_rtd_theme m2r first)docs folder and open the index.html to see your documentationtox -e docs (see tox.ini for what it does)docs folder to GitHub and go to your repository Settings –> GitHub Pages –> Source: select master branch/docs foldersrc/awesome/version.py and see how it affects calling hello and toxsetup.py, the name of the src/awesome folder, as well as in sphinx/conf.py and spinx/reference.rst (the latter two to also have your documentation reflect the changes)setup.py up-to-date with the dependencies and other information (for additional information, here is the documentation for setuptools) (Note that there is a gradual movement in the python community away from setup.py and towards a pyrproject.toml file with different project dependency managers such as e.g. poetry - the final best practice solution is still in flux so we are recommending to stick with setup.py for now).travis.yml file to make this possiblepip install blackblack src or black tests, it will reformat all python files in the respective folders to fit its prescribed coding style.coverage package is a great toolpip install coveragecoverage run -m pytest --doctest-modules and then coverage report for a summary of the resultscoverage report and launch the created htmlcov/index.html fileyour users (or you) can install your package directly from GitHub using the following syntax:
pip install git+https://github.com/USER/REPO.gitfor wider distribution it is useful to upload your package to the Python Package Index (PyPI) at which point it will become available to your users via regular pip install:
pip install PGKNAMEif you have already settled on a name for your package (it must be unique on PyPI!), it is worthwhile registering the name with PyPI using the following command from your main package directory (you’ll need a PyPI account first and then user your login credentials):
python setup.py registerand to actually upload/update your package on PyPI:
python setup.py sdist uploadnote that the sdist part creates a distribution .tar.gz file in your dist folder which you could also manually distribute to others (or use to test-install your package although we recommend taking the GitHub route for this)