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

conan 2.0: can we still use the imports method or an equivalent when consuming packages? #13239

Closed
1 task done
dimi309 opened this issue Feb 26, 2023 · 13 comments
Closed
1 task done

Comments

@dimi309
Copy link
Contributor

dimi309 commented Feb 26, 2023

What is your question?

Hello!

I was wondering if there is an equivalent for the conanfile.py imports method (discussed here for example #1267) in conan 2.0, for copying files (e.g. text configuration files, shaders, etc) from a package to a consuming application. I have an imports method in the conanfile.py of one of my applications but it does not seem to get launched any more.

Thanks!

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@samuel-emrys
Copy link
Contributor

The replacement feature for the imports() method is deployers

@dimi309
Copy link
Contributor Author

dimi309 commented Feb 26, 2023

I was searching and searching... 😭 Thanks a lot!!! 👍 👍 👍

@dimi309 dimi309 closed this as completed Feb 26, 2023
@samuel-emrys
Copy link
Contributor

Also see this section of the 2.0 migration guide - you can use the generate() function:

from conan.tools.files import copy

def generate(self):
    for dep in self.dependencies.values():
        copy(self, "*.dylib", dep.cpp_info.libdirs[0], self.build_folder)
        copy(self, "*.dll", dep.cpp_info.libdirs[0], self.build_folder)

@dimi309
Copy link
Contributor Author

dimi309 commented Feb 26, 2023

This one is even more straightforward and I was actually using it for packaging. What stopped me from using it for deployments to applications is that I didn't know about self.build_folder. Thanks again!!

@memsharded
Copy link
Member

Thanks @samuel-emrys!

@nextsilicon-itay-bookstein

It's not obvious to me from the documentation whether there's a built-in deployer for licenses or whether I need to write one myself - what was the verdict here, did you write a custom deployer?

@samuel-emrys
Copy link
Contributor

It's not obvious to me from the documentation whether there's a built-in deployer for licenses or whether I need to write one myself - what was the verdict here, did you write a custom deployer?

https://github.com/conan-io/conan-extensions/blob/main/extensions%2Fdeployers%2FREADME.md

@nextsilicon-itay-bookstein

Awesome, thanks!

@johan-boule
Copy link

There seems to be a big quiproquo/misunderstanding about the intended goals of these features, as they are designed, and the expectations of the users. It was the same in Conan 1, we had to abuse the imports command to actually deploy a self contained application.
Conan seems to have a "blind spot" in its feature-set and misses the equivalent of traditional make install.
I read the documentation, and I'm still clueless about how we can deploy runtime dependencies along with our application.

@memsharded
Copy link
Member

Hi @johan-boule

I am not sure what you mean, Conan 2 got the new deployers and the deploy() method, which easily allow to deploy apps, for example using the built-in runtime deployer, for a example to deploy an existing app like:

$ conan new cmake_exe -d name=myapp -d version=0.1
$ conan create . 

It is just

$ conan install --requires=myapp/0.1 --deployer=runtime_deploy

(the runtime_deploy is a bit new and experimental, it might need still a bit of iteration, but the intention is there).
And deployers are now also user-defined (and can be shared with conan config install too.

So maybe you want to create a new issue with more accurate details of the flow you want to implement, and your attempts using deployers or deploy() method?

@johan-boule
Copy link

$ conan install --requires=myapp/0.1 --deployer=runtime_deploy

(the runtime_deploy is a bit new and experimental, it might need still a bit of iteration, but the intention is there). And deployers are now also user-defined (and can be shared with conan config install too.

Thanks a lot for mentioning this new builtin deployer. When we did the preliminary work to switch to Conan 2 a few months ago, we were at version 2.4.0 and this one seem to have been added in 2.5.0, so that would explain why we didn't see it :-)

So maybe you want to create a new issue with more accurate details of the flow you want to implement, and your attempts using deployers or deploy() method?

From the description of the runtime_deploy, it says "into a flat directory structure", so there's a chance it matches my expectation of what a make install does, i.e. merging all things together into a standard unix tree layout. I'll check it out. Thanks again.

@samuel-emrys
Copy link
Contributor

@johan-boule if that doesn't satisfy your use case, you can either write a custom deployer (if the logic applies to many packages and you want reusability) or implement the deploy() method (if the logic only applies to the software being packaged/deployed), and these allow you to do almost literally anything you would care to from a deployment perspective.

@memsharded
Copy link
Member

Thanks a lot for mentioning this new builtin deployer. When we did the preliminary work to switch to Conan 2 a few months ago, we were at version 2.4.0 and this one seem to have been added in 2.5.0, so that would explain why we didn't see it :-)

yes, that makes sense :)

We keep working very hard to keep improving Conan. Conan 2.0 was not only the major version, but also a new architecture that allowed us to develop a lot of new features that have been requested for a long time, so definitely worth checking from time to time the release notes and our blog (https://blog.conan.io/) for new features.

From the description of the runtime_deploy, it says "into a flat directory structure", so there's a chance it matches my expectation of what a make install does, i.e. merging all things together into a standard unix tree layout. I'll check it out.

Feel free to create new tickets if you see any issue, there is already this pending ticket #16938, you can comment there if you find related problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants