From 412c0d8be50a6a12ba2729891e322b0253849b74 Mon Sep 17 00:00:00 2001 From: Robert Rosca <32569096+RobertRosca@users.noreply.github.com> Date: Tue, 24 Oct 2023 10:15:21 +0200 Subject: [PATCH 1/4] add 'no-pip-install' recipe --- .../recipes/no-pip-install/EXTERNALLY-MANAGED | 3 ++ .../recipes/no-pip-install/README.md | 5 ++++ .../recipes/no-pip-install/recipe.yaml | 28 +++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 custom-recipes/recipes/no-pip-install/EXTERNALLY-MANAGED create mode 100644 custom-recipes/recipes/no-pip-install/README.md create mode 100644 custom-recipes/recipes/no-pip-install/recipe.yaml 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..28c982cc --- /dev/null +++ b/custom-recipes/recipes/no-pip-install/EXTERNALLY-MANAGED @@ -0,0 +1,3 @@ +[externally-managed] +Error=This is a pure conda environment, packages should not be installed into + it directly via pip. 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..96dc97ea --- /dev/null +++ b/custom-recipes/recipes/no-pip-install/recipe.yaml @@ -0,0 +1,28 @@ +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 + +about: + license: GPL-3.0 + +extra: + recipe-maintainers: + - RobertRosca + From 2e329b34e5e4a5643ec4f2ce56b204ce8a54577b Mon Sep 17 00:00:00 2001 From: Robert Rosca <32569096+RobertRosca@users.noreply.github.com> Date: Wed, 25 Oct 2023 13:24:35 +0200 Subject: [PATCH 2/4] add tests for 'no-pip-install' --- custom-recipes/recipes/no-pip-install/recipe.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/custom-recipes/recipes/no-pip-install/recipe.yaml b/custom-recipes/recipes/no-pip-install/recipe.yaml index 96dc97ea..d3c6b62f 100644 --- a/custom-recipes/recipes/no-pip-install/recipe.yaml +++ b/custom-recipes/recipes/no-pip-install/recipe.yaml @@ -19,6 +19,10 @@ requirements: - python >=3 - pip >=23.0 +test: + commands: + - cat $STDLIB_DIR/EXTERNALLY-MANAGED + about: license: GPL-3.0 From f5c3475402c0315599af1b3ba2610043194fe9c8 Mon Sep 17 00:00:00 2001 From: Robert Rosca <32569096+RobertRosca@users.noreply.github.com> Date: Wed, 25 Oct 2023 13:39:21 +0200 Subject: [PATCH 3/4] add warning to maintenance docs about 'no-pip-install' --- docs/maintenance/environments.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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. From b9ba455b77023e5734fbf1418226376ff095254b Mon Sep 17 00:00:00 2001 From: Robert Rosca <32569096+RobertRosca@users.noreply.github.com> Date: Wed, 25 Oct 2023 13:46:43 +0200 Subject: [PATCH 4/4] add links to docs in externally managed error' --- .../recipes/no-pip-install/EXTERNALLY-MANAGED | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/custom-recipes/recipes/no-pip-install/EXTERNALLY-MANAGED b/custom-recipes/recipes/no-pip-install/EXTERNALLY-MANAGED index 28c982cc..638e9d97 100644 --- a/custom-recipes/recipes/no-pip-install/EXTERNALLY-MANAGED +++ b/custom-recipes/recipes/no-pip-install/EXTERNALLY-MANAGED @@ -1,3 +1,9 @@ [externally-managed] -Error=This is a pure conda environment, packages should not be installed into - it directly via pip. +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/