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

Avoid hard-coding the package version #10

Open
jhlegarreta opened this issue Feb 8, 2023 · 1 comment
Open

Avoid hard-coding the package version #10

jhlegarreta opened this issue Feb 8, 2023 · 1 comment

Comments

@jhlegarreta
Copy link
Contributor

Docker is being unable to identify the version for the tractolearn package:

LookupError: setuptools-scm was unable to detect version for /tractolearn.

The current workaround is to pretend a version for the package:
https://github.com/scil-vital/dockerfile_tractolearn/blob/main/Dockerfile#L6

Docker, through setuptools-scm, may be trying to do something like

import tractolearn
tractolearn.__version__

and it is failing because the property is not defined: it does not work either if you try in the console:

AttributeError: module 'tractolearn' has no attribute 'version'

For this to exist it must be defined in tractolearn.__init__: if I put __version__ = "0.0.1", the command tractolearn.__version__ works. So to do it automatically it would be necessary to put something like

import pkg_resources
__version__ = pkg_resources.require("tractolearn")[0].version

The next step would be to read the name "tractolearn" automatically:

  1. From the pyproject.toml file, or
  2. Using
    from setuptools_scm import get_version
    __version__ = get_version()
    

To do 1, tomli and the "pyproject.toml" file must be installed/locatable; to do 2. setuptools_scm must be installed.

The other option is to read the version from tractolearn/_version.py which is written at build time by setuptools_scm.

Slightly related to
scil-vital/tractolearn#37 (comment)
(Adopting a single way to read the version may ease maintenance)

Probably this is required regardless of Docker to be able towards building a PEP-compliant package:
https://peps.python.org/pep-0396/

@jhlegarreta
Copy link
Contributor Author

Cross-referencing scil-vital/tractolearn#39.

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

No branches or pull requests

1 participant