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

fixing python_requires remotes commands #5150

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
5 changes: 5 additions & 0 deletions conans/client/conan_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,8 @@ def imports(self, path, dest=None, info_folder=None, cwd=None):
info_folder = _make_abs_path(info_folder, cwd)
dest = _make_abs_path(dest, cwd)

remotes = self._cache.registry.load_remotes()
self.python_requires.enable_remotes(remotes=remotes)
mkdir(dest)
conanfile_abs_path = _get_conanfile_path(path, cwd, py=None)
conanfile = self._graph_manager.load_consumer_conanfile(conanfile_abs_path, info_folder,
Expand Down Expand Up @@ -802,6 +804,7 @@ def copy(self, reference, user_channel, force=False, packages=None):
"""
from conans.client.cmd.copy import cmd_copy
remotes = self._cache.registry.load_remotes()
self.python_requires.enable_remotes(remotes=remotes)
# FIXME: conan copy does not support short-paths in Windows
ref = ConanFileReference.loads(reference)
cmd_copy(ref, user_channel, packages, self._cache,
Expand Down Expand Up @@ -1134,6 +1137,8 @@ def get_package_revisions(self, reference, remote_name=None):

@api_method
def editable_add(self, path, reference, layout, cwd):
remotes = self._cache.registry.load_remotes()
self.python_requires.enable_remotes(remotes=remotes)
# Retrieve conanfile.py from target_path
target_path = _get_conanfile_path(path=path, cwd=cwd, py=True)

Expand Down
23 changes: 23 additions & 0 deletions conans/test/functional/python_requires/python_requires_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,28 @@


class PythonExtendTest(unittest.TestCase):
def test_with_python_requires(self):
# https://github.com/conan-io/conan/issues/5140
client = TestClient()
client.save({"conanfile.py": TestConanFile("dep", "0.1")})
client.run("export . user/testing")
conanfile = textwrap.dedent("""
from conans import ConanFile, python_requires
p = python_requires("dep/0.1@user/testing")
class APck(ConanFile):
pass
""")
client.save({"conanfile.py": conanfile})
client.run('editable add . pkg/0.1@user/testing')
self.assertIn("Reference 'pkg/0.1@user/testing' in editable mode", client.out)
client.run("editable remove pkg/0.1@user/testing")
client.run("create . pkg/0.1@user/testing")
client.run("copy pkg/0.1@user/testing company/stable")
self.assertIn("Copied pkg/0.1@user/testing to pkg/0.1@company/stable", client.out)
# imports should raise either
client.run("install .")
client.run("imports .")

def _define_base(self, client):
conanfile = """from conans import ConanFile
class MyConanfileBase(ConanFile):
Expand Down Expand Up @@ -506,6 +528,7 @@ class Lib(ConanFile):
self.assertIn("Same python_requires with different versions not allowed for a conanfile",
t.out)


class PythonRequiresNestedTest(unittest.TestCase):

@parameterized.expand([(False, False), (True, False), (True, True), ])
Expand Down