Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: Add pixi project configuration #84

Merged
merged 10 commits into from
Jan 7, 2025
Merged
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
@@ -0,0 +1,2 @@
# SCM syntax highlighting
pixi.lock linguist-language=YAML linguist-generated=true
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,7 @@ book/1Lbb-likelihoods/

# Mac artifacts
.DS_Store

# pixi environments
.pixi
*.egg-info
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
all: build

defualt: build
default: build

build:
jupyter-book build book/
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@

## Setup

### Using `pixi` (recommended)

On any `x86` Linux machine or any macOS machine first install [`pixi`](https://pixi.sh/) and then from the top level of the repository run

```
pixi install --environment book
```

### Using a manually controlled virtual environment

In a Python virtual environment run the following

```
Expand All @@ -21,6 +31,14 @@ python -m pip install --require-hashes --requirement book/requirements.lock

To build the book after setup simply run

### Using `pixi`

```
pixi run build
```

### Local virtual environment

```
make build
```
Expand Down
93 changes: 65 additions & 28 deletions book/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,49 +25,52 @@ Instead, let's move to looking at the `pyhf` API right away.

::::{tab-set}

:::{tab-item} Locally
:::{tab-item} With pixi
```
$ pixi init
$ pixi shell
```
:::

:::{tab-item} With venv
```
$ python3 -m venv pyhf-tutorial
$ source pyhf-tutorial/bin/activate
(pyhf-tutorial) $ python -m pip install --upgrade pip setuptools wheel
(pyhf-tutorial) $ python -m pip install --upgrade pip
```
:::

:::{tab-item} On CC7 lxplus/tier-3
First we need to set up the 'views' with the right paths to ensure we use the correct `pip`

:::{tab-item} With conda
```
$ export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase
$ source $ATLAS_LOCAL_ROOT_BASE/user/atlasLocalSetup.sh
$ lsetup "views LCG_98python3 x86_64-centos7-gcc8-opt"
$ export PYTHONPATH=/cvmfs/sft.cern.ch/lcg/views/LCG_98python3/x86_64-centos7-gcc8-opt/python:/cvmfs/sft.cern.ch/lcg/views/LCG_98python3/x86_64-centos7-gcc8-opt/lib
$ conda create --name pyhf-tutorial --yes 'python=3.12'
$ conda activate pyhf-tutorial
```
:::

Then we can go ahead and create the virtual environment
:::{tab-item} On EL9 LXPLUS/tier-3
First we need to set up the 'views' that [already have `pyhf` installed](https://lcginfo.cern.ch/pkg/pyhf/)

```
$ python3 -m venv pyhf-tutorial
$ source pyhf-tutorial/bin/activate
(pyhf-tutorial) $ python -m pip install --upgrade pip setuptools wheel
$ export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase
$ . $ATLAS_LOCAL_ROOT_BASE/user/atlasLocalSetup.sh
$ lsetup "views LCG_106 x86_64-el9-gcc13-opt"
```
:::

:::{tab-item} On SLC6 lxplus/tier-3
First we need to set up the 'views' with the right paths to ensure we use the correct `pip`
Then we can install [`cvmfs-venv`](https://github.com/matthewfeickert/cvmfs-venv)

```
$ export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase
$ source $ATLAS_LOCAL_ROOT_BASE/user/atlasLocalSetup.sh
$ lsetup "views LCG_98python3 x86_64-slc6-gcc8-opt"
$ export PYTHONPATH=/cvmfs/sft.cern.ch/lcg/views/LCG_98python3/x86_64-slc6-gcc8-opt/python:/cvmfs/sft.cern.ch/lcg/views/LCG_98python3/x86_64-slc6-gcc8-opt/lib
$ mkdir -p ~/.local/bin
$ export PATH=~/.local/bin:"${PATH}"
$ curl -sL https://raw.githubusercontent.com/matthewfeickert/cvmfs-venv/main/cvmfs-venv.sh -o ~/.local/bin/cvmfs-venv
$ chmod +x ~/.local/bin/cvmfs-venv
```

Then we can go ahead and create the virtual environment
and use it to create a user controlled virtual environment

```
$ python3 -m venv pyhf-tutorial
$ source pyhf-tutorial/bin/activate
(pyhf-tutorial) $ python -m pip install --upgrade pip setuptools wheel
$ cvmfs-venv pyhf-tutorial
$ . pyhf-tutorial/bin/activate
(pyhf-tutorial) $ uv pip install --upgrade pip
```
:::

Expand All @@ -82,21 +85,39 @@ Not all parts of this user guide are able to run in Pyodide, but the pure Python

::::

Once you have a virtual environment set up, you can use `source pyhf-tutorial/bin/activate` to get back into it again. Note the prefix `(pyhf-tutorial) $` on your command line, which indicates that you're inside a virtual environment named 'pyhf-tutorial'.
Once you have a virtual environment set up, you can use `source pyhf-tutorial/bin/activate` to get back into it again (or `pixi shell` for `pixi`). Note the prefix `(pyhf-tutorial) $` on your command line, which indicates that you're inside a virtual environment named 'pyhf-tutorial'.

### Getting pyhf

If you haven't already, make a new Python 3 virtual environment and then install `pyhf` from either [PyPI](https://pypi.org/project/pyhf/) with `pip`
If you haven't already, make a new Python 3 virtual environment and then install `pyhf`

::::{tab-set}

:::{tab-item} pixi
from [conda-forge](https://anaconda.org/conda-forge/pyhf) with [`pixi`](https://pixi.sh/)

```
$ pixi add pyhf
```
:::

:::{tab-item} pip
from [PyPI](https://pypi.org/project/pyhf/) with `pip`

```
(pyhf-tutorial) $ python -m pip install pyhf
```
:::

or [Conda-forge](https://anaconda.org/conda-forge/pyhf)
:::{tab-item} conda
from [conda-forge](https://anaconda.org/conda-forge/pyhf) with [`conda`](https://docs.conda.io/)

```
(pyhf-tutorial) $ conda install --channel conda-forge pyhf
```
:::

::::

### Installation Extras

Expand Down Expand Up @@ -141,7 +162,23 @@ To get all the dependencies needed for this tutorial first clone the repository
(pyhf-tutorial) $ cd pyhf-tutorial
```

then you can just install from the included `requirements.txt` in the top level `binder/` directory of [the source repository](https://github.com/pyhf/pyhf-tutorial)
#### Using `pixi`

then simply run

```
pixi install
```

or to also start running the example notebooks run

```
pixi run start
```

#### Using `pip`

then install from the included `requirements.txt` in the top level `binder/` directory of [the source repository](https://github.com/pyhf/pyhf-tutorial)

```
(pyhf-tutorial) $ python -m pip install --upgrade --requirement binder/requirements.txt
Expand Down
Loading
Loading