From ca241a7a6066cb1d5d890e0aead209d7cbb621d3 Mon Sep 17 00:00:00 2001 From: Hofer-Julian Date: Tue, 7 Nov 2023 11:28:50 +0100 Subject: [PATCH] Streamline release process to PyPI - Add pixi tasks - Update docs --- docs/contribute/python.qmd | 27 --------------------------- docs/contribute/release.qmd | 13 ++++++++++++- pixi.toml | 13 +++++++++++++ 3 files changed, 25 insertions(+), 28 deletions(-) diff --git a/docs/contribute/python.qmd b/docs/contribute/python.qmd index 2a3abb1c5..6aa4ddb51 100644 --- a/docs/contribute/python.qmd +++ b/docs/contribute/python.qmd @@ -45,33 +45,6 @@ If the example models change, re-run this script. 2. Copy `.vscode/settings_template.json` into `.vscode/settings.json` -## How to publish to PyPI {#sec-pypi} - -1) Update `__version__` in `ribasim/__init__.py` - -2) Open a terminal and run `cd python/ribasim` - -3) Activate the ribasim environment with `conda activate ribasim` - -4) If present remove dist folder - -5) Re-create the wheels: -``` -python -m build -``` - -6) Check the package files: -``` -twine check dist/* -``` - -7) Make a new commit with the updated version number, and push to remote - -8) Re-upload the new files: -``` -twine upload dist/* -``` - ## Linting To run our linting suite locally, execute: diff --git a/docs/contribute/release.qmd b/docs/contribute/release.qmd index 0d8a7fc68..3cc227eaf 100644 --- a/docs/contribute/release.qmd +++ b/docs/contribute/release.qmd @@ -54,7 +54,18 @@ All changes ## Release Ribasim Python to PyPI -To be able to do `pip install ribasim`, Ribasim Python needs to be released on the Python Package Index, see [these instructions](python.qmd#sec-pypi) +To be able to install packages with `pip`, they need to be released on the Python Package Index (PyPI). +In order to publish Ribasim Python or Ribasim API follow the following steps: + +1) Update `__version__` in `__init__.py` + +2) Open a terminal and run `cd python/ribasim` + +3) Run `pixi run create-ribasim-python-wheel` or `pixi run create-ribasim-api-wheel` + +7) Make a new commit with the updated version number, and push to remote + +8) Publish on PyPI with `pixi run publish-ribasim-python` or `pixi run publish-ribasim-api` ## Wait for TeamCity to build the new release {#sec-teamcity} diff --git a/pixi.toml b/pixi.toml index 4ac7b151b..07ac3b58b 100644 --- a/pixi.toml +++ b/pixi.toml @@ -87,6 +87,19 @@ generate-python = """\ datamodel-codegen --use-title-as-name --use-double-quotes --disable-timestamp --use-default --strict-nullable --input-file-type=jsonschema --input docs/schema/root.schema.json --output python/ribasim/ribasim/models.py && \ datamodel-codegen --use-title-as-name --use-double-quotes --disable-timestamp --use-default --strict-nullable --input-file-type=jsonschema --input docs/schema/Config.schema.json --output python/ribasim/ribasim/config.py""" codegen = { depends_on = ["generate-schema", "generate-python", "lint"] } +# Publish +create-ribasim-python-wheel = { cmd = "rm --recursive --force dist && python -m build && twine check dist/*", cwd = "python/ribasim" } +create-ribasim-api-wheel = { cmd = "rm --recursive --force dist && python -m build && twine check dist/*", cwd = "python/ribasim_api" } +create-wheels = { depends_on = [ + "create-ribasim-python-wheel", + "create-ribasim-api-wheel", +] } +publish-ribasim-python = { cmd = "twine upload dist/*", cwd = "python/ribasim", depends_on = [ + "create-ribasim-python-wheel", +] } +publish-ribasim-api = { cmd = "twine upload dist/*", cwd = "python/ribasim_api", depends_on = [ + "create-ribasim-api-wheel", +] } [dependencies] build = "*"