-
Notifications
You must be signed in to change notification settings - Fork 993
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
[bug] conan test
doesn't work with python_requires packages
#15484
Comments
Additionally, if I modify the diff --git a/test_package/conanfile.py b/test_package/conanfile.py
index c4cc2cc..4f6092b 100644
--- a/test_package/conanfile.py
+++ b/test_package/conanfile.py
@@ -7,6 +7,7 @@ class PyvenvTestConan(ConanFile):
settings = "os", "build_type", "arch", "compiler"
apply_env = False
test_type = "explicit"
+ python_requires = ConanFile.tested_reference_str
def config_options(self):
del self.settings.build_type This gives the following error: $ conan test test_package funcs/0.1.0@user
======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=clang
compiler.cppstd=20
compiler.libcxx=libstdc++11
compiler.version=16
os=Linux
[conf]
tools.build:compiler_executables={'c': '/usr/bin/clang', 'cpp': '/usr/bin/clang++'}
Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=clang
compiler.cppstd=20
compiler.libcxx=libstdc++11
compiler.version=16
os=Linux
[conf]
tools.build:compiler_executables={'c': '/usr/bin/clang', 'cpp': '/usr/bin/clang++'}
======== Launching test_package ========
======== Computing dependency graph ========
ERROR: Traceback (most recent call last):
File "/home/user/.local/pipx/venvs/conan/lib/python3.11/site-packages/conan/cli/cli.py", line 272, in main
cli.run(args)
File "/home/user/.local/pipx/venvs/conan/lib/python3.11/site-packages/conan/cli/cli.py", line 172, in run
command.run(self._conan_api, args[0][1:])
File "/home/user/.local/pipx/venvs/conan/lib/python3.11/site-packages/conan/cli/command.py", line 125, in run
info = self._method(conan_api, parser, *args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/pipx/venvs/conan/lib/python3.11/site-packages/conan/cli/commands/test.py", line 40, in test
deps_graph = run_test(conan_api, path, ref, profile_host, profile_build, remotes, lockfile,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/pipx/venvs/conan/lib/python3.11/site-packages/conan/cli/commands/test.py", line 67, in run_test
print_graph_basic(deps_graph)
File "/home/user/.local/pipx/venvs/conan/lib/python3.11/site-packages/conan/cli/printers/graph.py", line 20, in print_graph_basic
for r in node.conanfile.python_requires._pyrequires.values(): # TODO: improve interface
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute '_pyrequires'
ERROR: 'NoneType' object has no attribute '_pyrequires'
|
using diff --git a/test_package/conanfile.py b/test_package/conanfile.py
index c4cc2cc..640bf0b 100644
--- a/test_package/conanfile.py
+++ b/test_package/conanfile.py
@@ -7,6 +7,7 @@ class PyvenvTestConan(ConanFile):
settings = "os", "build_type", "arch", "compiler"
apply_env = False
test_type = "explicit"
+ python_requires = self.tested_reference_str
def config_options(self):
del self.settings.build_type Does not work with $ conan test test_package funcs/0.1.0@user
======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=clang
compiler.cppstd=20
compiler.libcxx=libstdc++11
compiler.version=16
os=Linux
[conf]
tools.build:compiler_executables={'c': '/usr/bin/clang', 'cpp': '/usr/bin/clang++'}
Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=clang
compiler.cppstd=20
compiler.libcxx=libstdc++11
compiler.version=16
os=Linux
[conf]
tools.build:compiler_executables={'c': '/usr/bin/clang', 'cpp': '/usr/bin/clang++'}
ERROR: Error loading conanfile at '/tmp/pyrequires/test_package/conanfile.py': Unable to load conanfile in /tmp/pyrequires/test_package/conanfile.py
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/tmp/pyrequires/test_package/conanfile.py", line 6, in <module>
class PyvenvTestConan(ConanFile):
File "/tmp/pyrequires/test_package/conanfile.py", line 10, in PyvenvTestConan
python_requires = self.tested_reference_str
^^^^
NameError: name 'self' is not defined
|
Thanks for the report. The |
Thanks @memsharded. Would it be feasible to just avoid raising when there are no
|
But hardcoding the |
Proposing #15485, seems explicit better than implicit, but can't guarantee, we need to make sure we don't break |
Yes, agree. As someone who doesn't look at the mechanics of how this works super frequently, being explicit is better to immediately understand it. After not looking at my python requires recipes for a few months, it took me some time to realise that I didn't need to specify the |
Fixed in #15485 for next 2.1 |
Environment details
Steps to reproduce
Using the following files:
conanfile.py
test_package/conanfile.py
conan create . --user user
- this will work correctlyconan test test_package funcs/0.1.0@user
, the below error message will be thrown.Logs
The text was updated successfully, but these errors were encountered: