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

[bug] Unable to use "specific names" as values for conf entries #15777

Closed
mhabibav opened this issue Feb 29, 2024 · 4 comments · Fixed by #15779
Closed

[bug] Unable to use "specific names" as values for conf entries #15777

mhabibav opened this issue Feb 29, 2024 · 4 comments · Fixed by #15779
Assignees
Milestone

Comments

@mhabibav
Copy link

Environment details

  • Operating System+version: Irrelevant
  • Compiler+version: Irrelevant
  • Conan version: 2.0.17 (packaged as exe with the pyinstaller script)
  • Python version: 3.12

Steps to reproduce

  1. In any recipe, setting a conf value to any of the following values results in an error: [copy, re, fnmatch, OrderedDict]. This is probably because there are modules / types with the same name imported in the file where eval is run. That results in the value being interpreted as something other than a string.

Dummy scenario:
conanfile.py

from conan import ConanFile


class dummy(ConanFile):
    name = "fixed_name"
    version = "1.2.3"

    def build(self):
        x = self.conf.get("user.company.conf:conf")
        self.output.warning("|" * 100)
        self.output.warning(type(x))
        self.output.warning(x)
        self.output.warning("|" * 100)

command:

conan build . -c "user.company.conf:conf=fnmatch"

Logs

PS C:\E\ws\temp\New folder (3)> conan build . -c "user.company.conf:conf=re"
ERROR: It's not possible to compose module values and str ones.
PS C:\E\ws\temp\New folder (3)> conan build . -c "user.company.conf:conf=OrderedDict"
ERROR: It's not possible to compose type values and str ones.
PS C:\E\ws\temp\New folder (3)> conan build . -c "user.company.conf:conf=fnmatch"
ERROR: It's not possible to compose module values and str ones.
@mhabibav
Copy link
Author

The suspected file where this issue is present is probably: conans/model/conf.py
Particularly the function _get_evaluated_value(__v) in line: 643 (or line 653 in the current version)

@memsharded
Copy link
Member

Thanks very much for your report @mhabibav

This is indeed a gap in the evaluation of confs, it didn't take into account the possibility of a match with an existing Python module. I am submitting a fix in #15779 for next 2.2 release.

@mhabibav
Copy link
Author

Thanks for the quick fix.

@memsharded
Copy link
Member

#15779 merged, it will be in next 2.2

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

Successfully merging a pull request may close this issue.

2 participants