Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,5 @@ tests.log
/installers/dist
*.exe
installers/credits.html
# pixi environments
.pixi/*
75 changes: 62 additions & 13 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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;
Expand Down Expand Up @@ -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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: This is in both the venv and Pixi instructions. This shouldn't hold up this PR, but might make sense to add a section called Obtaining the source code. This section could also have instructions on cloning the bumps and periodictable repos.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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
Comment thread
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.

Expand Down
17 changes: 16 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
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 }
Comment thread
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" }
Loading