-
Notifications
You must be signed in to change notification settings - Fork 53
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
started with conflicts examples #2
Open
memsharded
wants to merge
9
commits into
conan-io:main
Choose a base branch
from
memsharded:feature/tutorial_consuming_versioning_conflicts
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
22bc578
started with conflicts examples
memsharded 47a4ae3
wip
memsharded 4bcca59
wip
memsharded 8dbd0cb
both force and override examples
memsharded 24861e3
review
memsharded 85b6d14
Merge branch 'main' of github.com:conan-io/examples2 into feature/tut…
czoido f099c61
fix ci (#5)
czoido df4efbe
fixed tests
memsharded 45366d9
add shell=True
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 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
7 changes: 7 additions & 0 deletions
7
examples/consuming_packages/versioning/conflicts/force/engine/conanfile.py
This file contains 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,7 @@ | ||
from conan import ConanFile | ||
|
||
class Pkg(ConanFile): | ||
name = "engine" | ||
version = "1.0" | ||
|
||
requires = "math/1.0" |
9 changes: 9 additions & 0 deletions
9
examples/consuming_packages/versioning/conflicts/force/game/conanfile.py
This file contains 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,9 @@ | ||
from conan import ConanFile | ||
|
||
class Pkg(ConanFile): | ||
name = "game" | ||
version = "1.0" | ||
|
||
def requirements(self): | ||
self.requires("engine/1.0") | ||
self.requires("math/2.0") |
4 changes: 4 additions & 0 deletions
4
examples/consuming_packages/versioning/conflicts/force/math/conanfile.py
This file contains 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,4 @@ | ||
from conan import ConanFile | ||
|
||
class Pkg(ConanFile): | ||
name = "math" |
47 changes: 47 additions & 0 deletions
47
examples/consuming_packages/versioning/conflicts/force/run_example.py
This file contains 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,47 @@ | ||
import os | ||
import subprocess | ||
|
||
def run(cmd, error=False): | ||
# Used by tools/scm check_repo only (see if repo ok with status) | ||
print("Running: {}".format(cmd)) | ||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) | ||
out, err = process.communicate() | ||
out = out.decode("utf-8") | ||
err = err.decode("utf-8") | ||
ret = process.returncode | ||
|
||
output = err + out | ||
if ret != 0 and not error: | ||
raise Exception("Failed cmd: {}\n{}".format(cmd, output)) | ||
if ret == 0 and error: | ||
raise Exception("Cmd succeded (failure expected): {}\n{}".format(cmd, output)) | ||
return output | ||
|
||
|
||
# This is a half diamond | ||
# game -> engine -> math/1.0 | ||
# \--------------> math/2.0 (conflict) | ||
# solved with force=True | ||
|
||
# Demo the conflict | ||
run('conan remove "*" -f') # Make sure no packages from last run | ||
run("conan create math --version=1.0") | ||
run("conan create math --version=2.0") | ||
run("conan create engine") | ||
out = run("conan install game", error=True) | ||
assert "ERROR: Version conflict: engine/1.0->math/1.0, game/1.0->math/2.0" in out | ||
|
||
# Add the requires "force=True" fixes it | ||
content = open("game/conanfile.py").read() | ||
new_content = content.replace('self.requires("math/2.0")', | ||
'self.requires("math/2.0", force=True)') | ||
open("game/conanfile.py", "w").write(new_content) | ||
# The jump in major version requires building a new engine/1.0 binary | ||
out = run("conan install game", error=True) # binary missing | ||
assert "ERROR: Missing binary: engine/1.0" in out | ||
|
||
# With force=True and --build=missing, it works | ||
run("conan install game --build=missing") | ||
|
||
# restore the original contents: | ||
open("game/conanfile.py", "w").write(content) |
7 changes: 7 additions & 0 deletions
7
examples/consuming_packages/versioning/conflicts/override/ai/conanfile.py
This file contains 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,7 @@ | ||
from conan import ConanFile | ||
|
||
class Pkg(ConanFile): | ||
name = "ai" | ||
version = "1.0" | ||
|
||
requires = "math/2.0" |
7 changes: 7 additions & 0 deletions
7
examples/consuming_packages/versioning/conflicts/override/engine/conanfile.py
This file contains 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,7 @@ | ||
from conan import ConanFile | ||
|
||
class Pkg(ConanFile): | ||
name = "engine" | ||
version = "1.0" | ||
|
||
requires = "math/1.0" |
9 changes: 9 additions & 0 deletions
9
examples/consuming_packages/versioning/conflicts/override/game/conanfile.py
This file contains 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,9 @@ | ||
from conan import ConanFile | ||
|
||
class Pkg(ConanFile): | ||
name = "game" | ||
version = "1.0" | ||
|
||
def requirements(self): | ||
self.requires("engine/1.0") | ||
self.requires("ai/1.0") |
4 changes: 4 additions & 0 deletions
4
examples/consuming_packages/versioning/conflicts/override/math/conanfile.py
This file contains 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,4 @@ | ||
from conan import ConanFile | ||
|
||
class Pkg(ConanFile): | ||
name = "math" |
48 changes: 48 additions & 0 deletions
48
examples/consuming_packages/versioning/conflicts/override/run_example.py
This file contains 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,48 @@ | ||
import os | ||
import subprocess | ||
|
||
def run(cmd, error=False): | ||
# Used by tools/scm check_repo only (see if repo ok with status) | ||
print("Running: {}".format(cmd)) | ||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) | ||
out, err = process.communicate() | ||
out = out.decode("utf-8") | ||
err = err.decode("utf-8") | ||
ret = process.returncode | ||
|
||
output = err + out | ||
if ret != 0 and not error: | ||
raise Exception("Failed cmd: {}\n{}".format(cmd, output)) | ||
if ret == 0 and error: | ||
raise Exception("Cmd succeded (failure expected): {}\n{}".format(cmd, output)) | ||
return output | ||
|
||
|
||
# This is a full diamond | ||
# game -> engine -> math/1.0 | ||
# \----> ai -----> math/2.0 (conflict) | ||
# solved with override=True | ||
|
||
# Demo the conflict | ||
run('conan remove "*" -f') # Make sure no packages from last run | ||
run("conan create math --version=1.0") | ||
run("conan create math --version=2.0") | ||
run("conan create engine") | ||
run("conan create ai") | ||
out = run("conan install game", error=True) | ||
# NOTE This output shows the downstream conflict not the immediate | ||
assert "ERROR: Version conflict: ai/1.0->math/2.0, game/1.0->math/1.0" in out | ||
|
||
# Add the requires "force=True" fixes it | ||
content = open("game/conanfile.py").read() | ||
new_content = content + ' self.requires("math/2.0", override=True)\n' | ||
open("game/conanfile.py", "w").write(new_content) | ||
# The jump in major version requires building a new engine/1.0 binary | ||
out = run("conan install game", error=True) # binary missing | ||
assert "ERROR: Missing binary: engine/1.0" in out | ||
|
||
# With force=True and --build=missing, it works | ||
run("conan install game --build=missing") | ||
|
||
# restore the original contents: | ||
open("game/conanfile.py", "w").write(content) |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is weird. I would have expected now something like below:
what am I missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nop, this is the current implementation. The conflict shown is because the engine->math conflict is propagated down to game. If it wasn't propagated it wouldn't conflict, so the conflict needs to be tracked down from game.
At least this is the current implementation, we can try to improve the information there, but that would require changes in code.
This will be run by CI, so we will make sure that the examples work and they align with the release.