tox-dev / tox-conda

Make tox cooperate with conda envs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

isolated_build does not work with tox-conda

Choc13 opened this issue · comments

I'm having some issues getting isolated builds to work in tox when using tox-conda. Specifically, I have the following setup.cfg:

[tox:tox]
isolated_build = True
requires = tox-conda

[testenv:.package]
basepython = python3.6

[testenv:foo]
commands =
    python --version

And I have a pyproject.toml such as:

[build-system]
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]

Running tox -e foo from a conda environment containing tox produces the following error:

ERROR: FAIL could not package project - v = InvocationError("'J:\\imr\\tox-conda-bug\\.tox\\.package\\Scripts\\python' '.tox\\.tox\\Lib\\site-packages\\tox\\helper\\build_requires.py' setuptools.build_meta ''", 2)

It seems to me that there is no script named python in the Scripts folder when using tox-conda. However, when I remove tox-conda the isolated build works fine and I see a python file in the Scripts folder of the pip virtual env. The screenshot below shows the contents of .tox\.package\Scripts when using tox-conda:

image

The full contents of the most recent log file, specifically .tox/package/log/.package-2.log look like:

action: .package, msg: get-build-requires
cwd: J:\imr\tox-conda-bug
cmd: 'J:\imr\tox-conda-bug\.tox\.package\Scripts\python' '.tox\.tox\Lib\site-packages\tox\helper\build_requires.py' setuptools.build_meta ''

Additional Details:

OS: Windows 10
conda: 4.7.11
tox: 3.15.0

I have the same issue.

I've got as far as understanding that inside the tox package in tox/package/builder/isolated.py in get_build_requires it tries to run the build_require script (BUILD_REQUIRE_SCRIPT) using the path in package_venv.envconfig.envpython. in config/__init__.py the envpython property calls get_envpython which appends "python" to envbindir (i.e. the scripts directory). Something here seems like it needs patching by tox-conda but I can't understand what's going on enough to propose a fix.

Something like this perhaps:

diff --git a/tox_conda/plugin.py b/tox_conda/plugin.py
index f1aa6e9..8c32da3 100644
--- a/tox_conda/plugin.py
+++ b/tox_conda/plugin.py
@@ -57,6 +57,16 @@ def tox_configure(config):
         conda_deps = [DepConfig(str(name)) for name in envconfig.conda_deps]
         envconfig.deps.extend(conda_deps)

+        def get_envpython(self=envconfig):
+            """ path to python/jython executable. """
+            if "jython" in str(self.basepython):
+                name = "jython"
+            else:
+                name = "python"
+            return self.envdir.join(name)
+
+        envconfig.get_envpython = get_envpython
+

 def find_conda(action):
     # This should work if we're not already in an environment

Could you try with a recent version of tox and tox-conda?

I've moved on from the project that was using tox-conda now and no longer use Python in my day job so I'm not really in a position to test this. Maybe @jondye could though?

@jondye 0.8.1 has a fix for isolated build, you may give it a try.

No update from author: closing.