Skip to content

Commit 6a6dd06

Browse files
author
Sylvain MARIE
committed
Improved ci tools to override versions specifiers correctly
1 parent 8e0ec65 commit 6a6dd06

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

ci_tools/nox_utils.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from pathlib import Path
44
import shutil
55
import os
6+
import re
67

78
from typing import Sequence, Dict, Union
89

@@ -103,7 +104,28 @@ def install_any(session,
103104
# use the provided versions dictionary to update the versions
104105
if versions_dct is None:
105106
versions_dct = dict()
106-
pkgs = [pkg + versions_dct.get(pkg, "") for pkg in pkgs if versions_dct.get(pkg, "") != DONT_INSTALL]
107+
108+
_pkgs = pkgs
109+
pkgs = []
110+
for pkg in _pkgs:
111+
# Find version specifiers if any
112+
try:
113+
separator = next(re.finditer(r"[>=<~!]", pkg)).start()
114+
p_name, p_version = pkg[:separator], pkg[separator:]
115+
except StopIteration:
116+
p_name, p_version = pkg, ""
117+
118+
# Is there something to override them in our versions_dct ?
119+
specifier_override = versions_dct.get(p_name, "")
120+
if specifier_override == DONT_INSTALL:
121+
print(f"NOT INSTALLING {p_name}{p_version} as described in the nox parametrization grid")
122+
continue
123+
if specifier_override:
124+
print(f"OVERRIDING {p_name}{p_version} to {p_name}{specifier_override} as described in the nox parametrization grid")
125+
p_version = specifier_override
126+
127+
# Store the definitive package name and version specifier
128+
pkgs.append(f"{p_name}{p_version}")
107129

108130
nox_logger.debug("\nAbout to install *%s* requirements: %s.\n "
109131
"Conda pkgs are %s" % (phase_name, pkgs, use_conda_for))

0 commit comments

Comments
 (0)