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 'export-pkg' for 'python-require' #14819

Merged
merged 1 commit into from
Sep 26, 2023
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
7 changes: 5 additions & 2 deletions conan/cli/commands/export_pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from conan.cli.commands.create import _get_test_conanfile_path
from conan.cli.formatters.graph import format_graph_json
from conan.cli.printers.graph import print_graph_basic
from conans.errors import ConanException


@conan_command(group="Creator", formatters={"json": format_graph_json})
Expand Down Expand Up @@ -45,11 +46,13 @@ def export_pkg(conan_api, parser, *args):
profile_host, profile_build = conan_api.profiles.get_profiles_from_args(args)
remotes = conan_api.remotes.list(args.remote) if not args.no_remote else []

conanfile = conan_api.local.inspect(path, remotes, lockfile)
# The package_type is not fully processed at export
if conanfile.package_type == "python-require":
raise ConanException("export-pkg can only be used for binaries, not for 'python-require'")
ref, conanfile = conan_api.export.export(path=path, name=args.name, version=args.version,
user=args.user, channel=args.channel, lockfile=lockfile,
remotes=remotes)
# The package_type is not fully processed at export
assert conanfile.package_type != "python-require", "A python-require cannot be export-pkg"
lockfile = conan_api.lockfile.update_lockfile_export(lockfile, conanfile, ref,
args.build_require)

Expand Down
11 changes: 11 additions & 0 deletions conans/test/integration/py_requires/python_requires_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1199,3 +1199,14 @@ def test_transitive_range_not_found_in_cache():
c.run("create . ")
c.assert_listed_require({"pr/1.0": "Cache"}, python=True)
assert "pr/[>0]: pr/1.0" in c.out


def test_export_pkg():
c = TestClient()
c.save({"conanfile.py": GenConanfile("pytool", "0.1").with_package_type("python-require")})
c.run("export-pkg .", assert_error=True)
assert "export-pkg can only be used for binaries, not for 'python-require'" in c.out
# Make sure nothing is exported
c.run("list *")
assert "WARN: There are no matching recipe references" in c.out
assert "pytool/0.1" not in c.out