Skip to content

Commit 6066581

Browse files
committed
build: extract the lib version dynamically
The `pkg-resources` dependency is removed from `setuptools`. The version is now extracted via `setuptools-scm`. To get the version, feature detection should be used instead of `__version__`: ``` importlib.metadata.version("apispec_fromfile") ```
1 parent e2c7527 commit 6066581

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ def hello():
5858
spec.path("/hello", resource=hello)
5959
```
6060

61+
To get the version of the library, use feature detection:
62+
63+
```python
64+
from importlib.metadata
65+
66+
importlib.metadata.version("apispec_fromfile")
67+
```
68+
6169
# Related links
6270

6371
* Contribute: https://github.com/ovh/python-apispec-fromfile/blob/master/CONTRIBUTING.md

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[project]
22
name = "apispec-fromfile"
3-
version = "1.0.3"
43
authors = [
54
{ name = "OVHcloud", email = "opensource@ovhcloud.com" },
65
]
@@ -12,6 +11,7 @@ requires-python = ">=3.10"
1211
dependencies = [
1312
"apispec[yaml]>=6.9.0",
1413
]
14+
dynamic = ["version"]
1515
keywords = ["openapi", "apispec"]
1616
classifiers = [
1717
"Environment :: Plugins",
@@ -33,7 +33,7 @@ classifiers = [
3333
Repository = "https://github.com/ovh/python-apispec-fromfile"
3434

3535
[build-system]
36-
requires = ["setuptools>=77.0.3"]
36+
requires = ["setuptools>=80", "setuptools-scm[simple]>=9.2"]
3737
build-backend = "setuptools.build_meta"
3838

3939
[tool.ruff]

src/apispec_fromfile/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
import pkg_resources
2-
31
from .plugin import FromFilePlugin
42
from .plugin import from_file
53

64

7-
__version__ = str(pkg_resources.get_distribution("apispec-fromfile").parsed_version)
8-
95
__all__ = [
106
"FromFilePlugin",
117
"from_file",

tox.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ envlist =
66
[testenv]
77
deps =
88
pytest
9-
setuptools<82
109
commands =
1110
pytest {posargs} tests
1211

0 commit comments

Comments
 (0)