Skip to content

Commit 2adc598

Browse files
Merge pull request #1 from szymonlopaciuk/update-for-slicing-and-notes
Update for slicing and add some notes
2 parents a51f9bf + 89f7896 commit 2adc598

File tree

5 files changed

+87
-7
lines changed

5 files changed

+87
-7
lines changed

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,41 @@
11
# xsuite-kernels
2+
3+
## Simple installation
4+
5+
The package can be installed with `pip install xsuite-kernels`. Since it is
6+
dependent on particular versions of the Xsuite packages, installing it might
7+
automatically update your Xsuite packages to newer versions. You can use the
8+
`-U` option to upgrade all packages to the latest versions.
9+
10+
This package provides a set of precompiled kernels for the Xsuite packages, so
11+
that commonly used tracking scenarios can be run without the need to compile
12+
the kernels on the target machine. The precompiled kernels are distributed as
13+
binary Python wheels of the package `xsuite-kernels` on PyPI.
14+
15+
When the package is installed on a supported machine `pip` will automatically
16+
download the appropriate kernel files and install them in the correct location,
17+
so that Xtrack can use them. If `xsuite-kernels` is not installed, Xtrack will
18+
fall back to the default behaviour of compiling the kernels on the fly.
19+
20+
If the package is installed from source (e.g. by cloning the repository or
21+
downloading the source distribution in case of an unsupported platform), the
22+
kernels will be compiled automatically during the installation process
23+
(see `setup.py`).
24+
25+
## Developer notes
26+
27+
In case of a source installation, the building process can be skipped by setting
28+
an environment variable `SKIP_KERNEL_BUILD` to `1` before running `pip install`.
29+
30+
If your local versions of `xtrack`, `xfields`, etc. have diverged from the
31+
versions specified in `pyproject.toml`, you can install the package with the
32+
`--no-deps` option to avoid upgrading the dependencies.
33+
34+
The package exposes a `xsuite-kernels` command that can be used to manage the
35+
kernels on demand (add `--help` option for more information):
36+
37+
```bash
38+
$ xsuite-kernels regenerate # Regenerate all kernels
39+
$ xsuite-kernels clean # Remove all kernels
40+
$ xsuite-kernels info # Print some useful debug information
41+
```

pyproject.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
requires = [
33
"setuptools>=64",
44
"setuptools-scm[toml]>=8",
5-
"xtrack==0.56.1",
6-
"xfields==0.15.0",
5+
"xtrack==0.57.0",
6+
"xfields==0.15.1",
77
"xcoll==0.3.5",
8-
"xobjects==0.3.1",
8+
"xobjects==0.4.0",
99
]
1010
build-backend = "setuptools.build_meta"
1111

@@ -19,10 +19,10 @@ readme = "README.md"
1919
requires-python = ">=3.8"
2020
license = {file = "LICENSE"}
2121
dependencies = [
22-
"xtrack==0.56.1",
23-
"xfields==0.15.0",
22+
"xtrack==0.57.0",
23+
"xfields==0.15.1",
2424
"xcoll==0.3.5",
25-
"xobjects==0.3.1",
25+
"xobjects==0.4.0",
2626
]
2727
dynamic = ["version"]
2828

update_versions.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#! /bin/bash
2+
# copyright ############################### #
3+
# This file is part of the Xsuite project. #
4+
# Copyright (c) CERN, 2024. #
5+
# ######################################### #
6+
7+
set -e
8+
9+
get_latest_version () {
10+
pip index versions "$1" \
11+
| grep 'LATEST' \
12+
| sed -E -e 's/[ ]*LATEST:[ ]*([0-9.]+)/\1/g'
13+
}
14+
15+
update_version () {
16+
local package=$1
17+
local version=$2
18+
sed -i '' -E -e "s/$package==[0-9.]+/$package==$version/g" "pyproject.toml"
19+
}
20+
21+
for package in xtrack xfields xcoll xobjects; do
22+
latest_version=$(get_latest_version $package)
23+
update_version $package $latest_version
24+
done

xsuite_kernels/kernel_definitions.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,22 @@
4949
LineSegmentMap,
5050
FirstOrderTaylorMap,
5151
NonLinearLens,
52+
# Slices
53+
DriftSlice,
54+
DriftSliceBend,
55+
DriftSliceOctupole,
56+
DriftSliceQuadrupole,
57+
DriftSliceSextupole,
58+
ThickSliceBend,
59+
ThickSliceOctupole,
60+
ThickSliceQuadrupole,
61+
ThickSliceSextupole,
62+
ThinSliceBend,
63+
ThinSliceBendEntry,
64+
ThinSliceBendExit,
65+
ThinSliceOctupole,
66+
ThinSliceQuadrupole,
67+
ThinSliceSextupole,
5268
# Transformations
5369
XYShift,
5470
ZetaShift,

xsuite_kernels/prebuild_kernels.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def regenerate_kernels(kernels=None, location=XSK_PREBUILT_KERNELS_LOCATION):
302302
elements.append(element)
303303

304304
line = xt.Line(elements=elements)
305-
tracker = xt.Tracker(line=line, compile=False)
305+
tracker = xt.Tracker(line=line, compile=False, _prebuilding_kernels=True)
306306
tracker.config.clear()
307307
tracker.config.update(config)
308308

0 commit comments

Comments
 (0)