Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streamline release process to PyPI #750

Merged
merged 2 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
11 changes: 10 additions & 1 deletion docs/contribute/release.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,16 @@ 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 `pixi run create-ribasim-python-wheel` or `pixi run create-ribasim-api-wheel`

3) Make a new commit with the updated version number, and push to remote

4) 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",
] }
Hofer-Julian marked this conversation as resolved.
Show resolved Hide resolved
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
Loading