forked from CryPTSys/PharmaPy
-
Notifications
You must be signed in to change notification settings - Fork 2
Add pharmapy-sim distribution, pixi environments, and install guide #136
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
Open
bernalde
wants to merge
6
commits into
master
Choose a base branch
from
build/pixi-environment
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
145e0f2
build: add pixi environments for reproducible conda-forge dev/CI
bernalde 232cbb9
build: define pip distribution and install guide
bernalde cc50392
docs: clarify pip and Assimulo installation paths
bernalde a37e50e
ci: verify locked pixi environments
bernalde a8517cc
ci: make pixi lock verification gating
bernalde 98359b2
build: add locked Windows pixi environments
bernalde File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,251 @@ | ||
| # Installing PharmaPy | ||
|
|
||
| PharmaPy has a pip-installable core and an optional Assimulo solver backend. | ||
| Choose the installation path that matches the work you need to do: | ||
|
|
||
| - Use **pip** for the core library and solver-free development. | ||
| - Use **pixi** for a reproducible development environment or any work that | ||
| requires Assimulo. | ||
|
|
||
| pixi is a development and solver-environment tool. It is not a PharmaPy runtime | ||
| dependency and does not replace the package metadata used by pip. | ||
|
|
||
| The installation commands intentionally produce different environments: | ||
|
|
||
| | Command | Assimulo included? | Intended use | | ||
| | --- | --- | --- | | ||
| | `python -m pip install .` | No | Core library for users | | ||
| | `pixi install --locked` | No | Reproducible core development | | ||
| | `pixi install -e assimulo --locked` | Yes | Solver-backed development and use | | ||
| | `pixi install --all --locked` | Yes, in the separate `assimulo` environment | Maintainer verification of both environments | | ||
|
|
||
| ## Package and import names | ||
|
|
||
| The planned PyPI distribution name is **`pharmapy-sim`**. The Python import name | ||
| remains **`PharmaPy`**: | ||
|
|
||
| ```python | ||
| import PharmaPy | ||
| ``` | ||
|
|
||
| There is not yet a PharmaPy process-simulation release on PyPI. Until one is | ||
| published, install this project from a source checkout as described below. Do | ||
| not run `pip install pharmapy`: that name belongs to an unrelated project. | ||
| The `pharmapy-sim` name remains unreserved until the first release is uploaded; | ||
| maintainers must recheck its availability immediately before publishing and | ||
| must not advertise the index-install command until that upload succeeds. | ||
|
|
||
| ## Core installation with pip | ||
|
|
||
| The core installation supports Python 3.9 or newer and does not install | ||
| Assimulo. | ||
|
|
||
| Clone the repository and enter it: | ||
|
|
||
| ```bash | ||
| git clone https://github.com/PharmaPy-org/PharmaPy.git | ||
| cd PharmaPy | ||
| ``` | ||
|
|
||
| Create and activate a virtual environment: | ||
|
|
||
| ```bash | ||
| python -m venv .venv | ||
| ``` | ||
|
|
||
| On Linux or macOS: | ||
|
|
||
| ```bash | ||
| source .venv/bin/activate | ||
| ``` | ||
|
|
||
| On Windows PowerShell: | ||
|
|
||
| ```powershell | ||
| .venv\Scripts\Activate.ps1 | ||
| ``` | ||
|
|
||
| Install PharmaPy: | ||
|
|
||
| ```bash | ||
| python -m pip install --upgrade pip | ||
| python -m pip install . | ||
| ``` | ||
|
|
||
| Verify the installation: | ||
|
|
||
| ```bash | ||
| python -c "import PharmaPy; print(PharmaPy.__file__)" | ||
| ``` | ||
|
|
||
| For editable development and the core test dependencies, use: | ||
|
|
||
| ```bash | ||
| python -m pip install -e ".[test]" | ||
| python -m pytest tests/ -m "not assimulo" | ||
| ``` | ||
|
|
||
| After the first `pharmapy-sim` release is published, the core installation | ||
| command will be: | ||
|
|
||
| ```bash | ||
| python -m pip install pharmapy-sim | ||
| ``` | ||
|
|
||
| The `assimulo` optional extra contains only the Cython helper used by source | ||
| build workflows; it cannot install the current supported Assimulo release from | ||
| PyPI. | ||
|
|
||
| ## Why pixi is used | ||
|
|
||
| pip remains the primary installation mechanism for the PharmaPy package. pixi | ||
| is used for the development and solver environment because Assimulo wraps | ||
| compiled SUNDIALS, Cython, C, and Fortran components. The | ||
| [Assimulo release on PyPI](https://pypi.org/project/Assimulo/) does not provide | ||
| a compatible wheel for PharmaPy's supported Python versions, whereas | ||
| [conda-forge provides compiled Assimulo packages](https://anaconda.org/conda-forge/assimulo). | ||
|
|
||
| pixi can resolve those conda-forge binaries, install the local PharmaPy package | ||
| editably, and record the complete result in `pixi.lock`. Keeping pixi | ||
| configuration under `[tool.pixi]` means that it does not become a dependency of | ||
| the PharmaPy wheel and does not change how the package is built or published to | ||
| PyPI. | ||
|
|
||
| Plain `environment.yml` remains a simpler fallback, but it does not pin the | ||
| complete transitive environment. The lockfile is the reason to retain pixi; if | ||
| the project stops testing and maintaining that lockfile, pixi would add | ||
| maintenance cost without providing its intended reproducibility benefit. | ||
|
|
||
| ## Reproducible installation with pixi | ||
|
|
||
| The committed `pixi.lock` supports `linux-64` and `win-64`. Install pixi using | ||
| its | ||
| [official installation instructions](https://pixi.prefix.dev/latest/installation/). | ||
| The native Windows installer used to verify this guide can be run from | ||
| PowerShell: | ||
|
|
||
| ```powershell | ||
| powershell -ExecutionPolicy Bypass -c "irm -useb https://pixi.sh/install.ps1 | iex" | ||
| ``` | ||
|
|
||
| Open a new terminal after installation so that `pixi` is available on `PATH`. | ||
| Then clone and enter the repository: | ||
|
|
||
| ```bash | ||
| git clone https://github.com/PharmaPy-org/PharmaPy.git | ||
| cd PharmaPy | ||
| ``` | ||
|
|
||
| The available environments are: | ||
|
|
||
| - `default`: core dependencies without Assimulo | ||
| - `assimulo`: the full solver stack with Assimulo 3.4.3 and SUNDIALS | ||
|
|
||
| For work that requires Assimulo, install its locked environment explicitly: | ||
|
|
||
| ```bash | ||
| pixi install -e assimulo --locked | ||
| ``` | ||
|
|
||
| This command installs both PharmaPy and Assimulo in the named environment. | ||
| Verify that both imports work: | ||
|
|
||
| ```bash | ||
| pixi run -e assimulo python -c "import PharmaPy, assimulo" | ||
| ``` | ||
|
|
||
| For core-only development, install the default environment: | ||
|
|
||
| ```bash | ||
| pixi install --locked | ||
| ``` | ||
|
|
||
| Maintainers can install both environments together: | ||
|
|
||
| ```bash | ||
| pixi install --all --locked | ||
| ``` | ||
|
|
||
| Run the matching test lanes: | ||
|
|
||
| ```bash | ||
| pixi run test | ||
| pixi run -e assimulo test-assimulo | ||
| ``` | ||
|
|
||
| Run Python or a script in either environment: | ||
|
|
||
| ```bash | ||
| pixi run python -c "import PharmaPy" | ||
| pixi run -e assimulo python -c "import PharmaPy, assimulo" | ||
| pixi run -e assimulo python path/to/script.py | ||
| ``` | ||
|
|
||
| You can also start an activated shell with `pixi shell` or | ||
| `pixi shell -e assimulo`. | ||
|
|
||
| macOS is not currently present in the committed lockfile. Maintainers extending | ||
| platform support must add the platform under `[tool.pixi.workspace].platforms`, | ||
| regenerate `pixi.lock`, and verify both test lanes on that platform. | ||
|
|
||
| ## What is tested | ||
|
|
||
| The following installation paths were run successfully on `linux-64` when this | ||
| guide was introduced: | ||
|
|
||
| - A fresh Python 3.11 virtual environment ran `python -m pip install .`, | ||
| `python -m pip check`, and `import PharmaPy`. Wheel and source-distribution | ||
| builds also passed. | ||
| - `pixi install --all --locked` installed both locked environments. | ||
| - The core pixi test lane passed. | ||
| - The Assimulo pixi test lane passed and imported both `PharmaPy` and Assimulo | ||
| 3.4.3. | ||
|
|
||
| The native `win-64` lock was then generated and verified with pixi 0.67.1 and | ||
| Python 3.11: | ||
|
|
||
| - `pixi install --all --locked` installed the core and Assimulo environments. | ||
| - The core lane passed 56 tests, with 4 skipped and 6 deselected. | ||
| - The Assimulo lane imported Assimulo 3.4.3 and passed all 14 selected | ||
| integration tests. | ||
|
|
||
| Continuous integration exercises both installation promises: | ||
|
|
||
| - The core job installs PharmaPy editably with pip and runs the solver-free | ||
| tests. | ||
| - The gating locked-environment job runs on Linux and Windows, installs both | ||
| pixi environments from the committed lockfile, reruns the documented | ||
| `pixi install --all --locked` command, and verifies the core and Assimulo | ||
| imports. | ||
| - A separate advisory job runs the solver-backed tests with | ||
| `continue-on-error: true`, preserving the project's tolerance for instability | ||
| in the compiled Assimulo/SUNDIALS integration without weakening the lockfile | ||
| check. | ||
|
|
||
| Maintainers changing dependencies should also run the same checks locally: | ||
|
|
||
| ```bash | ||
| pixi lock --check | ||
| pixi install --all --locked | ||
| pixi run test | ||
| pixi run -e assimulo test-assimulo | ||
| ``` | ||
|
|
||
| Keeping the pip-based core CI lane alongside a gating locked-pixi job proves | ||
| both installation promises: PharmaPy remains pip-installable, and the compiled | ||
| solver environment remains reproducible. The advisory solver-test job reports | ||
| integration health separately. | ||
|
|
||
| ## Manual conda fallback for Assimulo | ||
|
|
||
| `environment.yml` remains available as an unlocked conda-forge fallback: | ||
|
|
||
| ```bash | ||
| conda env create -f environment.yml | ||
| conda activate pharmapy-assimulo | ||
| python -m pip install -e . --no-deps | ||
| python -m pytest tests/ -m assimulo | ||
| ``` | ||
|
|
||
| Prefer pixi when possible because its committed lockfile records the complete | ||
| resolved environment. |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.