Skip to content

Old setuptools_scm issue (FreeBSD, for example) #1207

@henryiii

Description

@henryiii

Describe the bug

Pipx expects setuptools_scm (via hatch_vcs) to produce __version__ in the default template. However, older versions, such as the one supplied in FreeBSD, do not (this alias was added in version 7; for other reasons, FreeBSD is stuck on 6 and treats 7 as a new package).

https://github.com/pypa/pipx/blob/6918c4de5898d65807a2255eed43b6f5a6cf1a21/src/pipx/main.py#L31C1-L32C1

Two easy fixes and one less so: the one I usually do is to import version (the original name) as __version__ (like in https://github.com/scikit-build/scikit-build-core/blob/f8c5798897852e107df0683893de59e15c558baf/src/scikit_build_core/__init__.py#L9). That was the original name, and is always available. You can also specify the template, which allows you to put whatever you want in version.py, but does require a bit more configuration. And the less-ideal fix would be to limit the version of setuptools_scm that hatch_vcs pulls in to some minimum that includes the addition of this feature (v7).

How to reproduce

Seen in abravalheri/validate-pyproject#142, logs: https://github.com/abravalheri/validate-pyproject/pull/142/checks?check_run_id=20500888256

pipx run coverage xml -o coverage.xml
Traceback (most recent call last):
  File "/usr/local/bin/pipx", line 5, in <module>
    from pipx.main import cli
  File "/usr/local/lib/python3.9/site-packages/pipx/main.py", line 31, in <module>
    from pipx.version import __version__
ImportError: cannot import name '__version__' from 'pipx.version' (/usr/local/lib/python3.9/site-packages/pipx/version.py)

Expected behavior

Would be nice not to have pipx crash on FreeBSD.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions