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
Feature/install ref #4197
Feature/install ref #4197
Conversation
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'm trying things like the one below, to test if it is the same behavior with .py
and .txt
files (and it is not):
class InstallReferenceTest(unittest.TestCase):
@parameterized.expand([(True, ), (False, )])
def test_install_reference_full(self, use_py):
client = TestClient()
if use_py:
conanfile_py = 'from conans import ConanFile\nclass Pkg(ConanFile):\n\tpass'
client.save({"conanfile.py": conanfile_py})
else:
conanfile_txt = '[generators]\ncmake'
client.save({"conanfile.txt": conanfile_txt})
client.run("install . Pkg/0.1@myuser/testing")
client.run("info . -n None")
self.assertIn("Pkg/0.1@myuser/testing", client.out)
Yeah, I thought about this one. It is not equal, because .txt cannot create packages, doesn't have any method that could use the attributes, or contain any logic, etc. It seemed that it didn't make a lot of sense to add this behavior to |
I would like to have the same behavior for a From my point of view, block/raise is not an option (we will force the batch script to check if it is a Is it hard to add this behavior? Does it require too many changes? |
Make sense, I'll try to change that. |
I have added code for printing the package information in Now it prints:
Or just |
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 am not sure what pain this PR is trying to solve. I guess something related to consumer nodes of the graph not having a proper name but for me this is adding complexity to users to solve a "Conan issue".
For me the syntax conan install . Pkg/0.1@myuser/testing
means: Install the requirements of my conanfile.txt (located in .) and additionally this Pkg/0.1@myuser/testing
one. I think this will confuse users.
Also this is missing documentation
client.save({"conanfile.txt": ""}) | ||
client.run("info .") | ||
self.assertIn("conanfile.txt", str(client.out).splitlines()) | ||
client.run("install . Pkg/0.1@myuser/testing") |
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.
This is confusing for conanfile.txt users
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.
It is not necessary, you don't need to specify it. Furthermore, raising an error was one of the possibilities suggested above. @jgsogo wanted to keep it to be consistent for all kinds of conanfiles
There are several real problems that this PR is trying to solve:
# This will fail with command ``conan build``
class Pkg(ConanFile):
#no version explictly defined, it is passed dynamically in conan create/export
def build(self):
if self.version == "1.68":
self.run("some build...")
else:
self.run("other build...")
class Pkg(ConanFile):
def requirements(self):
self.requires("Pkg/0.1@%s/%s" % (self.user, self.channel)) The above fails if the environment variables are not defined and you use it for local development with These environment variables should probably be deprecated in conan 2.0
|
We should take into account this comment by @danimtb, it could be the expected behavior (
...and the only alternative I can think about is using and argument 😕 or adding interactivity 😟 I'm sorry, but I don't have a silver bullet. |
I thought that it was very aligned with other conan commands: $ conan export <path> <partial-ref>
$ conan create <path> <partial-ref>
$ conan export-pkg <path> <partial-ref>
$ conan test <path> <full-ref> None of them mean to export, create, or test 2 different things, so apparently the commands: $ conan install <path> <partial-ref>
$ conan info <path> <partial-ref> had a nice symmetry with the above Note that it doesn't necessarily exclude installing multiple references, as the first argument could be tested to not be a reference, as it is already done right now where there is just 1 argument. I understand the point, but as you commented, the alternative of using an argument is a bit ugly too. |
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 agree with @memsharded this is the best approach we could do and totally understand the need. I suggest a couple of UX changes.
conans/client/command.py
Outdated
@@ -346,6 +346,9 @@ def install(self, *args): | |||
parser.add_argument("path_or_reference", help="Path to a folder containing a recipe" | |||
" (conanfile.py or conanfile.txt) or to a recipe file. e.g., " | |||
"./my_project/conanfile.txt. It could also be a reference") | |||
parser.add_argument("reference", nargs="?", | |||
help='user/channel, version@user/channel or pkg/version@user/channel ' |
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.
Suggested help:
Reference for the conanfile path of the first argument: user/channel, version@user/channel or pkg/version@user/channel
conans/client/command.py
Outdated
@@ -370,7 +373,9 @@ def install(self, *args): | |||
try: | |||
reference = ConanFileReference.loads(args.path_or_reference) |
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.
Check that args.reference
is None or raise. (Two references makes no sense)
I'm approving it, but still needed what other reviews are requesting:
|
Everything good BUT DOCS |
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.
Still think the command conan install . <ref>
is confusing as this command interacts both in the cache and in user space depending on using a ref as first argument or using a path. So let's document this clearly
Changelog: Feature: Enable a new
reference
argument inconan install <path> <reference>
, wherereference
can be a partial reference too (identical to what is passed toconan create
orconan export
. This allows defining all pkg,version,user,channel fields of the recipe for the local flow.Docs: conan-io/docs#1045