Closed gazzatav closed 6 months ago
Hi @gazzatav
Thanks for the feedback.
I am not sure the CMakeLists.txt
is missing. It is part of the source repo, the source repo is obtained in the recipe:
def source(self):
git = Git(self)
git.clone(url="https://github.com/conan-io/libhello.git", target=".")
# Please, be aware that using the head of the branch instead of an immutable tag
# or commit is not a good practice in general
git.checkout("with_tests")
And if we see the repo, we can see the CMakeListst.xt: https://github.com/conan-io/libhello/blob/with_tests/CMakeLists.txt, with the necessary install(TARGETS hello)
call, no need edition (it cannot actually be edited, because it is not in the repo, it is external).
Maybe this needs some clarification in the docs
instead?
In the docs we just have: $ git clone https://github.com/conan-io/examples2.git $ cd examples2/tutorial/creating_packages/package_method
Then what do I need to do?
I tried conan install . -pr=c++20 followed by: conan create . --build=missing -tf="." -pr=c++20 -c tools.build:skip_test=True but I still get the same error: AttributeError: 'helloRecipe' object has no attribute 'test'
Which step am I missing that needs to be in the docs? (As soon as I know I can edit the docs and do a pull request).
I also tried the above steps after removing everything except the conan file and the two other python scripts and I got this: ERROR: hello/1.0 (test package): Error in build() method, line 68 cmake.configure() ConanException: Error 1 while executing
I have just tried what the tutorial says:
$ conan create . --build=missing -tf=""
And it works fine If I try
$ conan create . --build=missing -tf="" -c tools.build:skip_test=True
Still the same, it works.
I don't know what is c++20
, is this a local profile file you have there? Also the first conan install .
step is not necessary, conan create
is good.
Running the test_package
with:
$ conan create . --build=missing
Also seems to work here.
It might be something else, but I dont know what it could be. Can you please share the exact steps from scratch?
conan remove * -c
conan --version
is the latestc++20
profile fileThanks!
I had worked through each tutorial all the way to package_method. In light of what you said I removed the tutorials and cloned again. Now create works (with the c++20 profile - it has the paths to the gcc-12 things). I didn't need to clear the cache - I wasn't keen on removing 30+ packages anyway!
Now I understand where my thinking was wrong but not why it resulted in an error. When I read the tutorial I was interested in what was not being shown in the CMakeLists.txt '...' so being tired I stupidly looked in the packagemethod folder instead of the cache (or cloning the libhello repo). Not finding it package method folder, I created it there - but the conan file won't see that so I'm still puzzled by why that attribute error happened - like you said - the sources are being cloned each time.
I'm using Conan version 2.0.4 on Ubuntu 22.04 using pyenv for the python. I've just upgraded to Conan version 2.0.17 and run the create command, output looks the same (no errors now). Even created that wrong CMakeLists.txt and it still works fine.
The docs are a little confusing but essentially correct.
Ok, great, thanks for the feedback!
I think that explain the issue, and the example is correct. Then maybe we can close this issue as solved? Don't hesitate to create new tickets for any further question!
Yes, thanks as always, closing.
The creating_packages/package_method tutorial is missing the CMakeLists.txt which is shown in the docs. Of course it's easy enough to copy the file from the tutorial and use it as is but this could be a source of confusion especially as it has to be edited. Next the src dir and hello.cpp are missing as is the test folder and its test. The conan file has the gtest logic but from the error below maybe it's missing something. Finally after creating missing dirs and src file with void hello() and setting -c tools.build:skip_test=True in the create command, I get this which is puzzling: ======== Testing the package: Executing test ======== hello/1.0 (test package): Running test() ERROR: AttributeError: 'helloRecipe' object has no attribute 'test'
EDIT: This funny error disappears after removing -tf="" from the command line.