diff --git a/.github/workflows/deploy-book.yml b/.github/workflows/deploy-book.yml new file mode 100644 index 00000000..a21e0ccd --- /dev/null +++ b/.github/workflows/deploy-book.yml @@ -0,0 +1,42 @@ +name: Deploy book +on: + # Deploy the book when the Rust (Linux) workflow completes on main + workflow_run: + workflows: ["Rust (Linux)"] + branches: [main] + types: + - completed + +jobs: + deploy: + runs-on: ubuntu-latest + permissions: + contents: write # To push a branch + pages: write # To push to a GitHub Pages site + id-token: write # To update the deployment status + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Install latest mdbook + run: | + tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name') + url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz" + mkdir mdbook + curl -sSL $url | tar -xz --directory=./mdbook + echo `pwd`/mdbook >> $GITHUB_PATH + - name: Build Book + run: | + # This assumes your book is in the root of your repository. + # Just add a `cd` here if you need to change to another directory. + mdbook build ./pywr-book + - name: Setup Pages + uses: actions/configure-pages@v2 + - name: Upload artifact + uses: actions/upload-pages-artifact@v1 + with: + # Upload entire repository + path: './pywr-book/book' + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v1 diff --git a/Cargo.toml b/Cargo.toml index e29f971f..eaaa2686 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ default-members = [ "pywr-core", "pywr-schema", "pywr-cli", - "pywr-python", + # "pywr-python", ] @@ -40,7 +40,7 @@ num = "0.4.0" ndarray = "0.15.3" polars = { version = "0.37.0", features = ["lazy", "rows", "ndarray"] } pyo3-polars = "0.11.1" -pyo3 = { version = "0.20.2" } +pyo3 = { version = "0.20.2", default-features = false } pyo3-log = "0.9.0" tracing = { version ="0.1", features = ["log"] } csv = "1.1" diff --git a/pywr-book/book.toml b/pywr-book/book.toml index 3613edc5..241792d1 100644 --- a/pywr-book/book.toml +++ b/pywr-book/book.toml @@ -3,4 +3,4 @@ authors = ["James Tomlinson"] language = "en" multilingual = false src = "src" -title = "The Pywr Book" +title = "Pywr User Guide" diff --git a/pywr-book/src/SUMMARY.md b/pywr-book/src/SUMMARY.md index f9bbbccb..d4fbe8be 100644 --- a/pywr-book/src/SUMMARY.md +++ b/pywr-book/src/SUMMARY.md @@ -2,8 +2,6 @@ - [Introduction](./introduction.md) - [Getting started](./getting_started.md) - - [Installation](./installation.md) - - [Licensing](./licensing.md) - [Related projects](./related_projects.md) - [Core concepts](./concepts/README.md) - [The network](./concepts/the-network.md) diff --git a/pywr-book/src/getting_started.md b/pywr-book/src/getting_started.md index 69a5d543..f3719830 100644 --- a/pywr-book/src/getting_started.md +++ b/pywr-book/src/getting_started.md @@ -1 +1,36 @@ -# Getting started +# Installation + +Pywr is both a Rust library and a Python package. + +## Rust + +TBC + +## Python + +Pywr requires Python 3.9 or later. +It is currently not available on PyPI, but wheels are available from the GitHub [actions](https://github.com/pywr/pywr-next/actions) page. +Navigate to the latest successful build, and download the archive and extract the wheel for your platform. + +```bash +pip install pywr-2.0.0b0-cp312-none-win_amd64.whl +``` +> **Note**: That current Pywr v2.x is in pre-release and may not be suitable for production use. +> If you require Pywr v1.x please use `pip install pywr<2`. + + +# Running a model + +Pywr is a modelling system for simulating water resources systems. +Models are defined using a JSON schema, and can be run using the `pywr` command line tool. +Below is an example of a simple model definition `simple1.json`: + +```json +{{#include ../../pywr-schema/src/test_models/simple1.json}} +``` + +To run the model, use the `pywr` command line tool: + +```bash +python -m pywr run simple1.json +``` diff --git a/pywr-book/src/installation.md b/pywr-book/src/installation.md deleted file mode 100644 index 25267fe2..00000000 --- a/pywr-book/src/installation.md +++ /dev/null @@ -1 +0,0 @@ -# Installation diff --git a/pywr-book/src/licensing.md b/pywr-book/src/licensing.md deleted file mode 100644 index a489b0ce..00000000 --- a/pywr-book/src/licensing.md +++ /dev/null @@ -1 +0,0 @@ -# Licensing diff --git a/pywr-python/Cargo.toml b/pywr-python/Cargo.toml index ce2b7b46..f3b14553 100644 --- a/pywr-python/Cargo.toml +++ b/pywr-python/Cargo.toml @@ -14,7 +14,7 @@ categories = ["science", "simulation"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -pyo3 = { workspace = true } +pyo3 = { workspace = true, features = ["extension-module", "macros"] } pyo3-polars = { workspace = true } pyo3-log = { workspace = true } serde = { workspace = true } @@ -24,9 +24,6 @@ time = { workspace = true, features = ["serde", "serde-well-known", "serde-human pywr-core = { path="../pywr-core" } pywr-schema = { path="../pywr-schema" } -[features] -extension-module = ["pyo3/extension-module"] -default = ["extension-module"] [lib] name = "pywr"