Installation
Following Sections provide overview on how to install the package.
Contents
Using This Project Template
Use the following guide to fully take advantage of this project template:
Install Pyenv (only if not already present):
Download and install using bash:
$ curl https://pyenv.run | bash
Add the following lines to your
~/.bashrcto make pyenv known to your system:$ export PATH="~/.pyenv/bin:$PATH" $ eval "$(pyenv init -)" $ eval "$(pyenv virtualenv-init -)"
Open a new shell, or
source ~/.bashrcin your current shellInstall the Python build dependencies for your platform, using one of the commands listed in the official instructions. For example, on a recent Ubuntu this would be:
$ sudo apt update && sudo apt install -y make build-essential libssl-dev zlib1g-dev \ $ libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \ $ libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl git
Create a new folder representing your repo/published package using kebab case:
$ mkdir my-project
Install the desired python versions using pyenv:
$ pyenv install 3.10.4 $ pyenv install 3.9.13 $ pyenv install 3.8.13
Clone the hpmpy-template into your new local repo folder:
$ git clone https://github.com/tZ3ma/hpmpy-project my-project
Change into the new project folder and ctivate the desired python versions
$ cd my-project $ pyenv local 3.10.4 3.9.13 3.8.13
Install poetry (only if not already present)
Download the poetry install script and run it
$ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
Open a new shell or
source ~/.poetry/envin your current shell
Install nox:
$ pip install --user --upgrade nox
Rename all hpmpy instances after your project using git grep by replacing
MY-PROJECTbelow:$ git grep -lz hpmpy-project | xargs -0 sed -i -e "s/hpmpy-project/MY-PROJECT/g" $ git grep -lz hpmpy_project | xargs -0 sed -i -e "s/hpmpy_project/MY_PROJECT/g"
Rename the
src/hpmpy_projectpackage folder by replacingMY_PROJECTbelow:$ mv src/hpmpy_project src/MY_PROJECT
Install your package using poetry:
$ poetry install
Run your first nox sessions:
$ noxBump your package version to 0.1.0:
$ poetry version minor
Modify the tests/test_version.py file accordingly
Create a remote repo on Github
Integrate your PyPI and TestPyPI API-Token as explained in the release workflow sections.
Add coverage reports using Codecov:
Go to the Codecov website and login using your Github account.
Click on
not yet setupand copy the API-Token in point 2.Make it a Secret in your remote repo called
CODECOV_TOKENYour next push to the remote repo will trigger the test workflow in
.github/workflows/tests.ymlwhich will then automatically upload the coverage report to Codecov
Install and add git pre-commit hooks:
pip install --user --upgrade pre-commit pre-commit install
Add, commit and push all changes to your new remote repo:
$ git add -A $ git commit -m "Project Initialization" $ git remote set-url origin https://github.com/GIT-USER/MY-PROJECT.git $ git branch -M main $ git push -u origin main
All set up! Now branch of your main branch to create the develop branch and add first implementations:
Create switch to new develop branch:
$ git checkout -b develop
Modify the
README.rst,docs/index.rstand thedocs/source/getting_started/installation.rstfiles to refelct your project description.Add sub-packages and/or modules to the
src/strutils/folderAdd, commit and push all changes/addition to your remote repo
$ git add -A $ git commit -m "Initial Implementation" $ git push -u origin develop
(Optional) Create accounts on Codacy, Codeclimate and Scrutinizer for code quality checks using you Github account.
All done! Make sure to checkout the Workflows Developer Guide to acquaint yourself with the usage of Poetry, Nox and Github.
Development Install of Your Package Created with this Template
Install Pyenv (only if not already present)
Clone the repo to a local directory (uses package name if square bracket part is omitted):
$ git clone https://github.com/tZ3ma/hpmpy-project [hpmpy-project-develop]
Change to the new local repo folder and activate the desired python versions using pyenv:
$ cd strutils $ pyenv install 3.10.4 (adjust version to your needs) $ pyenv install 3.9.13 (optional) $ pyenv install 3.8.13 (optional) $ pyenv local 3.10.4 3.9.13 3.8.13 (activate those desired)
Install the package with development requirements:
$ poetry install
- 56 Auto generate and activate a virtual environment where the installed package
is installed:
$ poetry shell
(Optional) Alternatively, you can now run an interactive Python session, or the command-line interface if your package supports it:
$ poetry run python $ poetry run hpmpy-project
User Install of Your Package Created with this Template
Use the following advice to install the standard / user version of this package, once you have at least one push on your main and develop branch (so the respective release workflows are triggered).
Linux
Install using a console with your virtual environment activated:
Latest Stable Version
$ pip install hpmpy-project
Latest Development Version (potentially unstable)
$ pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ hpmpy-project
This installs the TestPyPI version of MY-PROJECT while resolving the dependencies on PyPI.