diff --git a/.gitattributes b/.gitattributes index e5c3e2a282..bc9b09c3e6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7,3 +7,5 @@ sasview/test/* linguist-language=Other *.h text eol=lf *.cpp text eol=lf *.rst text eol=lf +# SCM syntax highlighting & preventing 3-way merges +pixi.lock merge=binary linguist-language=YAML linguist-generated=true -diff diff --git a/.gitignore b/.gitignore index 80a030a709..e33213a711 100644 --- a/.gitignore +++ b/.gitignore @@ -81,3 +81,5 @@ tests.log /installers/dist *.exe installers/credits.html +# pixi environments +.pixi/* diff --git a/INSTALL.md b/INSTALL.md index 7911ff9d2e..227209a91b 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -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. ## 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 +pixi shell + +# 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. diff --git a/pyproject.toml b/pyproject.toml index 6e9bc548af..34b5409b83 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"] \ No newline at end of file +section-order = ["future", "standard-library", "third-party", "sas", "first-party", "local-folder"] + +[tool.pixi.workspace] +channels = ["conda-forge"] +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 } +# 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" }