Skip to content

Commit

Permalink
support for python_requires in local-recipes-index (#16420)
Browse files Browse the repository at this point in the history
* support for python_requires in local-recipes-index

* wip
  • Loading branch information
memsharded authored Jul 24, 2024
1 parent a55d94e commit 66a3a01
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
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):
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

0 comments on commit 66a3a01

Please sign in to comment.