Skip to content

Commit 7eff259

Browse files
Merge pull request #20 from sqliteai/add-license-and-upgrade-build-flow
chore(python): upgrade flow to python -m build
2 parents 2539b1f + 4790f8d commit 7eff259

File tree

9 files changed

+81
-67
lines changed

9 files changed

+81
-67
lines changed

.github/workflows/python-package.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,10 @@ jobs:
9191
- name: Build wheel
9292
env:
9393
PACKAGE_VERSION: ${{ steps.get_version.outputs.version }}
94+
PLAT_NAME: ${{ matrix.plat_name }}
9495
run: |
9596
cd packages/python
96-
python setup.py bdist_wheel --plat-name "${{ matrix.plat_name }}"
97+
python -m build --wheel
9798
9899
- name: Publish to PyPI
99100
uses: pypa/gh-action-pypi-publish@release/v1
@@ -103,4 +104,4 @@ jobs:
103104
# Avoid workflow to fail if the version has already been published
104105
skip-existing: true
105106
# Upload to Test Pypi for testing
106-
# repository-url: https://test.pypi.org/legacy/
107+
#repository-url: https://test.pypi.org/legacy/

packages/python/LICENSE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../LICENSE.md

packages/python/MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
include README.md
2-
include LICENSE
2+
include LICENSE.md
33
recursive-include src/sqlite-vector/binaries *

packages/python/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ conn = sqlite3.connect("example.db")
3434

3535
# Load the sqlite-vector extension
3636
# pip will install the correct binary package for your platform and architecture
37-
ext_path = importlib.resources.files("sqlite-vector.binaries") / "vector"
37+
ext_path = importlib.resources.files("sqlite_vector.binaries") / "vector"
3838

3939
conn.enable_load_extension(True)
4040
conn.load_extension(str(ext_path))

packages/python/pyproject.toml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
11
[build-system]
2-
requires = ["setuptools>=61.0", "wheel", "toml"]
2+
requires = ["setuptools>=61.0", "build", "wheel"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "sqliteai-vector"
7-
dynamic = ["version"]
7+
dynamic = ["version", "classifiers"]
88
description = "Python prebuilt binaries for SQLite Vector extension for all supported platforms and architectures."
99
authors = [
1010
{ name = "SQLite AI Team" }
1111
]
1212
readme = "README.md"
13+
license = "LicenseRef-Elastic-2.0-Modified-For-Open-Source-Use"
14+
license-files = ["LICENSE.md"]
1315
requires-python = ">=3"
14-
classifiers = [
15-
"Programming Language :: Python :: 3",
16-
"Operating System :: POSIX :: Linux",
17-
"Operating System :: Microsoft :: Windows",
18-
"Operating System :: MacOS :: MacOS X"
19-
]
2016

2117
[project.urls]
2218
Homepage = "https://sqlite.ai"
2319
Documentation = "https://github.com/sqliteai/sqlite-vector/blob/main/API.md"
2420
Repository = "https://github.com/sqliteai/sqlite-vector"
2521
Issues = "https://github.com/sqliteai/sqlite-vector/issues"
22+
23+
[tool.setuptools]
24+
packages = {find = {where = ["src"]}}
25+
include-package-data = true
26+
27+
[tool.setuptools.dynamic]
28+
version = {attr = "sqlite_vector._version.__version__"}
29+
30+
[tool.bdist_wheel]
31+
# Force platform-specific wheels
32+
universal = false
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
requests
2-
toml
3-
wheel
2+
wheel
3+
build

packages/python/setup.py

Lines changed: 55 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,56 @@
1-
import setuptools
2-
import toml
31
import os
4-
import sys
5-
6-
usage = """
7-
Usage: python setup.py bdist_wheel --plat-name <platform>
8-
The PACKAGE_VERSION environment variable must be set to the desired version.
9-
10-
Example:
11-
PACKAGE_VERSION=0.5.9 python setup.py bdist_wheel --plat-name linux_x86_64
12-
"""
13-
14-
with open("pyproject.toml", "r") as f:
15-
pyproject = toml.load(f)
16-
17-
project = pyproject["project"]
18-
19-
# Get version from environment or default
20-
version = os.environ.get("PACKAGE_VERSION", "")
21-
if not version:
22-
print("PACKAGE_VERSION environment variable is not set.")
23-
print(usage)
24-
sys.exit(1)
25-
26-
# Get Python platform name from --plat-name argument
27-
plat_name = None
28-
for i, arg in enumerate(sys.argv):
29-
if arg == "--plat-name" and i + 1 < len(sys.argv):
30-
plat_name = sys.argv[i + 1]
31-
break
32-
33-
if not plat_name:
34-
print("Error: --plat-name argument is required")
35-
print(usage)
36-
sys.exit(1)
37-
38-
with open("README.md", "r", encoding="utf-8") as f:
39-
long_description = f.read()
40-
41-
setuptools.setup(
42-
name=project["name"],
43-
version=version,
44-
description=project.get("description", ""),
45-
author=project["authors"][0]["name"],
46-
long_description=long_description,
47-
long_description_content_type="text/markdown",
48-
url=project["urls"]["Homepage"],
49-
packages=setuptools.find_packages(where="src"),
50-
package_dir={"": "src"},
51-
include_package_data=True,
52-
python_requires=project.get("requires-python", ">=3"),
53-
classifiers=project.get("classifiers", []),
54-
)
2+
from setuptools import setup
3+
from setuptools.command.bdist_wheel import bdist_wheel
4+
5+
6+
class PlatformSpecificWheel(bdist_wheel):
7+
"""Custom bdist_wheel to force platform-specific wheel."""
8+
9+
def finalize_options(self):
10+
bdist_wheel.finalize_options(self)
11+
# Force platform-specific wheel
12+
self.root_is_pure = False
13+
14+
# Set platform name from environment if provided
15+
plat_name = os.environ.get("PLAT_NAME")
16+
if plat_name:
17+
self.plat_name = plat_name
18+
19+
def get_tag(self):
20+
# Force platform-specific tags with broader compatibility
21+
python_tag, abi_tag, platform_tag = bdist_wheel.get_tag(self)
22+
23+
# Override platform tag if specified
24+
plat_name = os.environ.get("PLAT_NAME")
25+
if plat_name:
26+
platform_tag = plat_name
27+
28+
# Use py3 for broader Python compatibility since we have pre-built binaries
29+
python_tag = "py3"
30+
abi_tag = "none"
31+
32+
return python_tag, abi_tag, platform_tag
33+
34+
35+
def get_platform_classifiers():
36+
"""Get platform-specific classifiers based on PLAT_NAME environment variable."""
37+
classifier_map = {
38+
"manylinux2014_x86_64": ["Operating System :: POSIX :: Linux"],
39+
"manylinux2014_aarch64": ["Operating System :: POSIX :: Linux"],
40+
"win_amd64": ["Operating System :: Microsoft :: Windows"],
41+
"macosx_10_9_x86_64": ["Operating System :: MacOS"],
42+
"macosx_11_0_arm64": ["Operating System :: MacOS"],
43+
}
44+
45+
plat_name = os.environ.get("PLAT_NAME")
46+
if plat_name and plat_name in classifier_map:
47+
return ["Programming Language :: Python :: 3", classifier_map[plat_name][0]]
48+
49+
raise ValueError(f"Unsupported or missing PLAT_NAME: {plat_name}")
50+
51+
52+
if __name__ == "__main__":
53+
setup(
54+
cmdclass={"bdist_wheel": PlatformSpecificWheel},
55+
classifiers=get_platform_classifiers(),
56+
)
File renamed without changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import os
2+
3+
__version__ = os.environ.get("PACKAGE_VERSION", "0.0.0")

0 commit comments

Comments
 (0)