Skip to content

Commit 4e02221

Browse files
authored
Merge branch 'main' into python-3.10.11
2 parents aeaa700 + 9fdd0e3 commit 4e02221

File tree

5 files changed

+38
-8
lines changed

5 files changed

+38
-8
lines changed

build.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"default": "3.9.13"
1111
},
1212
"AIIDA_VERSION": {
13-
"default": "2.6.2"
13+
"default": "2.6.3"
1414
},
1515
"AIIDALAB_VERSION": {
1616
"default": "24.09.0"

bumpver.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpver]
2-
current_version = "v2024.1023"
2+
current_version = "v2024.1024"
33
version_pattern = "vYYYY.BUILD[-TAG]"
44
commit_message = "Bump version {old_version} -> {new_version}."
55
commit = true

stack/base/Dockerfile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,19 @@ RUN cat /opt/requirements.txt | xargs -I{} conda config --system --add pinned_pa
4242

4343
# Configure pip to use the same requirements file as constraints file.
4444
ENV PIP_CONSTRAINT /opt/requirements.txt
45-
# Ensure that pip installs packages to ~/.local by default
46-
COPY pip.conf /etc/pip.conf
45+
# Ensure that pip installs packages to '~/.local/lib/python3.X/site-packages/' by default
46+
# by implicitly passing the '--user' option to 'pip install'
47+
# Otherwise, pip would install into /opt/conda and such packages would be lost
48+
# when the container exits.
49+
# NOTE: We specifically chose the location '/opt/conda/pip.conf'
50+
# which represents the 'site' config file when VIRTUAL_ENV is not set, per:
51+
# https://pip.pypa.io/en/stable/topics/configuration/#configuration-files
52+
# Other locations such as '~/.config/pip/pip.conf' or '/etc/pip.conf' would interfere with virtual environments,
53+
# for example those used by pre-commit.
54+
# We can't use the PIP_USER env variable for the same reason.
55+
# To better understand this, try running `pip config debug` and see
56+
# https://github.com/aiidalab/aiidalab-docker-stack/issues/501
57+
COPY pip.conf "${CONDA_DIR}/pip.conf"
4758

4859
# Upgrade pip and mamba to latest
4960
# Update async_generator, certipy to satisfy `pip check`

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ def pip_install(aiidalab_exec, nb_user):
112112
def _pip_install(pkg, **args):
113113
nonlocal package
114114
package = pkg
115-
return aiidalab_exec(f"pip install {pkg}", **args)
115+
return aiidalab_exec(f"pip install {pkg}", user=nb_user, **args)
116116

117117
yield _pip_install
118118
if package:
119-
aiidalab_exec(f"pip uninstall --yes {package}")
119+
aiidalab_exec(f"pip uninstall --yes {package}", user=nb_user)
120120

121121

122122
@pytest.fixture(scope="session")

tests/test_base.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
"""This module contains tests for the base image, which are AiiDA and package management related tests."""
22

3+
import email
34
import json
45

56
import pytest
67
from packaging.version import parse
78

89

10+
@pytest.fixture
11+
def venv(tmp_path, aiidalab_exec):
12+
venv_path = tmp_path / ".venv"
13+
aiidalab_exec(f"python -m venv {venv_path}")
14+
return venv_path
15+
16+
917
@pytest.mark.parametrize("pkg_manager", ["pip", "mamba"])
1018
def test_prevent_installation_of_aiida(
1119
aiidalab_exec, nb_user, aiida_version, pkg_manager
@@ -76,8 +84,6 @@ def test_path_local_pip(aiidalab_exec, nb_user):
7684

7785
def test_pip_user_install(aiidalab_exec, pip_install, nb_user):
7886
"""Test that pip installs packages to ~/.local/ by default"""
79-
import email
80-
8187
# We use 'tuna' as an example of python-only package without dependencies
8288
pkg = "tuna"
8389
pip_install(pkg)
@@ -86,3 +92,16 @@ def test_pip_user_install(aiidalab_exec, pip_install, nb_user):
8692
# `pip show` output is in the RFC-compliant email header format
8793
msg = email.message_from_string(output)
8894
assert msg.get("Location").startswith(f"/home/{nb_user}/.local/")
95+
96+
97+
def test_pip_install_in_venv(aiidalab_exec, venv, nb_user):
98+
"""Test that pip installs packages to an activated venv"""
99+
100+
pkg = "tuna"
101+
pip = venv / "bin/pip"
102+
103+
aiidalab_exec(f"{pip} install {pkg}")
104+
105+
output = aiidalab_exec(f"{pip} show {pkg}")
106+
msg = email.message_from_string(output)
107+
assert msg.get("Location").startswith(f"{venv}/lib")

0 commit comments

Comments
 (0)