You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Trying to access the _version attribute fails since the VERSION file isn't included in the package.
I found this when coming up with a workaround for #244 since I was using runpy to run the files and ensure they are importable.
To reproduce
A clear, step-by-step set of instructions to reproduce the bug.
The provided code need to be complete and runnable, if additional data is needed, please include them in the issue.
$ python -c 'import sagemaker_core._version'
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ in <module>:1 │
│ │
│\venv\Lib\site-pack │
│ ages\sagemaker_core\_version.py:10 in <module> │
│ │
│ 7 │
│ 8 version_file_path = os.path.join(root_dir, "VERSION") │
│ 9 │
│ ❱ 10 with open(version_file_path) as version_file: │
│ 11 │ __version__ = version_file.read().strip() │
│ 12 │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
FileNotFoundError: [Errno 2] No such file or directory:
\\venv\\Lib\\VERSION'
Expected behavior
The VERSION file should be included with the distribution.
Simplest solution would be to make it dynamic and fetch the version with importlib.metadata at runtime. I'll submit a PR for this.
pyproject.toml: Setuptools will make sure this file is included with no extra config needed.
[tool.setuptools.dynamic]
version = {file = ["VERSION"]}
The __version__ can now be accessed at runtime.
Tested with the following. We can see the version being copied by build.
It also shows up in the sdist.
```bash
python -m pip install build
python -m build
tar -xzf ./dist/sagemaker_core-1.0.24.tar.gz
ls -l sagemaker_core-1.0.24
total 31
-rw-r--r-- 1 RM13 1049089 11558 Feb 12 16:54 LICENSE
-rw-r--r-- 1 RM13 1049089 15 Feb 12 16:54 MANIFEST.in
-rw-r--r-- 1 RM13 1049089 4945 Feb 24 13:57 PKG-INFO
-rw-r--r-- 1 RM13 1049089 1441 Feb 24 13:54 pyproject.toml
-rw-r--r-- 1 RM13 1049089 3647 Feb 12 16:54 README.rst
-rw-r--r-- 1 RM13 1049089 133 Feb 24 13:57 setup.cfg
drwxr-xr-x 1 RM13 1049089 0 Feb 24 13:57 src/
-rw-r--r-- 1 RM13 1049089 6 Feb 24 13:53 VERSION
```
Closesaws#248
Describe the bug
Trying to access the
_version
attribute fails since the VERSION file isn't included in the package.I found this when coming up with a workaround for #244 since I was using runpy to run the files and ensure they are importable.
To reproduce
A clear, step-by-step set of instructions to reproduce the bug.
The provided code need to be complete and runnable, if additional data is needed, please include them in the issue.
Expected behavior
The VERSION file should be included with the distribution.
Simplest solution would be to make it dynamic and fetch the version with importlib.metadata at runtime. I'll submit a PR for this.
pyproject.toml
: Setuptools will make sure this file is included with no extra config needed._version.py
Another alternative would be using
package_data
. This is not as clean though.pyproject.toml
And the version could be gotten by using importlib.resources.files: https://docs.python.org/3/library/importlib.resources.html#importlib.resources.files
Screenshots or logs
If applicable, add screenshots or logs to help explain your problem.
Bug information
A description of your system. Please provide:
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: