Note: some badges above might not work unless you use CI (Github or Gitlab) and publish your app on Pypi
This is just a sample helloworld project which aims to provide some good (at least not so bad) praticies to start a new project.
Basically, you can clone this repository and run sed -i 's/helloworld/YOURPROJECTNAME/g' ;)
This project uses Poetry, ensure you have Poetry installed
$ pip3 install poetry $ poetry --version Poetry version 1.1.12 To clone the project
$ git clone https://github.com/essembeh/python-helloworld $ cd python-helloworldTo create the virtual env with all needed dependencies
$ poetry install $ poetry shell (.venv) $ helloworld --helpTo run the tests
# to run the tests: $ poetry run pytest # to get the coverage $ poetry run pytestYou can use Poetry to build your app and get a .whl
$ poetry build Building helloworld (0.1.0) - Building sdist - Built helloworld-0.1.0.tar.gz - Building wheel - Built helloworld-0.1.0-py3-none-any.whl $ ls dist helloworld-0.1.0-py3-none-any.whl helloworld-0.1.0.tar.gzYou can use Poetry to publish your app to PyPI
$ poetry publishBy default, Github Actions are configured to
- build your app and run your unit tests with coverage on every push
- build the wheel package and upload it to Pypi on every tag
Note: to allow Github CI to publish on PyPI, you need to create a token and add it to your project settings, the name of the token should be
PYPI_TOKEN
I personnally use this command to bump the version using poetry, create the associated git tag and push to Github:
# for a patch bump $ poetry version patch && git commit -a -m '🔖 New release' && git tag -f $(poetry version -s) && git push --tags # for a minor bump $ poetry version minor && git commit -a -m '🔖 New release' && git tag -f $(poetry version -s) && git push --tags # for a major bump $ poetry version major && git commit -a -m '🔖 New release' && git tag -f $(poetry version -s) && git push --tagsInstall from the sources
$ pip3 install poetry $ pip3 install git+https://github.com/essembeh/python-helloworld $ helloworld --helpInstall the latest release from PyPI
$ pip3 install python-helloworld $ helloworld --helpPoetry, a very useful tool to avoid boilerplate code (setup.py, requirements.txt, requirements-dev.txt ...)
VSCodium: a light IDE editor supporting Python with an extension. Some workspace settings in .vscode/settings.json are configured for example to work with the virtual environment.
Pylint: to report many warnings/errors (and VSCodium is configured to show them).
Black: a strict code formatter that automatically format source code on save using VSCodium.
Gitmoji: a list of emoji to get a more efficient history