Skip to content

Commit

Permalink
Streamline release process to PyPI
Browse files Browse the repository at this point in the history
- Add pixi tasks
- Update docs
  • Loading branch information
Hofer-Julian committed Nov 7, 2023
1 parent 5ecfd83 commit ca241a7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 28 deletions.
27 changes: 0 additions & 27 deletions docs/contribute/python.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 12 additions & 1 deletion docs/contribute/release.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
13 changes: 13 additions & 0 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "*"
Expand Down

0 comments on commit ca241a7

Please sign in to comment.