diff --git a/custom-recipes/recipes/no-pip-install/EXTERNALLY-MANAGED b/custom-recipes/recipes/no-pip-install/EXTERNALLY-MANAGED new file mode 100644 index 00000000..638e9d97 --- /dev/null +++ b/custom-recipes/recipes/no-pip-install/EXTERNALLY-MANAGED @@ -0,0 +1,9 @@ +[externally-managed] +Error=This is a pure conda environment, packages should not be installed into it directly via pip. + + If you are a user see this page for more information on using our environments: https://european-xfel.github.io/environments/environments/ + + For DA staff see the environment maintenance documentation: + + - Environment maintenance: https://european-xfel.github.io/environments/maintenance/environments/ + - Recipe creation: https://european-xfel.github.io/environments/maintenance/recipes/ diff --git a/custom-recipes/recipes/no-pip-install/README.md b/custom-recipes/recipes/no-pip-install/README.md new file mode 100644 index 00000000..f630c1a7 --- /dev/null +++ b/custom-recipes/recipes/no-pip-install/README.md @@ -0,0 +1,5 @@ +# No Pip Install + +This 'package' use [PEP 668](https://peps.python.org/pep-0668/) to mark a conda environment it is installed into as 'externally managed', disallowing `pip install` commands from being run in the environment. + +It should be included in our per-cycle conda environments to prevent the environments from becoming difficult to maintain and track due to changes made by pip. diff --git a/custom-recipes/recipes/no-pip-install/recipe.yaml b/custom-recipes/recipes/no-pip-install/recipe.yaml new file mode 100644 index 00000000..d3c6b62f --- /dev/null +++ b/custom-recipes/recipes/no-pip-install/recipe.yaml @@ -0,0 +1,32 @@ +context: + name: no-pip-install + version: 0.1.0 + +package: + name: '{{ name|lower }}' + version: '{{ version }}' + +source: + path: . + +build: + script: "cp ./EXTERNALLY-MANAGED ${SP_DIR}/../." + +requirements: + host: + - python >=3 + run: + - python >=3 + - pip >=23.0 + +test: + commands: + - cat $STDLIB_DIR/EXTERNALLY-MANAGED + +about: + license: GPL-3.0 + +extra: + recipe-maintainers: + - RobertRosca + diff --git a/docs/maintenance/environments.md b/docs/maintenance/environments.md index 591cc89e..6b057279 100644 --- a/docs/maintenance/environments.md +++ b/docs/maintenance/environments.md @@ -8,12 +8,20 @@ Each environment directory will have a few files: - `0-desy-pinned.yml` - environment file with a few packages that we should keep in sync with DESY, e.g. if we have a different version of `ipympl` (interactive plotting backend for matplotlib) to the one in the DESY Conda environment that is running Max-JHub then there may be problems with interactive plotting due to incompatibilities. - `1-base.yml` - Conda environment file containing packages which are available on a Conda channel -- `2-custom.yml` - optional Conda environment file containing packages built from custom recipes (see [Recipes](./recipes.md)) +- `2-custom.yml` - optional Conda environment file containing packages built from custom recipes (see [Custom Recipes](./recipes.md)) - `environment.yml` - file generated by merging the three files from above into one - `environment.lock.yml` - the output of `conda env export`, contains the versions of all packages installed in the environment Environments exist in an installation of Conda, setting up a new Conda installation is very rarely required and is covered in the [Instances](./instances.md) section. +!!! warning + + The cycle environments are **pure conda environments**, you should not run `pip install` commands to add packages to them. Any package added to the per-cycle environments should be a conda package. + + If you need to add a package which is not available on a Conda channel then you should create a recipe for it as described in [Custom Recipes](./recipes.md). + + A special `no-pip-install` package is installed into the cycle environments to prevent direct package installation via pip. + ## Creating a New Specification The first step to creating a new environment is activating an installation, this can be done with `module load exfel mambaforge`. Loading this module will initialise the Conda instance into the `base` environment which provides useful tools for environment management.