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

support for python_requires in local-recipes-index #16420

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions conans/client/rest_client_local_recipe_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,16 @@ def _export_recipe(self, ref):
sys.stderr = StringIO()
try:
global_conf = ConfDefinition()
new_ref, _ = cmd_export(self._app, global_conf, conanfile_path,
ref.name, str(ref.version), None, None)
new_ref, _ = cmd_export(self._app, global_conf, conanfile_path, ref.name,
str(ref.version), None, None, remotes=[self._remote])
except Exception as e:
raise ConanException(f"Error while exporting recipe from remote: {self._remote.name}\n"
f"{str(e)}")
finally:
export_stderr = sys.stderr.getvalue()
export_err = sys.stderr.getvalue()
sys.stderr = original_stderr
ConanOutput().debug(f"Internal export for {ref}:\n"
f"{textwrap.indent(export_stderr, ' ')}")

ConanOutput(scope="local-recipes-index").debug(f"Internal export for {ref}:\n"
f"{textwrap.indent(export_err, ' ')}")
return new_ref

@staticmethod
Expand Down
29 changes: 29 additions & 0 deletions test/integration/remote/test_local_recipes_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,32 @@ class Zlib(ConanFile):
c.run(f"remote add local '{folder}'")
c.run("install --requires=zlib/[*] --build missing", assert_error=True)
assert "NameError: name 'ConanFile' is not defined" in c.out


class TestPythonRequires:
@pytest.fixture(scope="class")
def c3i_pyrequires_folder(self):
folder = temp_folder()
recipes_folder = os.path.join(folder, "recipes")
config = textwrap.dedent("""
versions:
"1.0":
folder: all
""")
pkg = str(GenConanfile("pkg").with_python_requires("pyreq/1.0"))
save_files(recipes_folder,
{"pkg/config.yml": config,
"pkg/all/conanfile.py": pkg,
"pyreq/config.yml": config,
"pyreq/all/conanfile.py": str(GenConanfile("pyreq", "1.0"))})
return folder

def test_install(self, c3i_pyrequires_folder):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's not too much, I'd add a test to explicitly state that a pyreq coming from a different remote is not supported? Or is it enought with the issue message?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to consider the use cases with more detail, this is why this is a draft, lets talk about it.

c = TestClient(light=True)
c.run(f"remote add local '{c3i_pyrequires_folder}'")
c.run("list * -r=local")
assert "pyreq/1.0" in c.out
assert "pkg/1.0" in c.out
c.run("install --requires=pkg/1.0 --build missing -vvv")
assert "pyreq/1.0#a0d63ca853edefa33582a24a1bb3c75f - Downloaded (local)" in c.out
assert "pkg/1.0: Created package" in c.out