Conan: Environment variables used in imports()

Created on 24 Jan 2017  路  5Comments  路  Source: conan-io/conan

Hi,
As discussed in #836 with @memsharded
I am opening an issue to see if this feature would make sense.

My current case is the following:
Since we have seen that conan is pretty awesome. We decided to gradually switch our dependencies to conan

Currently I have a library B wich depends on a shared library A.
I first migrate B to conan and in order to build I have an environment variable that points to some external path where library A is compiled by our old system.
This path changes depending on machine so I do not want it to be a setting.

When running the test package I need the dlls of the dependency A to be in the test_package/..../bin folder. So what I thought is that in imports() I could use the variables passed by --env in order to get the path of A and copy the dlls with self.copy.
However imports() does not have access to what it is passed by --env.

All 5 comments

I have submitted a proposal to include this in #897.

I guess that your issue was about the environment variables declared by conan command line or profile. The imports:

def imports(self):
    self.copy("file*.txt", dst=os.environ["MY_IMPORT_PATH"])

should work with manually defined environment variables (like set MY_IMPORT_PATH=C:/mypath or export MY_IMPORT_PATH=/home/myuser/mypath)

So you meant about this, right?

$ install -e MY_IMPORT_PATH=C:/Mypath

That should work with the fix of the proposed PR.

The proposed solution in #897 has some caveat though: it will not work for $ conan imports command, only for the imports functionality in $ conan install.

For the "conan imports" to work, we need to do some larger improvements over the caching of install information, so impossible for this release. I hope that the "conan install" could be enough for you by now.

I think that covers our use case since we use it mostly from conan test_package and conan install.

Thanks a lot! It is very nice to see that there is a C++ package manager with such an active development!

Thanks for telling! :) Good, it will be released in 0.19, scheduled for 31st: https://github.com/conan-io/conan/milestone/12. If you want to use it today, you can run from sources (develop branch), it is not difficult. Cheers!

Released in 0.19, closing the issue, but please re-open or create a new one if necessary.

Was this page helpful?
0 / 5 - 0 ratings