-
Notifications
You must be signed in to change notification settings - Fork 49
Add basic Pixi config in pyproject.toml and developer instructions
#3842
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,3 +81,5 @@ tests.log | |
| /installers/dist | ||
| *.exe | ||
| installers/credits.html | ||
| # pixi environments | ||
| .pixi/* | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |
| Whether you're installing SasView to use as a tool for your research or | ||
| because you're wanting to work on the code, it is recommended that you | ||
| work inside a Python virtual environment of some sort. | ||
| A `venv` or a `conda` are both popular choices. | ||
| A `venv` or a `Pixi` are both popular choices. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing word "environment" or some other rewording? (venv is both a tool and an environment type, pixi is a tool that manages environments) |
||
|
|
||
| ## Installing SasView as a User | ||
|
|
||
|
|
@@ -18,39 +18,49 @@ environment | |
|
|
||
| ## Making a SasView Development Environment | ||
|
|
||
| If you're familiar with working with developing in Python, then the very quick version is: | ||
| ### Prerequisite: Obtaining the source code | ||
|
|
||
| Obtain the SasView source using `git`. This step is the same whether you are using `venv` or Pixi to create the development environment. You will likely need to coordinate | ||
| updates to `sasdata` and `sasmodels`. The | ||
| [`bumps`](https://github.com/bumps/bumps) and | ||
| [`periodictable`](https://github.com/python-periodictable/periodictable) | ||
| packages are far more loosely coupled, but depending on what you are | ||
| doing you may also want them as development packages. | ||
|
|
||
| ```shell | ||
| # clone the repository | ||
| git clone https://github.com/sasview/sasdata/ | ||
| git clone https://github.com/sasview/sasmodels/ | ||
| git clone https://github.com/sasview/sasview/ | ||
| ``` | ||
|
|
||
| ### Develop using `venv` | ||
|
|
||
| If you're familiar with working with developing in Python, then the very quick version is: | ||
|
|
||
| ```shell | ||
| cd sasview | ||
|
|
||
| # create the virtual environment | ||
| # Create the virtual environment | ||
| python -m venv .venv | ||
| # .venv\Scripts\activate & REM Windows: activate environment | ||
| . .venv/bin/activate # Linux/Mac: activate environment | ||
|
|
||
| # install repositories in editable/developer mode in the venv | ||
| # use "python -m ..." to ensure the venv's pip is used | ||
| # Install repositories in editable/developer mode in the venv | ||
| # Use "python -m ..." to ensure the venv's pip is used | ||
| python -m pip install -e ../sasdata | ||
| python -m pip install -e ../sasmodels | ||
| python -m pip install -e .[dev,test] | ||
|
|
||
| # test if sasview launches | ||
| # Test if sasview launches | ||
| python -m sas | ||
|
|
||
| # To deactivate the virtual environment when finished developing | ||
| deactivate | ||
| ``` | ||
|
|
||
| Step by step, that is: | ||
|
|
||
| 1. Obtain the SasView source using `git`. You will likely need to coordinate | ||
| updates to `sasdata` and `sasmodels`. The | ||
| [`bumps`](https://github.com/bumps/bumps) and | ||
| [`periodictable`](https://github.com/python-periodictable/periodictable) | ||
| packages are far more loosely coupled, but depending on what you are | ||
| doing you may also want them as development packages. | ||
| 1. Create a Python virtual environment in the `.venv` directory. | ||
| 1. Activate the `.venv` so that Python and its modules from the venv are used. | ||
| Note that the particular syntax above works for the `bash` and `zsh` shells under Linux, Windows and macOS; | ||
|
|
@@ -87,7 +97,46 @@ debugging software, e.g.: | |
| - [VS Code](https://code.visualstudio.com/docs/python/environments) | ||
| - [PyCharm](https://www.jetbrains.com/help/pycharm/creating-virtual-environment.html) | ||
|
|
||
| ### Pre-Commit Hooks for Linting | ||
| ### Develop using Pixi | ||
|
|
||
| An alternative to `venv` is the package management tool Pixi. If Pixi is not | ||
| installed, follow the instructions [here](https://pixi.prefix.dev/latest/#installation). | ||
|
|
||
| The very quick version for developing using Pixi is: | ||
|
|
||
| ```shell | ||
| # Enter the developer environment | ||
| # (This will create (or reuse) a local Pixi environment with all required dependencies.) | ||
| cd sasview | ||
|
Comment on lines
+107
to
+110
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: This is in both the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made a change to extract this part into a section "Prerequisites". Please see if you think it makes sense. |
||
| pixi shell | ||
|
backmari marked this conversation as resolved.
|
||
|
|
||
| # Start the GUI | ||
| python -m sas | ||
|
|
||
| # Run tests | ||
| pixi run test | ||
|
|
||
| # Exit the developer environment when finished developing | ||
| exit | ||
| ``` | ||
|
|
||
| In more detail, the steps are: | ||
|
|
||
| 1. Create (or reuse) a local Pixi environment in `.pixi` and enter the shell | ||
| into the developer environment. The first time it will take a while to | ||
| download and unpack all dependencies. | ||
| Note that `sasdata`, `sasmodels` and `sasview` are installed in editable mode, | ||
| meaning that any code changes will be available the next time you run the | ||
| program. | ||
| 1. Run SasView! As an alternative to typing `python -m sas`, you can simply | ||
| type `sasview`. | ||
|
|
||
| Almost all the modules that SasView needs are available as precompiled modules | ||
| on PyPI, including numpy, scipy, h5py, pyside6. A handful of Python-only | ||
| modules will be built into wheels on your local machine. Installing the | ||
| dependencies should be a one-off task. | ||
|
|
||
| ## Pre-Commit Hooks for Linting | ||
|
|
||
| The SasView, SasData and SasModels repositories include [pre-commit hooks](https://pre-commit.com/), which can be set up to enable linting to be run on the code. A linter is a tool that can detect programming errors, bugs, stylistic errors, etc. SasView uses the [Ruff](https://docs.astral.sh/ruff/) package for linting. Ruff is able to warn about a wide range of possible errors, and in some cases apply automatic fixes for them. | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -237,4 +237,19 @@ ignore = ["E501", # line too long (leave to formatter) | |
| "sas" = ["sasdata", "sasmodels"] | ||
|
|
||
| [tool.ruff.lint.isort] | ||
| section-order = ["future", "standard-library", "third-party", "sas", "first-party", "local-folder"] | ||
| section-order = ["future", "standard-library", "third-party", "sas", "first-party", "local-folder"] | ||
|
|
||
| [tool.pixi.workspace] | ||
| channels = ["conda-forge"] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The edit to |
||
| platforms = ["linux-64", "win-64", "osx-arm64"] | ||
|
|
||
| [tool.pixi.pypi-dependencies] | ||
| sasview = { path = ".", editable = true, extras = ["test", "dev"]} | ||
| sasdata = { path = "../sasdata", editable = true } | ||
| sasmodels = { path = "../sasmodels", editable = true } | ||
|
backmari marked this conversation as resolved.
|
||
| # Uncomment if you want to install bumps and/or periodictable in editable mode: | ||
| # bumps = { path = "../bumps", editable = true } | ||
| # periodictable = { path = "../periodictable", editable = true } | ||
|
|
||
| [tool.pixi.tasks] | ||
| test = { description = "Run the test suite", cmd = "python -m pytest -s test" } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should
pixi.lockinstead be in.gitignoresince it is not being added?