Skip to content

Commit 18052cf

Browse files
feat: Add pixi project configuration (#84)
* Add pixi support for linux-64, osx-64, and osx-arm64 machines. - Add root_base only to the linux-64 book environment given poor macOS support. * Update README and introduction to add pixi instructions. * Add conda instructions to introduction. * Remove SLC6 and CentOS 7 LXPLUS instructions and add EL9 LXPLUS instructions using cvmfs-venv. * Fix typo in Makefile.
1 parent 1167038 commit 18052cf

File tree

7 files changed

+8202
-29
lines changed

7 files changed

+8202
-29
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# SCM syntax highlighting
2+
pixi.lock linguist-language=YAML linguist-generated=true

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,7 @@ book/1Lbb-likelihoods/
136136

137137
# Mac artifacts
138138
.DS_Store
139+
140+
# pixi environments
141+
.pixi
142+
*.egg-info

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
all: build
22

3-
defualt: build
3+
default: build
44

55
build:
66
jupyter-book build book/

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@
1111

1212
## Setup
1313

14+
### Using `pixi` (recommended)
15+
16+
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
17+
18+
```
19+
pixi install --environment book
20+
```
21+
22+
### Using a manually controlled virtual environment
23+
1424
In a Python virtual environment run the following
1525

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

2232
To build the book after setup simply run
2333

34+
### Using `pixi`
35+
36+
```
37+
pixi run build
38+
```
39+
40+
### Local virtual environment
41+
2442
```
2543
make build
2644
```

book/introduction.md

Lines changed: 65 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,49 +25,52 @@ Instead, let's move to looking at the `pyhf` API right away.
2525

2626
::::{tab-set}
2727

28-
:::{tab-item} Locally
28+
:::{tab-item} With pixi
29+
```
30+
$ pixi init
31+
$ pixi shell
32+
```
33+
:::
34+
35+
:::{tab-item} With venv
2936
```
3037
$ python3 -m venv pyhf-tutorial
3138
$ source pyhf-tutorial/bin/activate
32-
(pyhf-tutorial) $ python -m pip install --upgrade pip setuptools wheel
39+
(pyhf-tutorial) $ python -m pip install --upgrade pip
3340
```
3441
:::
3542

36-
:::{tab-item} On CC7 lxplus/tier-3
37-
First we need to set up the 'views' with the right paths to ensure we use the correct `pip`
38-
43+
:::{tab-item} With conda
3944
```
40-
$ export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase
41-
$ source $ATLAS_LOCAL_ROOT_BASE/user/atlasLocalSetup.sh
42-
$ lsetup "views LCG_98python3 x86_64-centos7-gcc8-opt"
43-
$ 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
45+
$ conda create --name pyhf-tutorial --yes 'python=3.12'
46+
$ conda activate pyhf-tutorial
4447
```
48+
:::
4549

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

4853
```
49-
$ python3 -m venv pyhf-tutorial
50-
$ source pyhf-tutorial/bin/activate
51-
(pyhf-tutorial) $ python -m pip install --upgrade pip setuptools wheel
54+
$ export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase
55+
$ . $ATLAS_LOCAL_ROOT_BASE/user/atlasLocalSetup.sh
56+
$ lsetup "views LCG_106 x86_64-el9-gcc13-opt"
5257
```
53-
:::
5458

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

5861
```
59-
$ export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase
60-
$ source $ATLAS_LOCAL_ROOT_BASE/user/atlasLocalSetup.sh
61-
$ lsetup "views LCG_98python3 x86_64-slc6-gcc8-opt"
62-
$ 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
62+
$ mkdir -p ~/.local/bin
63+
$ export PATH=~/.local/bin:"${PATH}"
64+
$ curl -sL https://raw.githubusercontent.com/matthewfeickert/cvmfs-venv/main/cvmfs-venv.sh -o ~/.local/bin/cvmfs-venv
65+
$ chmod +x ~/.local/bin/cvmfs-venv
6366
```
6467

65-
Then we can go ahead and create the virtual environment
68+
and use it to create a user controlled virtual environment
6669

6770
```
68-
$ python3 -m venv pyhf-tutorial
69-
$ source pyhf-tutorial/bin/activate
70-
(pyhf-tutorial) $ python -m pip install --upgrade pip setuptools wheel
71+
$ cvmfs-venv pyhf-tutorial
72+
$ . pyhf-tutorial/bin/activate
73+
(pyhf-tutorial) $ uv pip install --upgrade pip
7174
```
7275
:::
7376

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

8386
::::
8487

85-
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'.
88+
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'.
8689

8790
### Getting pyhf
8891

89-
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`
92+
If you haven't already, make a new Python 3 virtual environment and then install `pyhf`
93+
94+
::::{tab-set}
95+
96+
:::{tab-item} pixi
97+
from [conda-forge](https://anaconda.org/conda-forge/pyhf) with [`pixi`](https://pixi.sh/)
98+
99+
```
100+
$ pixi add pyhf
101+
```
102+
:::
103+
104+
:::{tab-item} pip
105+
from [PyPI](https://pypi.org/project/pyhf/) with `pip`
90106

91107
```
92108
(pyhf-tutorial) $ python -m pip install pyhf
93109
```
110+
:::
94111

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

97115
```
98116
(pyhf-tutorial) $ conda install --channel conda-forge pyhf
99117
```
118+
:::
119+
120+
::::
100121

101122
### Installation Extras
102123

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

144-
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)
165+
#### Using `pixi`
166+
167+
then simply run
168+
169+
```
170+
pixi install
171+
```
172+
173+
or to also start running the example notebooks run
174+
175+
```
176+
pixi run start
177+
```
178+
179+
#### Using `pip`
180+
181+
then install from the included `requirements.txt` in the top level `binder/` directory of [the source repository](https://github.com/pyhf/pyhf-tutorial)
145182

146183
```
147184
(pyhf-tutorial) $ python -m pip install --upgrade --requirement binder/requirements.txt

0 commit comments

Comments
 (0)