Skip to content
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

[question] python requires : to create a package with 2.x #13861

Closed
1 task done
maitrey opened this issue May 10, 2023 · 8 comments
Closed
1 task done

[question] python requires : to create a package with 2.x #13861

maitrey opened this issue May 10, 2023 · 8 comments
Assignees

Comments

@maitrey
Copy link

maitrey commented May 10, 2023

What is your question?

Dear Conan Folks,
I have some common methods in my recipes that I use across packages.
But the 1.x and 2.x documentation seems to be different in the way of creating packages.
https://docs.conan.io/2/reference/extensions/python_requires.html?highlight=python%20requires
Here it says conan create .
But In 1.x it says :
https://docs.conan.io/1/extending/python_requires.html
conan export .
Which is the correct way of python requires package?
I use conan-2.0.4.
Could you please guide me?

Thanks!
Br,
Maitrey

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@memsharded
Copy link
Member

Hi @maitrey

In Conan 2.0 you can also use conan export as in 1.X.

What changed in Conan 2.0 is that as long as you define the package_type = "python-require" in it, the conan create will be equivalent to the conan export.

@maitrey
Copy link
Author

maitrey commented May 10, 2023

Yes I could use the conan export . but I see that the documentation is confusing as it says to use : conan create . in 2.x.
I have another issue at the moment. I use static code analysis and I use compile_commands.json.
When using conan-2.x:
i can see that the structure of folders is different in conan cache .. when i build locally i see the export sources sources and sources in another folder and build and package in another folder .. When the build is running everything is run inside a  t folder and this is cleaned up once the package is created . Also, the CMAKE_SOURCE_DIR , CMAKE_BINARY_DIR ; CMAKE_CURRENT_SOURCE_DIR and CMAKE__CURRENT_BINARY_DIR  all point to everything insiide the t folder . Its not possible to debug as the compile_commands.json information after copying to b folder is having information that no longer exists.How can I disable that the t folder stays for debugging purposes ?

@memsharded
Copy link
Member

Yes I could use the conan export . but I see that the documentation is confusing as it says to use : conan create . in 2.x.

Yes, this is intended. Users don't need to recall to call another command, they can do conan create for python-requires as well, more homogenous and simpler UX

can see that the structure of folders is different in conan cache .. when i build locally i see the export sources sources and sources in another folder and build and package in another folder .. When the build is running everything is run inside a t folder and this is cleaned up once the package is created . Also, the CMAKE_SOURCE_DIR , CMAKE_BINARY_DIR ; CMAKE_CURRENT_SOURCE_DIR and CMAKE__CURRENT_BINARY_DIR all point to everything insiide the t folder . Its not possible to debug as the compile_commands.json information after copying to b folder is having information that no longer exists.How can I disable that the t folder stays for debugging purposes ?

This would be solved by #13833, ongoing work

@maitrey
Copy link
Author

maitrey commented May 10, 2023

I am using the command to build my packages locally:
conan create . --user autosar--channel bringupconan2 -pr:b=default -pr:h=ndp -c tools.build:skip_test=False
I am using add_test to run static code analysis. In my case, there is a python script that I call. But I donot see the Testing logs and also if I use BUILD_TESTING I cannot see which testing targets are built :( .

@maitrey
Copy link
Author

maitrey commented May 10, 2023

If I use like this:

def build(self):
    cmake = CMake(self)
    cmake.configure()
    cmake.build()
    if not self.conf.get("tools.build:skip_test", default=False):
        cmake.test()

and in CMakeLists.txt:

 if (BUILD_TESTING)
add_test(testTarget ${PYTHONPATH} ${ENV_TESTTOOL}/staticcodeanalysis_run.py )
endif()

It fails with:
ERROR: mngr/0.0.0-dev.0@autosar/bringupconan2: Error in build() method, line 64
cmake.test()
ConanException: Cannot wrap command with different envs,['C:\Users\.conan2\p\t\mngr396dd68d0350b\b\build\Debug\generators\conanbuild.bat'] - ['C:\Users\.conan2\p\t\mngr396dd68d0350b\b\build\Debug\generators\conanrun.sh']

@maitrey
Copy link
Author

maitrey commented May 10, 2023

If I use add_custom_target instead of add_test it fails with:
ERROR: Couldn't move folder: C:\Users.conan2\p\t\mngr5fc49c520f875->C:\Users.conan2\p\mngrbe25c70a5cd31
Destination path C:\Users\.conan2\p\mngrbe25c70a5cd31\mngr5fc49c520f875 already exists
Folder might be busy or open. Close any app using it and retry.
And there is no other application that has opened this location , unfortuantely.
How do I fix it ?

@memsharded
Copy link
Member

Hi @maitrey

Sorry, this issue is deviating too much from the original post, which was about python_requires, and then changed to debugging, now it seems related to testing inside recipes, and apparently usage of environments.

I'd recommend to open a new ticket with the environment thing, with something that can be reproduced, I am afraid there is not enough information above to understand what could be happening. Thanks!

@maitrey
Copy link
Author

maitrey commented May 10, 2023

alright, sorry I tend to misuse when I open one for a discussion. Sorry about it. I will open up a new issue.

@maitrey maitrey closed this as completed May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants