-
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
22bc578
47a4ae3
4bcca59
8dbd0cb
24861e3
85b6d14
f099c61
df4efbe
45366d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from conan import ConanFile | ||
|
||
class Pkg(ConanFile): | ||
name = "math" |
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" |
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") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from conan import ConanFile | ||
|
||
class Pkg(ConanFile): | ||
name = "math" |
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) | ||
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) |
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" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing newline |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from conan import ConanFile | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could not see the usage of this file in the sample execution. Is this intentional? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same. Removing |
||
|
||
class Pkg(ConanFile): | ||
name = "math" |
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" |
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") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from conan import ConanFile | ||
|
||
class Pkg(ConanFile): | ||
name = "math" |
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) | ||||||
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 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that is weird. I would have expected now something like below:
Suggested change
what am I missing? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||||||
|
||||||
# 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) |
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.
I could not see the usage of this file in the sample execution. Is this intentional?
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, good catch.