Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ jobs:
- name: Build wheel
env:
PACKAGE_VERSION: ${{ steps.get_version.outputs.version }}
PLAT_NAME: ${{ matrix.plat_name }}
run: |
cd packages/python
python setup.py bdist_wheel --plat-name "${{ matrix.plat_name }}"
python -m build --wheel

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Expand All @@ -103,4 +104,4 @@ jobs:
# Avoid workflow to fail if the version has already been published
skip-existing: true
# Upload to Test Pypi for testing
# repository-url: https://test.pypi.org/legacy/
#repository-url: https://test.pypi.org/legacy/
1 change: 1 addition & 0 deletions packages/python/LICENSE.md
2 changes: 1 addition & 1 deletion packages/python/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include README.md
include LICENSE
include LICENSE.md
recursive-include src/sqlite-vector/binaries *
2 changes: 1 addition & 1 deletion packages/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ conn = sqlite3.connect("example.db")

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

conn.enable_load_extension(True)
conn.load_extension(str(ext_path))
Expand Down
23 changes: 15 additions & 8 deletions packages/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
[build-system]
requires = ["setuptools>=61.0", "wheel", "toml"]
requires = ["setuptools>=61.0", "build", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "sqliteai-vector"
dynamic = ["version"]
dynamic = ["version", "classifiers"]
description = "Python prebuilt binaries for SQLite Vector extension for all supported platforms and architectures."
authors = [
{ name = "SQLite AI Team" }
]
readme = "README.md"
license = "LicenseRef-Elastic-2.0-Modified-For-Open-Source-Use"
license-files = ["LICENSE.md"]
requires-python = ">=3"
classifiers = [
"Programming Language :: Python :: 3",
"Operating System :: POSIX :: Linux",
"Operating System :: Microsoft :: Windows",
"Operating System :: MacOS :: MacOS X"
]

[project.urls]
Homepage = "https://sqlite.ai"
Documentation = "https://github.com/sqliteai/sqlite-vector/blob/main/API.md"
Repository = "https://github.com/sqliteai/sqlite-vector"
Issues = "https://github.com/sqliteai/sqlite-vector/issues"

[tool.setuptools]
packages = {find = {where = ["src"]}}
include-package-data = true

[tool.setuptools.dynamic]
version = {attr = "sqlite_vector._version.__version__"}

[tool.bdist_wheel]
# Force platform-specific wheels
universal = false
4 changes: 2 additions & 2 deletions packages/python/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
requests
toml
wheel
wheel
build
108 changes: 55 additions & 53 deletions packages/python/setup.py
Original file line number Diff line number Diff line change
@@ -1,54 +1,56 @@
import setuptools
import toml
import os
import sys

usage = """
Usage: python setup.py bdist_wheel --plat-name <platform>
The PACKAGE_VERSION environment variable must be set to the desired version.

Example:
PACKAGE_VERSION=0.5.9 python setup.py bdist_wheel --plat-name linux_x86_64
"""

with open("pyproject.toml", "r") as f:
pyproject = toml.load(f)

project = pyproject["project"]

# Get version from environment or default
version = os.environ.get("PACKAGE_VERSION", "")
if not version:
print("PACKAGE_VERSION environment variable is not set.")
print(usage)
sys.exit(1)

# Get Python platform name from --plat-name argument
plat_name = None
for i, arg in enumerate(sys.argv):
if arg == "--plat-name" and i + 1 < len(sys.argv):
plat_name = sys.argv[i + 1]
break

if not plat_name:
print("Error: --plat-name argument is required")
print(usage)
sys.exit(1)

with open("README.md", "r", encoding="utf-8") as f:
long_description = f.read()

setuptools.setup(
name=project["name"],
version=version,
description=project.get("description", ""),
author=project["authors"][0]["name"],
long_description=long_description,
long_description_content_type="text/markdown",
url=project["urls"]["Homepage"],
packages=setuptools.find_packages(where="src"),
package_dir={"": "src"},
include_package_data=True,
python_requires=project.get("requires-python", ">=3"),
classifiers=project.get("classifiers", []),
)
from setuptools import setup
from setuptools.command.bdist_wheel import bdist_wheel


class PlatformSpecificWheel(bdist_wheel):
"""Custom bdist_wheel to force platform-specific wheel."""

def finalize_options(self):
bdist_wheel.finalize_options(self)
# Force platform-specific wheel
self.root_is_pure = False

# Set platform name from environment if provided
plat_name = os.environ.get("PLAT_NAME")
if plat_name:
self.plat_name = plat_name

def get_tag(self):
# Force platform-specific tags with broader compatibility
python_tag, abi_tag, platform_tag = bdist_wheel.get_tag(self)

# Override platform tag if specified
plat_name = os.environ.get("PLAT_NAME")
if plat_name:
platform_tag = plat_name

# Use py3 for broader Python compatibility since we have pre-built binaries
python_tag = "py3"
abi_tag = "none"

return python_tag, abi_tag, platform_tag


def get_platform_classifiers():
"""Get platform-specific classifiers based on PLAT_NAME environment variable."""
classifier_map = {
"manylinux2014_x86_64": ["Operating System :: POSIX :: Linux"],
"manylinux2014_aarch64": ["Operating System :: POSIX :: Linux"],
"win_amd64": ["Operating System :: Microsoft :: Windows"],
"macosx_10_9_x86_64": ["Operating System :: MacOS"],
"macosx_11_0_arm64": ["Operating System :: MacOS"],
}

plat_name = os.environ.get("PLAT_NAME")
if plat_name and plat_name in classifier_map:
return ["Programming Language :: Python :: 3", classifier_map[plat_name][0]]

raise ValueError(f"Unsupported or missing PLAT_NAME: {plat_name}")


if __name__ == "__main__":
setup(
cmdclass={"bdist_wheel": PlatformSpecificWheel},
classifiers=get_platform_classifiers(),
)
3 changes: 3 additions & 0 deletions packages/python/src/sqlite_vector/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import os

__version__ = os.environ.get("PACKAGE_VERSION", "0.0.0")