-
Notifications
You must be signed in to change notification settings - Fork 1k
Package vendor new feature #16073
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
Merged
Merged
Package vendor new feature #16073
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
65d33d0
wip
memsharded 1cff999
wip
memsharded 8a12d6d
wip
memsharded b3874b7
fix
memsharded 00fccb8
merged develop2
memsharded 94ea8bb
fix test
memsharded 0a44cbe
Updated graph serialization and display for re-package nodes
perseoGI 5df06f0
Merge branch 'develop2' into feature/repackage
perseoGI 0789acf
Fix broken tests
perseoGI 2ed9551
Make graph command check tools.graph:repackage is passed when trying …
perseoGI 8a6e88b
Fix integration test, changed error output
perseoGI 31d9fb0
merged develop2
memsharded 5fad438
renamed to bundle
memsharded feee412
fixes
memsharded 4ff021a
fix test
memsharded 3a76c13
Merge branch 'develop2' into feature/repackage
memsharded 4af765a
rename conf to build_bundle
memsharded f1987ca
renames
memsharded 9926b0b
avoid propagate options
memsharded cdb1245
Update conans/client/graph/graph.py
memsharded e13037c
merged develop2
memsharded File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
import os | ||
import textwrap | ||
|
||
from conan.test.assets.genconanfile import GenConanfile | ||
from conan.test.utils.tools import TestClient | ||
|
||
|
||
def test_package_vendor(): | ||
c = TestClient() | ||
app = textwrap.dedent(""" | ||
import os | ||
from conan import ConanFile | ||
from conan.tools.files import copy, save | ||
class App(ConanFile): | ||
name = "app" | ||
version = "0.1" | ||
package_type = "application" | ||
vendor = True | ||
requires = "pkga/0.1" | ||
def package(self): | ||
copy(self, "*", src=self.dependencies["pkga"].package_folder, | ||
dst=self.package_folder) | ||
save(self, os.path.join(self.package_folder, "app.exe"), "app") | ||
""") | ||
|
||
c.save({"pkga/conanfile.py": GenConanfile("pkga", "0.1").with_package_type("shared-library") | ||
.with_package_file("pkga.dll", "dll"), | ||
"app/conanfile.py": app | ||
}) | ||
c.run("create pkga") | ||
c.run("create app") # -c tools.graph:vendor=build will be automatic | ||
assert "app/0.1: package(): Packaged 1 '.dll' file: pkga.dll" in c.out | ||
|
||
# we can safely remove pkga | ||
c.run("remove pkg* -c") | ||
c.run("list app:*") | ||
assert "pkga" not in c.out # The binary doesn't depend on pkga | ||
c.run("install --requires=app/0.1 --deployer=full_deploy") | ||
assert "pkga" not in c.out | ||
assert c.load("full_deploy/host/app/0.1/app.exe") == "app" | ||
assert c.load("full_deploy/host/app/0.1/pkga.dll") == "dll" | ||
|
||
# we can create a modified pkga | ||
c.save({"pkga/conanfile.py": GenConanfile("pkga", "0.1").with_package_type("shared-library") | ||
.with_package_file("pkga.dll", "newdll")}) | ||
c.run("create pkga") | ||
# still using the re-packaged one | ||
c.run("install --requires=app/0.1 --deployer=full_deploy") | ||
assert "pkga" not in c.out | ||
assert c.load("full_deploy/host/app/0.1/app.exe") == "app" | ||
assert c.load("full_deploy/host/app/0.1/pkga.dll") == "dll" | ||
|
||
# but we can force the expansion, still not the rebuild | ||
c.run("install --requires=app/0.1 --deployer=full_deploy -c tools.graph:vendor=build") | ||
assert "pkga" in c.out | ||
assert c.load("full_deploy/host/app/0.1/app.exe") == "app" | ||
assert c.load("full_deploy/host/app/0.1/pkga.dll") == "dll" | ||
|
||
# and finally we can force the expansion and the rebuild | ||
c.run("install --requires=app/0.1 --build=app* --deployer=full_deploy " | ||
"-c tools.graph:vendor=build") | ||
assert "pkga" in c.out | ||
assert c.load("full_deploy/host/app/0.1/app.exe") == "app" | ||
assert c.load("full_deploy/host/app/0.1/pkga.dll") == "newdll" | ||
# This shoulnd't happen, no visibility over transitive dependencies of app | ||
assert not os.path.exists(os.path.join(c.current_folder, "full_deploy", "host", "pkga")) | ||
|
||
# lets remove the binary | ||
c.run("remove app:* -c") | ||
c.run("install --requires=app/0.1", assert_error=True) | ||
assert "Missing binary" in c.out | ||
c.run("install --requires=app/0.1 --build=missing", assert_error=True) | ||
assert "app/0.1: Invalid: The package 'app/0.1' is a vendoring one, needs to be built " \ | ||
"from source, but it didn't enable 'tools.graph:vendor=build'" in c.out | ||
|
||
c.run("install --requires=app/0.1 --build=missing -c tools.graph:vendor=build") | ||
assert "pkga" in c.out # it works | ||
|
||
|
||
def test_package_vendor_editable(): | ||
c = TestClient() | ||
pkgb = textwrap.dedent(""" | ||
import os | ||
from conan import ConanFile | ||
from conan.tools.files import copy, save | ||
class App(ConanFile): | ||
name = "pkgb" | ||
version = "0.1" | ||
package_type = "shared-library" | ||
vendor = True | ||
requires = "pkga/0.1" | ||
def layout(self): | ||
self.folders.build = "build" | ||
self.cpp.build.bindirs = ["build"] | ||
def generate(self): | ||
copy(self, "*", src=self.dependencies["pkga"].package_folder, | ||
dst=self.build_folder) | ||
def build(self): | ||
save(self, os.path.join(self.build_folder, "pkgb.dll"), "dll") | ||
""") | ||
|
||
c.save({"pkga/conanfile.py": GenConanfile("pkga", "0.1").with_package_type("shared-library") | ||
.with_package_file("bin/pkga.dll", "d"), | ||
"pkgb/conanfile.py": pkgb, | ||
"app/conanfile.py": GenConanfile("app", "0.1").with_settings("os") | ||
.with_requires("pkgb/0.1") | ||
}) | ||
c.run("create pkga") | ||
c.run("editable add pkgb") | ||
c.run("install app -s os=Linux") | ||
assert "pkga" in c.out | ||
# The environment file of "app" doesn't have any visibility of the "pkga" paths | ||
envfile_app = c.load("app/conanrunenv.sh") | ||
assert "pkga" not in envfile_app | ||
# But the environment file needed to build "pkgb" has visibility over the "pkga" paths | ||
envfile_pkgb = c.load("pkgb/conanrunenv.sh") | ||
assert "pkga" in envfile_pkgb | ||
|
||
|
||
def test_vendor_dont_propagate_options(): | ||
c = TestClient() | ||
app = GenConanfile("app", "0.1").with_requires("pkga/0.1").with_class_attribute("vendor=True") | ||
c.save({"pkga/conanfile.py": GenConanfile("pkga", "0.1").with_shared_option(False), | ||
"app/conanfile.py": app, | ||
"consumer/conanfile.txt": "[requires]\napp/0.1", | ||
"consumer_shared/conanfile.txt": "[requires]\napp/0.1\n[options]\n*:shared=True" | ||
}) | ||
c.run("create pkga") | ||
c.assert_listed_binary({"pkga/0.1": ("55c609fe8808aa5308134cb5989d23d3caffccf2", "Build")}) | ||
c.run("create app") | ||
c.assert_listed_binary({"pkga/0.1": ("55c609fe8808aa5308134cb5989d23d3caffccf2", "Cache"), | ||
"app/0.1": ("da39a3ee5e6b4b0d3255bfef95601890afd80709", "Build")}) | ||
c.run("install consumer --build=app/* -c tools.graph:vendor=build") | ||
c.assert_listed_binary({"pkga/0.1": ("55c609fe8808aa5308134cb5989d23d3caffccf2", "Cache"), | ||
"app/0.1": ("da39a3ee5e6b4b0d3255bfef95601890afd80709", "Build")}) | ||
c.run("install consumer_shared --build=app/* -c tools.graph:vendor=build") | ||
c.assert_listed_binary({"pkga/0.1": ("55c609fe8808aa5308134cb5989d23d3caffccf2", "Cache"), | ||
"app/0.1": ("da39a3ee5e6b4b0d3255bfef95601890afd80709", "Build")}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.