From cdc777cd1e4ad711186032ae165747aaf556d351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20=C5=81opaciuk?= Date: Fri, 2 Dec 2022 14:50:50 +0100 Subject: [PATCH] add a command line script `xsuite-prebuild` to precompile trackers --- docs/installation.rst | 8 ++++++++ setup.py | 17 ++++++++++------- xsuite/cli.py | 10 ++++++++++ 3 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 xsuite/cli.py diff --git a/docs/installation.rst b/docs/installation.rst index 1f2b1ca6..0f048e10 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -20,6 +20,14 @@ The Xsuite packages can be installed using pip: This installation allows using Xsuite on CPU. To use Xsuite on GPU, with the cupy and/or pyopencl you need to install the corresponding packages, as described in the :ref:`dedicated section`. +After the installation, you can choose to precompile some often-used kernels, in +order to reduce the waiting time spent on running the simulations later on. This +can be accomplished simply by running the following command: + +.. code-block:: bash + + xsuite-precompile + Developer installation ====================== diff --git a/setup.py b/setup.py index b82877a5..4a95e7e4 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -from setuptools import setup, find_packages, Extension +from setuptools import setup, find_packages from pathlib import Path ####################################### @@ -33,13 +33,16 @@ 'xfields', 'xpart', 'xdeps' - ], + ], url='https://xsuite.readthedocs.io/', license='Apache 2.0', download_url="https://pypi.python.org/pypi/xsuite", project_urls={ - "Bug Tracker": "https://github.com/xsuite/xsuite/issues", - "Documentation": 'https://xsuite.readthedocs.io/', - "Source Code": "https://github.com/xsuite/xsuite", - }, - ) + "Bug Tracker": "https://github.com/xsuite/xsuite/issues", + "Documentation": 'https://xsuite.readthedocs.io/', + "Source Code": "https://github.com/xsuite/xsuite", + }, + entry_points={ + 'console_scripts': ['xsuite-prebuild=xsuite.cli:main'], + }, +) diff --git a/xsuite/cli.py b/xsuite/cli.py new file mode 100644 index 00000000..340acc8a --- /dev/null +++ b/xsuite/cli.py @@ -0,0 +1,10 @@ +# copyright ################################# # +# This file is part of the Xobjects Package. # +# Copyright (c) CERN, 2022. # +# ########################################### # +from xtrack.prebuild_kernels import regenerate_kernels + + +def main(): + regenerate_kernels() + print('Successfully compiled kernels.')