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

tools.files.get doesn't work in export_sources(). [bug] #16032

Closed
IceJohnS opened this issue Apr 5, 2024 · 3 comments · Fixed by #16034
Closed

tools.files.get doesn't work in export_sources(). [bug] #16032

IceJohnS opened this issue Apr 5, 2024 · 3 comments · Fixed by #16034
Assignees
Milestone

Comments

@IceJohnS
Copy link

IceJohnS commented Apr 5, 2024

Describe the bug

We're trying to use tools.files.get to download external source to bundle it with the recipe during export. The get call fails when tools.files.download tries to read conanfile.conf which isn't populated.

Error in export_sources() method, line 41
        get(
        AttributeError: 'Bzip2Conan' object has no attribute 'conf'

How to reproduce it

We removed the source() method from a conan-center recipe and appended the following to export_sources().

        get(
            self,
            **self.conan_data["sources"][self.version],
            destination='src',
            strip_root=True)
        copy(self, 'src/*', self.recipe_folder, self.export_sources_folder)
@memsharded memsharded self-assigned this Apr 5, 2024
@memsharded
Copy link
Member

Hi @IceJohnS

Thanks for your report.

I'd say this is intended behavior, at least at the moment. The export_source() method is a method to copy files from the current repo to the recipe, but it was never intended to download things and do a copy of those in the recipe.

Maybe you are looking for the source-backup feature? If you haven't yet, please have a look to https://blog.conan.io/2023/10/03/backup-sources-feature.html. It can store the sources from the internet in your own server, to not rely on internet sources, which I'd say it is more or less your concern when you are trying to capture those sources as recipe "export-sources".

I'll have a look anyway to the conf issue in exports_sources. I don't think this is solvable, at least to use profile conf information, because the export stage doesn't use the profiles at all (the conan export command doesn't get profile arguments at all, for example).

@memsharded
Copy link
Member

If we assume that only global.conf information is going to be available at those methods, I think it might be ok to give access. I am trying it in #16034 (intended for next Conan 2.3 release), it should be relatively low risk, and something similar is already being done for the source() method in the conan source command, which also acts on the "local" recipe and is independent of profile information.

@memsharded memsharded added this to the 2.3.0 milestone Apr 8, 2024
@memsharded
Copy link
Member

#16034 got merged, so it will be in next Conan 2.3

However the above recommendations might be worth checking.

There are several reasons why the "download code at export time" might not be the best approach. Another one is that you will never be able to use the "local flow", in which it is possible to do conan source + conan build to develop and test locally, which is way more convenient for developers. I guess this is not a current concern for you, but it can be an important use case for many other people, just something to have in mind.

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

Successfully merging a pull request may close this issue.

2 participants