Closed yurivict closed 5 months ago
How did you install param? It looks like it was done with a Linux distribution, which did not package the _version
file.
param was built and installed using the PEP517-compliant build
and install
projects within the FreeBSD ports framework.
Hi @yurivict, you mention the install
project, is it thin one https://pypi.org/project/install/?
I've just tried the following with success:
python3 -m venv .venv
and source .venv/bin/activate
python -m build
pip install dist/param-2.0.2.dev2+g3e90912-py3-none-any.whl
mkdir foo && cd foo
import param
Could you please report the exact steps that lead you to the error you reported?
Thanks @yurivict, but I'm still confused by this issue.
I've tried to reproduce locally some of the steps you shared in this log file (get sdist, install build/installer/hatchling/hatch-vcs, isolated wheel build, wheel installed with installer) and could import param without any issue.
Coming back to your traceback, it clearly shows that the param/_version.py
module exists (otherwise you would see a ModuleNotFoundError
) but that it does not contain a __version__
variable, resulting in an ImportError
. However, I can confirm that the sdist on PyPI has a __version__
variable in the param/_version.py
module:
❯ curl -sL "https://files.pythonhosted.org/packages/14/c8/b42882ed1ba40478d5c1daa6fbb953c8180ea69fe94b9e6783060f5564ae/param-2.0.1.tar.gz" | tar -xzO "param-2.0.1/param/_version.py"
# file generated by setuptools_scm
# don't change, don't track in version control
TYPE_CHECKING = False
if TYPE_CHECKING:
from typing import Tuple, Union
VERSION_TUPLE = Tuple[Union[int, str], ...]
else:
VERSION_TUPLE = object
version: str
__version__: str
__version_tuple__: VERSION_TUPLE
version_tuple: VERSION_TUPLE
__version__ = version = '2.0.1'
__version_tuple__ = version_tuple = (2, 0, 1)
Maybe you could check the content of param/_version.py
in your pipeline?
Oh wait wait wait, I think I know, do you download param-2.0.1.tar.gz
from Github?
Oh wait wait wait, I think I know, do you download param-2.0.1.tar.gz from Github?
No, the tarball is downloaded from the PYPI site: https://pypi.org/packages/source/p/param/param-2.0.1.tar.gz
Ok ok. I'm at a loss there :/ Really wish I could unblock you. I'd be curious to see the content of param._version.py
at different stages of your pipeline.
Before build:
$ cat ./work-py39/param-2.0.1/param/_version.py
# file generated by setuptools_scm
# don't change, don't track in version control
TYPE_CHECKING = False
if TYPE_CHECKING:
from typing import Tuple, Union
VERSION_TUPLE = Tuple[Union[int, str], ...]
else:
VERSION_TUPLE = object
version: str
__version__: str
__version_tuple__: VERSION_TUPLE
version_tuple: VERSION_TUPLE
__version__ = version = '2.0.1'
__version_tuple__ = version_tuple = (2, 0, 1)
After build:
$ cat ./work-py39/param-2.0.1/param/_version.py
# coding: utf-8
# file generated by setuptools_scm
# don't change, don't track in version control
version = '2.0.1'
version_tuple = (2, 0, 1)
py39-setuptools_scm-6.4.2 is used.
The latest is setuptools-scm 8.0.4, but it wasn't yet adopted.
Now I vaguely remember that a similar problem happened with some other port because setuptools-scm was 6.x, and they had to patch the project in some way because setuptools-scm changed behavior between versions.
Indeed __version__
was added in _version.py
to setuptools-scm in version 7.0.0 (part of this massive PR https://github.com/pypa/setuptools_scm/pull/580/files#diff-bdefa0298003efada7c465428643cc6d9c129168afb3eb5c551b40fcc77feac1R42).
To add compatibility to older versions of setuptools-scm it seems we could try to import version
if importing __version__
fails. I also see in their docs they suggest using:
from importlib.metadata import version, PackageNotFoundError
try:
__version__ = version("package-name")
except PackageNotFoundError:
# package is not installed
pass
Feel free to have a look at https://github.com/holoviz/param/pull/903 :) We plan to release 2.0.2 soon, it's very likely it'll include this fix.
ALL software version info
Version: 2.0.1 Python 3.9 py39-hatch-vcs-0.4.0 py39-hatchling-1.20.0 FreeBSD 14.0
Description of expected behavior and the observed behavior
Complete, minimal, self-contained example code that reproduces the issue