Skip to content

Commit

Permalink
Get version using an arbitraty executable
Browse files Browse the repository at this point in the history
  • Loading branch information
webknjaz committed Nov 25, 2018
1 parent b9e0c33 commit ec30169
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions poetry/packages/project_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@

class ProjectPackage(Package):
def __init__(self, name, version, pretty_version=None):
if isinstance(version, str) and version.startswith('attr:'):
version_pkg, _, version_attr = (
version[6:].strip().rpartition('.')
)
if not version_pkg:
version_pkg = 'builtins'
version_getter = getattr(
__import__(version_pkg, fromlist=(version_pkg, )),
version_attr,
)
version = version_getter()
if version is None:
raise RuntimeError(
'The version getter callable must return a string '
'or a Version instance'
)

super(ProjectPackage, self).__init__(name, version, pretty_version)

self.build = None
Expand Down

0 comments on commit ec30169

Please sign in to comment.