Skip to content

Conan should let my recipe inherit its package name and version #5340

Description

@thejohnfreeman

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions