Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isolated_build does not work with tox-conda #45

Closed
Choc13 opened this issue May 15, 2020 · 6 comments
Closed

isolated_build does not work with tox-conda #45

Choc13 opened this issue May 15, 2020 · 6 comments

Comments

@Choc13
Copy link

Choc13 commented May 15, 2020

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

@jondye
Copy link

jondye commented Nov 12, 2020

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.

@jondye
Copy link

jondye commented Nov 12, 2020

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

@AntoineD
Copy link
Collaborator

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

@Choc13
Copy link
Author

Choc13 commented May 25, 2021

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?

@AntoineD
Copy link
Collaborator

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

@AntoineD
Copy link
Collaborator

No update from author: closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants