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..acd1c6c64 100644 --- a/docs/contribute/release.qmd +++ b/docs/contribute/release.qmd @@ -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 build-ribasim-python-wheel` or `pixi run build-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} diff --git a/pixi.toml b/pixi.toml index 4ac7b151b..46afcf750 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 +build-ribasim-python-wheel = { cmd = "rm --recursive --force dist && python -m build && twine check dist/*", cwd = "python/ribasim" } +build-ribasim-api-wheel = { cmd = "rm --recursive --force dist && python -m build && twine check dist/*", cwd = "python/ribasim_api" } +build-wheels = { depends_on = [ + "build-ribasim-python-wheel", + "build-ribasim-api-wheel", +] } +publish-ribasim-python = { cmd = "twine upload dist/*", cwd = "python/ribasim", depends_on = [ + "build-ribasim-python-wheel", +] } +publish-ribasim-api = { cmd = "twine upload dist/*", cwd = "python/ribasim_api", depends_on = [ + "build-ribasim-api-wheel", +] } [dependencies] build = "*" diff --git a/python/ribasim_api/README.md b/python/ribasim_api/README.md new file mode 100644 index 000000000..fd6c07199 --- /dev/null +++ b/python/ribasim_api/README.md @@ -0,0 +1,23 @@ +# Ribasim API + +`ribasim_api` is an extension to [xmipy](https://pypi.org/project/xmipy/) for the Ribasim API. + +The `ribasim_api` can be used to access functionality in the eXtended Model Interface (XMI) wrapper (XmiWrapper) +and additional functionality specific to the Ribasim API. + + +`ribasim_api` can be installed by running + +``` +pip install ribasim-api +``` + +or + +``` +conda install -c conda-forge ribasim-api +``` + +# Contributing + +For the developer docs please have a look at https://deltares.github.io/Ribasim/python/developer.html diff --git a/python/ribasim_api/ribasim_api/__init__.py b/python/ribasim_api/ribasim_api/__init__.py index 5c8b7720c..9d4736142 100644 --- a/python/ribasim_api/ribasim_api/__init__.py +++ b/python/ribasim_api/ribasim_api/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.3.0" +__version__ = "0.4.0" from ribasim_api.ribasim_api import RibasimApi