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 local flow with python requires #4983

Closed
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
10 changes: 10 additions & 0 deletions conans/client/conan_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,8 @@ def export_pkg(self, conanfile_path, name, channel, source_folder=None, build_fo
package_folder=None, install_folder=None, profile_names=None, settings=None,
options=None, env=None, force=False, user=None, version=None, cwd=None):

remotes = self._cache.registry.load_remotes()
self.python_requires.enable_remotes(remotes=remotes)
settings = settings or []
options = options or []
env = env or []
Expand Down Expand Up @@ -675,6 +677,8 @@ def build(self, conanfile_path, source_folder=None, package_folder=None, build_f
install_folder=None, should_configure=True, should_build=True, should_install=True,
should_test=True, cwd=None):

remotes = self._cache.registry.load_remotes()
self.python_requires.enable_remotes(remotes=remotes)
cwd = cwd or get_cwd()
conanfile_path = _get_conanfile_path(conanfile_path, cwd, py=True)
build_folder = _make_abs_path(build_folder, cwd)
Expand All @@ -691,6 +695,9 @@ def build(self, conanfile_path, source_folder=None, package_folder=None, build_f
@api_method
def package(self, path, build_folder, package_folder, source_folder=None, install_folder=None,
cwd=None):
remotes = self._cache.registry.load_remotes()
self.python_requires.enable_remotes(remotes=remotes)

cwd = cwd or get_cwd()
conanfile_path = _get_conanfile_path(path, cwd, py=True)
build_folder = _make_abs_path(build_folder, cwd)
Expand All @@ -711,6 +718,9 @@ def package(self, path, build_folder, package_folder, source_folder=None, instal

@api_method
def source(self, path, source_folder=None, info_folder=None, cwd=None):
remotes = self._cache.registry.load_remotes()
self.python_requires.enable_remotes(remotes=remotes)

cwd = cwd or get_cwd()
conanfile_path = _get_conanfile_path(path, cwd, py=True)
source_folder = _make_abs_path(source_folder, cwd)
Expand Down
26 changes: 26 additions & 0 deletions conans/test/functional/python_requires/python_requires_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from conans.paths import CONANFILE
from conans.test.utils.tools import TestClient, TestServer, \
NO_SETTINGS_PACKAGE_ID, create_local_git_repo
from conans.test.utils.conanfile import TestConanFile


class PythonExtendTest(unittest.TestCase):
Expand Down Expand Up @@ -605,3 +606,28 @@ def build(self):
# - no mention to alias
self.assertNotIn("alias", client.out)
self.assertNotIn("alias2", client.out)

def local_build_test(self):
client = TestClient()
client.save({"conanfile.py": "var=42\n"+str(TestConanFile("Tool", "0.1"))})
client.run("export . Tool/0.1@user/channel")

conanfile = """from conans import ConanFile, python_requires
pkg1 = python_requires("Tool/0.1@user/channel")
class MyConanfileBase(ConanFile):
def source(self):
self.output.info("Pkg1 source: %s" % pkg1.var)
def build(self):
self.output.info("Pkg1 build: %s" % pkg1.var)
def package(self):
self.output.info("Pkg1 package: %s" % pkg1.var)
"""
client.save({"conanfile.py": conanfile})
client.run("source .")
self.assertIn("conanfile.py: Pkg1 source: 42", client.out)
client.run("install .")
client.run("build .")
self.assertIn("conanfile.py: Pkg1 build: 42", client.out)
client.run("package .")
self.assertIn("conanfile.py: Pkg1 package: 42", client.out)
client.run("export-pkg . pkg1/0.1@user/testing")