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

fix conan source with python_requires in remotes #14852

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: 3 additions & 2 deletions conan/api/subapi/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,13 @@ def editable_list(self):
app = ConanApp(self._conan_api.cache_folder)
return app.cache.editable_packages.edited_refs

def source(self, path, name=None, version=None, user=None, channel=None):
def source(self, path, name=None, version=None, user=None, channel=None, remotes=None):
""" calls the 'source()' method of the current (user folder) conanfile.py
"""
app = ConanApp(self._conan_api.cache_folder)
conanfile = app.loader.load_consumer(path, name=name, version=version,
user=user, channel=channel, graph_lock=None)
user=user, channel=channel, graph_lock=None,
remotes=remotes)
# This profile is empty, but with the conf from global.conf
profile = self._conan_api.profiles.get_profile([])
initialize_conanfile_profile(conanfile, profile, profile, CONTEXT_HOST, False)
Expand Down
3 changes: 2 additions & 1 deletion conan/cli/commands/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def source(conan_api, parser, *args):

cwd = os.getcwd()
path = conan_api.local.get_conanfile_path(args.path, cwd, py=True)
enabled_remotes = conan_api.remotes.list() # for python_requires not local
# TODO: Missing lockfile for python_requires
conan_api.local.source(path, name=args.name, version=args.version, user=args.user,
channel=args.channel)
channel=args.channel, remotes=enabled_remotes)
13 changes: 13 additions & 0 deletions conans/test/integration/command/source_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,16 @@ def source(self):
client.run("source .")
assert "conanfile.py: Calling source()" in client.out
assert "CACHE:MYCACHE!!" in client.out


def test_source_python_requires():
c = TestClient(default_server_user=True)
c.save({"conanfile.py": GenConanfile("pytool", "0.1")})
c.run("export . ")
c.run("upload * -r=default -c")
c.run("remove * -c")

c.save({"conanfile.py": GenConanfile().with_python_requires("pytool/0.1")}, clean_first=True)
c.run("source . ")
assert "pytool/0.1: Not found in local cache, looking in remotes" in c.out
memsharded marked this conversation as resolved.
Show resolved Hide resolved
assert "pytool/0.1: Downloaded recipe" in c.out