Package: aequitas-lib
Python project templateA simple template of a Python project, with a rigid file structure, and predisposition for unit testing and release on PyPi.Relevant featuresAll your project code into a single main package (aequitas-lib/)All your project tests into a single test package (test/)Unit testing support viaunittestAutomatic testing on all branches via GitHub ActionsSemi-automatic versioning via GitPackaging support viasetuptoolsAutomatic release onPyPivia GitHub ActionsDocker image support viaDockerfileAutomatic release onDockerHubvia GitHub ActionsSupport for semi-automatic development environment management viaPyenvAutomatic dependencies updates viaRenovateAutomatic conversion ofTODOcomments into GitHub issues via thealstr/todo-to-issue-actionProject structureOverview:<rootdirectory>
├──aequitas-lib/# main package (should be named after your project)│├──__init__.py# python package marker│└──__main__.py# application entry point├──test/# test package (should contain unit tests)├──.github/# configuration of GitHub CI│└──workflows/# configuration of GitHub Workflows│├──check.yml# runs tests on multiple OS and versions of Python│└──deploy.yml# if check succeeds, and the current branch is one of {main, master}, triggers automatic releas on PyPi├──MANIFEST.in# file stating what to include/exclude in releases├──LICENSE# license file (Apache 2.0 by default)├──pyproject.toml# declares build dependencies├──renovate.json# configuration of Renovate bot, for automatic dependency updates├──requirements-dev.txt# declares development dependencies├──requirements.txt# declares runtime dependencies├──setup.py# configuration of the package to be released on Pypi└──Dockerfile# configuration of the Docker image to be realsed on DockerhubTODO-list for template usageUse this template to create a new GitHub repository, sayaequitas-libthis name will also be used to identify the package on PyPiso, we suggest choosing a name which has not been used on PyPi, yetwe also suggest choosing a name which is a valid Python package name (i.e.using_snake_case)Clone theaequitas-librepositoryOpen a shell into your localaequitas-libdirectory and run./rename-template.shaequitas-libThis will coherently rename the template's project name with the one chosen by you (i.e.aequitas-lib, in this example)Commit & pushEnsure you like theApache 2.0 License. If you don't, change the content of theLICENSEfileEnsure the version reported in.python-versioncorresponds to the actual Python version you are willing to use to develop your projectCheck the Python version and OS tests should be run on in CI, by looking the file.github/workflows/check.ymlAdd your runtime dependencies torequirements.txtand development-only dependencies hererequirements-dev.txtSet your project's release metadata and dependencies by editingsetup.pyChange the assignee for pull-requests for automatic dependency updates by editingrenovate.jsoncurrently defaults to @gciattoAdd your PyPi credentials as secrets of the GitHub repositoryPYPI_USERNAME(resp.PYPI_PASSWORD) for your username (resp. password)this may require you to register on PyPi firstGenerate a GitHub token and add it as a secret of the GitHub repository, namedRELEASE_TOKENcf.https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classicthe token must allow pushing to the repositoryPut your main (resp. test) code inaequitas-lib/(resp.test/)How to do stuffRun your code as an applicationThis will execute the fileaequitas-lib/__main__.py:python-maequitas-libRun unit testspython-munittestdiscover-stest-t.Tests are automatically run in CI, on all pushes on all branches.
There, tests are executed on multiple OS (Win, Mac, Ubuntu) and on multiple Python versions (from3.8to3.11).Restore dev dependenciespipinstall-rrequirements-dev.txtRelease a new version on PyPiThis paragraph is more understandable if the reader has some background aboutGitFlowGitHub actions automatically release a new version ofaequitas-libon PyPi whenever commits are pushed on either themain/masterordevelopbranches, as well as when new tags are pushed.Tags are assumed to consist ofsemantic versioningstrings of the formMajor.Minor.PatchwhereMajor,Minor, andPatchare non-negative integers.So, to release versionX.Y.Z, developers must:tag a commit on themaster/main/developbranch, usingX.Y.Zas the tag labelgittag-a'X.Y.Z'-m<amessageheredescribingtheversion>push the taggitpush--follow-tagsGitHub Actions will then run tests and, if all of them succeed, release the code on PyPi.
After the release, users will be able to install your code via Pip.Non-tagged commits pushed on themaster/main/developbranch will triggerdev releases.
Dev releases are automatically tagged asX.Y.Y.devN, whereX.Y.Yis the value of themost recentversion tagNis the amount of commits following the most recent version tag