tox-dev / tox-conda

Make tox cooperate with conda envs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ambiguous Python version

chuber1986 opened this issue · comments

When the environment.yaml specifies a Python version that contradicts with the Python version of the new tox test envronment, the environment creation fails. The error does not occur when the conda environment doesn't specify a version.

E.g. environment.yaml:

name: python-boilerplate
channels:
  - conda-forge
  - nodefaults
dependencies:
  - python==3.10

tox.ini:

[tox]
envlist = py39, py310
skipsdist = false
requires = tox-conda


[testenv]
setenv =
    PYTHONPATH = {toxinidir}
    PYTHONWARNINGS = ignore

conda_env = {toxinidir}/environment.yaml

commands =
    pytest --cov=python_boilerplate --cov-branch --cov-report=xml --cov-report=term-missing tests

tox output:

GLOB sdist-make: <path>/python-boilerplate/setup.py
py39 create: <path>/python-boilerplate/.tox/py39
ERROR: invocation failed (exit code 1), logfile: <path>/python-boilerplate/.tox/py39/log/py39-0.log
=============================================================================== log start ===============================================================================
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... failed

ResolvePackageNotFound: 
  - python[version='3.10,3.9.*']


================================================================================ log end ================================================================================
ERROR: InvocationError for command /opt/anaconda3/bin/conda env create -p py39 --file <path>/python-boilerplate/tox_conda_tmp_o962u00.yaml (exited with code 1)

This is the expected behavior since version 0.10.0, from the readme:

If the conda-env.yml specifies a python version it must be compatible with the basepython set for the tox env. A conda-env.yml specifying python>=3.8 could for example be used with basepython set to py38, py39 or py310. The above conda_deps, conda_channels, and conda_spec arguments, if used in conjunction with a conda-env.yml file, will be used to update the environment after the initial environment creation.

I see. Thanks for the fast response!
Sorry for bothering.