A cookiecutter based project template for Brightway ecosystem packages.
We prefer using cruft
as tooling to create/check/update projects created with the template over direct cookiecutter because of the following features of cruft:
- it is actively maintained
- it allows to check if the project is up to date with the template
- it allows to update the project, based on changes on the template
- Create a new environment (pip, conda, mamba, choose your 💊),
- Activate the newly created envionrment and install
cruft
(mamba install cruft
for example) - Create a project with:
cruft create https://github.com/brightway-lca/cookiecutter-brightwaylib
You will be asked for the following information:
- "full_name"
- "email"
- "project_name". This will be the github repo and pypi name. Should not include dashes or spaces.
- "github_username" if not intended for submission to
https://github.com/brightway-lca/
- A one-sentence project description
- Version string (default 0.0.1)
- Which license to use (default MIT)
If the cookiecutter template is updated, you can upgrade your project with:
cruft update
inside the repository of the project. See cruft documentation for more on this.
The template provides enough information to build a PyPI
and conda
package, under the pyproject.toml
and conda.recipe/meta.yaml
files.
Make sure you have "build" installed, and then you can build the package with:
python -m build --outdir dist/ .
Make sure you have conda-build
installed, and then you can build the package with:
conda config --set anaconda_upload no
conda build -c conda-forge conda.recipe .
The previous snippet disables automatic uploading to anaconda. You can see the publishing/uploading part below.
The template includes github actions to automatically publish/upload the packages to PyPI
and anaconda.org
, but you can find below the instructions to do it manually as well.
The repository is configured to do the publishing/uploading automatically on develop
and main
branches.
You have to enable trusted publishing from your PyPI account for this to work.
Hint: the publisher is the python-package-deploy.yml
.
If you prefer to deactivate the automatic github actions, here is how to publish/upload.
- Install
build
andtwine
in your current or a new environment - Configure
twine
with you pypi username and password and with your pypi API token. - Run
python -m build
- Run
twine upload dist/*
You can also consider uploading to testpypi first to test that the process works fine.
The repository is configured to do the publishing/uploading automatically on develop
and main
branches.
You must add 2 secrets to your repository:
ANACONDA_USER
ANACONDA_PASSWORD
- Install
conda-build
andanaconda-client
in your current or a new environment - Use
anaconda
to login to anaconda.org (see anaconda documentation conda config --set anaconda_upload yes
- Build and upload the package with:
conda build -c conda-forge conda.recipe .
- github actions:
- test
main
anddevelop
on push and on pull requests to this branches on the following:- os: [ubuntu-latest, windows-latest, macos-latest] and one version before.
- py-version: ["3.9", "3.10", "3.11", "3.12"]
- build source and wheel distribution packages using build as backend
- upload to
test.pypi.org
on push events to thedevelop
andmain
branches. - upload to
pypi.org
on tagged push events to thedevelop
andmain
branch with tags.
- test
- pytest
- source folder is at the root of the project, and not under
src
! pyproject.toml
used for everything
Follow the instructions at the pre-commit website.
In our pre-commit configuration, we run pylint, and this needs to be installed locally as its Github repo doesn't play nicely with pre-commit. Follow the instructions at the pylint website