Skip to content

Commit e4a05ab

Browse files
fixed __version__ + fixed bug with maturin pipeline due to change in PEP + add wheels for python 3.10,11
1 parent d3bc337 commit e4a05ab

File tree

6 files changed

+350
-160
lines changed

6 files changed

+350
-160
lines changed

.github/workflows/release-python.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: Build with maturin
3434
run: |
3535
python -m pip install --upgrade pip
36-
pip install maturin==1.1.0
36+
pip install --upgrade maturin==1.8.7
3737
maturin sdist --manifest-path Cargo.toml --out dist
3838
3939
@@ -65,8 +65,8 @@ jobs:
6565
matrix:
6666
os: [ubuntu-latest, macos-14, macos-latest, windows-latest]
6767
# os: [macos-14]
68-
python-version: ["3.9"] # , "3.10"
69-
# python-version: ["3.10"]
68+
python-version: ["3.9", "3.10", "3.11"] # , "3.10"
69+
7070
architecture: [x86_64, aarch64] # Explicitly define architectures
7171
# architecture: [aarch64] # Explicitly define architectures
7272
exclude:
@@ -98,7 +98,7 @@ jobs:
9898
- name: Create source distribution
9999
run: |
100100
python -m pip install --upgrade pip
101-
pip install maturin==1.1.0
101+
pip install --upgrade maturin==1.8.7
102102
maturin build --manifest-path Cargo.toml --profile dist-release --out target/wheels
103103
104104

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
[package]
22
name = "polodb_python" # Must match the Python package name
3-
version = "0.1.17"
3+
version = "0.1.18"
44
edition = "2021"
55
description = "Python bindings for PoloDB"
66
license = "Apache License"
7-
license-file = "LICENSE.txt"
7+
88
repository = "https://github.com/PoloDB/polodb-python"
99
homepage = "https://github.com/PoloDB/polodb-python"
1010
documentation = "https://github.com/PoloDB/polodb-python/blob/main/README.md"
11+
exclude = ["LICENSE.txt"]
1112

1213
[lib]
1314
# The name of the native library. This is the name which will be used in Python to import the

polodb/version.py

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,42 @@
1-
import tomli
2-
import os
1+
from __future__ import annotations
32

3+
try:
4+
from importlib.metadata import version, PackageNotFoundError
5+
except ImportError: # Python < 3.8 fallback
6+
from importlib_metadata import version, PackageNotFoundError
47

5-
def get_version():
6-
pyproject_path = os.path.join(os.path.dirname(__file__), "..", "pyproject.toml")
7-
with open(pyproject_path, "rb") as f:
8-
pyproject_data = tomli.load(f)
9-
return pyproject_data["project"]["version"] # Adjust if using a different tool
108

9+
def _detect_version() -> str:
10+
"""
11+
Return the installed version. Works in three situations:
1112
12-
__version__ = get_version()
13+
1. Normal wheel/sdist install → use .dist-info metadata
14+
2. Editable install (PEP 660) → metadata still available
15+
3. Plain source tree (no build) → fall back to pyproject.toml
16+
"""
17+
dist_name = "polodb-python" # *distribution* name, not module
18+
19+
# 1 & 2 — installed package: read from dist-info
20+
try:
21+
return version(dist_name)
22+
except PackageNotFoundError:
23+
pass
24+
25+
# 3 — running from a working copy: read pyproject.toml
26+
import pathlib, sys
27+
28+
# tomli is the back-port of tomllib for < 3.11
29+
if sys.version_info >= (3, 11):
30+
import tomllib
31+
else:
32+
import tomli as tomllib
33+
34+
root = pathlib.Path(__file__).resolve().parents[1]
35+
with (root / "pyproject.toml").open("rb") as f:
36+
data = tomllib.load(f)
37+
38+
return data["project"]["version"]
39+
40+
41+
__version__: str = _detect_version()
42+
del _detect_version, version, PackageNotFoundError

pyproject.toml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
[project]
22
name = "polodb-python"
3-
version = "0.1.17"
3+
version = "0.1.18"
44
description = "Add your description here"
55
readme = "README.md"
66
requires-python = ">=3.9"
7-
license = { file = "LICENSE.txt" }
87
authors = [
98
{ name = "SENHAJI RHAZI Hamza", email = "[email protected]" },
109
]
@@ -13,19 +12,22 @@ classifiers = [
1312
"Programming Language :: Python :: Implementation :: CPython",
1413
"Programming Language :: Python :: Implementation :: PyPy",
1514
]
16-
dependencies = ["tomli>=2.0.2"]
15+
dependencies = [
16+
"importlib-metadata>=8.7.0",
17+
"tomli>=2.2.1",
18+
]
1719

1820
[build-system]
19-
requires = ["maturin>=1,<2"]
21+
requires = ["maturin==1.8.7"]
2022
build-backend = "maturin"
2123

2224
[dependency-groups]
2325
dev = [
2426
"cibuildwheel>=2.21.3",
2527
"ipdb>=0.13.13",
2628
"ipython>=8.18.1",
27-
"maturin>=1.7.4",
28-
"pip>=24.3.1",
29+
"maturin>=1.9.0",
30+
"pip>=25.1.1",
2931
"pytest>=8.3.3",
3032
"wheel>=0.44.0",
3133
]
@@ -40,6 +42,5 @@ polodb = { workspace = true }
4042
pythonpath = ["."]
4143

4244
[tool.maturin]
43-
include = ["polodb/**/*"]
44-
sdist-include = ["Cargo.toml", "README.md", "LICENSE.txt"]
45+
include = ["polodb/**/*", "LICENSE.txt"]
4546

0 commit comments

Comments
 (0)