Skip to content

Commit e0b5e33

Browse files
authored
fix: conda_install issue with newer conda (#957)
* tests: conda tests check < char Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * tests: add symbol to conda install Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * fix: drop extra double quoting Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * fix: conda_install extra quotes Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * fix: needed only on Windows Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * tests: skip check on Windows Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> --------- Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
1 parent a58fe60 commit e0b5e33

5 files changed

Lines changed: 30 additions & 11 deletions

File tree

.github/workflows/ci.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ jobs:
2424
os: [ubuntu-22.04, windows-latest, macos-13]
2525
python-version:
2626
- "3.8"
27-
- "3.9"
2827
- "3.10"
29-
- "3.11"
3028
- "3.12"
3129
- "3.13"
3230
include:
31+
- os: ubuntu-24.04
32+
python-version: "3.9"
33+
- os: ubuntu-24.04
34+
python-version: "3.11"
3335
- os: macos-14
3436
python-version: "3.12"
3537
steps:
@@ -60,6 +62,10 @@ jobs:
6062
run: uv pip install --system .
6163
- name: Run tests on ${{ matrix.os }}
6264
run: nox --non-interactive --error-on-missing-interpreter --session "tests-${{ matrix.python-version }}" -- --full-trace
65+
66+
- name: Run Conda tests
67+
if: matrix.python-version == '3.12'
68+
run: nox --non-interactive --error-on-missing-interpreter --session "conda_tests" -- --full-trace
6369
- name: Save coverage report
6470
uses: actions/upload-artifact@v4
6571
with:

nox/sessions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,8 @@ def conda_install(
724724
return
725725

726726
# Escape args that should be (conda-specific; pip install does not need this)
727-
args = _dblquote_pkg_install_args(args)
727+
if sys.platform.startswith("win32"):
728+
args = _dblquote_pkg_install_args(args)
728729

729730
if silent is None:
730731
silent = True

noxfile.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ def conda_tests(session: nox.Session) -> None:
7474
"--file", "requirements-conda-test.txt", channel="conda-forge"
7575
)
7676
session.install("-e.", "--no-deps")
77+
# Currently, this doesn't work on Windows either with or without quoting
78+
if not sys.platform.startswith("win32"):
79+
session.conda_install("requests<99")
7780
session.run("pytest", *session.posargs)
7881

7982

@@ -84,6 +87,8 @@ def mamba_tests(session: nox.Session) -> None:
8487
"--file", "requirements-conda-test.txt", channel="conda-forge"
8588
)
8689
session.install("-e.", "--no-deps")
90+
if not sys.platform.startswith("win32"):
91+
session.conda_install("requests<99")
8792
session.run("pytest", *session.posargs)
8893

8994

@@ -93,7 +98,10 @@ def micromamba_tests(session: nox.Session) -> None:
9398
session.conda_install(
9499
"--file", "requirements-conda-test.txt", channel="conda-forge"
95100
)
101+
# Currently, this doesn't work on Windows either with or without quoting
96102
session.install("-e.", "--no-deps")
103+
if not sys.platform.startswith("win32"):
104+
session.conda_install("requests<99")
97105
session.run("pytest", *session.posargs)
98106

99107

tests/test_sessions.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ def test_conda_install_bad_args(self) -> None:
581581
with pytest.raises(ValueError, match="arg"):
582582
session.conda_install()
583583

584+
@pytest.mark.skipif(not sys.platform.startswith("win32"), reason="Only on Windows")
584585
def test_conda_install_bad_args_odd_nb_double_quotes(self) -> None:
585586
session, runner = self.make_session_and_runner()
586587
runner.venv = mock.create_autospec(nox.virtualenv.CondaEnv)
@@ -590,6 +591,7 @@ def test_conda_install_bad_args_odd_nb_double_quotes(self) -> None:
590591
with pytest.raises(ValueError, match="odd number of quotes"):
591592
session.conda_install('a"a')
592593

594+
@pytest.mark.skipif(not sys.platform.startswith("win32"), reason="Only on Windows")
593595
def test_conda_install_bad_args_cannot_escape(self) -> None:
594596
session, runner = self.make_session_and_runner()
595597
runner.venv = mock.create_autospec(nox.virtualenv.CondaEnv)
@@ -646,7 +648,7 @@ class SessionNoSlots(nox.sessions.Session):
646648
else:
647649
args += [f"--channel={c}" for c in channel]
648650
session.conda_install(
649-
"requests", "urllib3", auto_offline=auto_offline, channel=channel
651+
"requests<99", "urllib3", auto_offline=auto_offline, channel=channel
650652
)
651653
run.assert_called_once_with(
652654
conda,
@@ -655,7 +657,7 @@ class SessionNoSlots(nox.sessions.Session):
655657
*args,
656658
"--prefix",
657659
"/path/to/conda/env",
658-
"requests",
660+
'"requests<99"' if sys.platform.startswith("win32") else "requests<99",
659661
"urllib3",
660662
**_run_with_defaults(silent=True, external="error"),
661663
)
@@ -716,7 +718,9 @@ class SessionNoSlots(nox.sessions.Session):
716718

717719
if version_constraint == "no":
718720
pkg_requirement = passed_arg = "urllib3"
719-
elif version_constraint == "yes":
721+
elif version_constraint == "yes" and not sys.platform.startswith("win32"):
722+
pkg_requirement = passed_arg = "urllib3<1.25"
723+
elif version_constraint == "yes" and sys.platform.startswith("win32"):
720724
pkg_requirement = "urllib3<1.25"
721725
passed_arg = f'"{pkg_requirement}"'
722726
elif version_constraint == "already_dbl_quoted":

tests/test_virtualenv.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,16 +218,16 @@ def test_condaenv_create_with_params(
218218
def test_condaenv_create_interpreter(
219219
make_conda: Callable[..., tuple[CondaEnv, Path]],
220220
) -> None:
221-
venv, dir_ = make_conda(interpreter="3.8")
221+
venv, dir_ = make_conda(interpreter="3.12")
222222
venv.create()
223223
if IS_WINDOWS:
224224
assert dir_.joinpath("python.exe").exists()
225-
assert dir_.joinpath("python38.dll").exists()
226-
assert dir_.joinpath("python38.pdb").exists()
227-
assert not dir_.joinpath("python38.exe").exists()
225+
assert dir_.joinpath("python312.dll").exists()
226+
assert dir_.joinpath("python312.pdb").exists()
227+
assert not dir_.joinpath("python312.exe").exists()
228228
else:
229229
assert dir_.joinpath("bin", "python").exists()
230-
assert dir_.joinpath("bin", "python3.8").exists()
230+
assert dir_.joinpath("bin", "python3.12").exists()
231231

232232

233233
@has_conda

0 commit comments

Comments
 (0)