Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add 'no-pip-install' recipe #19

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions custom-recipes/recipes/no-pip-install/EXTERNALLY-MANAGED
Original file line number Diff line number Diff line change
@@ -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/
5 changes: 5 additions & 0 deletions custom-recipes/recipes/no-pip-install/README.md
Original file line number Diff line number Diff line change
@@ -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.
32 changes: 32 additions & 0 deletions custom-recipes/recipes/no-pip-install/recipe.yaml
Original file line number Diff line number Diff line change
@@ -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

10 changes: 9 additions & 1 deletion docs/maintenance/environments.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down