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 should let my recipe inherit its package name and version #5340

Open
thejohnfreeman opened this issue Jun 12, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@thejohnfreeman
Copy link

commented Jun 12, 2019

To help us debug your issue please explain:

  • I've read the CONTRIBUTING guide.
  • I've specified the Conan version, operating system version and any tool that can be relevant.
  • I've explained the steps to reproduce the error or the motivation/use case of the question/suggestion.

Conan: 1.15.0
OS: Ubuntu 18.04
Python: 3.7.1

My recipe wants to inherit its package name and version from a class that knows how to get them, but Conan refuses to create the package because (I believe) it uses astroid to parse the recipe script and see if there is a name and version attribute set directly on the recipe class. Please just run the recipe and fail if there really is no name or version.

# test.py
from conans import ConanFile

class Foo:
    name = 'foo'
    version = '1.2.3'

class Recipe(Foo, ConanFile):
    pass
$ conan create test.py demo/testing
ERROR: conanfile didn't specify name
$ python -c 'import test; print(test.Recipe.name); print(test.Recipe.version)'
foo
1.2.3

I shouldn't have to do this.

# fixed.py
from conans import ConanFile

class Foo:
    name = 'foo'
    version = '1.2.3'

class Recipe(Foo, ConanFile):
    name = Foo.name
    version = Foo.version
@memsharded

This comment has been minimized.

Copy link
Contributor

commented Jun 12, 2019

This has a reason: inheriting automatically the name and version of a base class was very confusing and problematic, because the main case of inheriting a base class is via python_requires, and in that case, the name and version are the name and version of the python-require'd package, which is not what you want.

I think allowing this would be breaking behavior for those users and cannot be changed, unless until the python-requires issue (#4635) has been addressed (and no earlier than Conan 2.0, to be able to change this)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.