Skip to content

Commit b5b5d62

Browse files
committed
Fix(sqlglotc): pin sqlglot to the exact matching version
1 parent 74bef2f commit b5b5d62

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

sqlglotc/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "sqlglotc"
3-
dynamic = ["version"]
3+
dynamic = ["version", "dependencies"]
44
description = "mypyc-compiled extensions for sqlglot"
55
authors = [{ name = "Toby Mao", email = "toby.mao@gmail.com" }]
66
license = "MIT"

sqlglotc/setup.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,28 @@ def run(self):
128128
shutil.rmtree(local_sqlglot, ignore_errors=True)
129129

130130

131+
def _sqlglot_requirement():
132+
"""Pin sqlglot to the matching version so resolvers keep the two packages in lockstep."""
133+
pkg_info = os.path.join(os.path.dirname(os.path.abspath(__file__)), "PKG-INFO")
134+
if os.path.isfile(pkg_info):
135+
# Building from an sdist: no git metadata; the released version is frozen in PKG-INFO.
136+
with open(pkg_info, encoding="utf-8") as fd:
137+
version = next(
138+
(line.split(":", 1)[1].strip() for line in fd if line.startswith("Version:")), ""
139+
)
140+
else:
141+
from setuptools_scm import get_version
142+
143+
version = get_version(root="..", relative_to=__file__, local_scheme="no-local-version")
144+
145+
# Dev builds have no matching sqlglot release on PyPI, so skip the pin.
146+
return [] if not version or ".dev" in version else [f"sqlglot=={version}"]
147+
148+
131149
setup(
132150
name="sqlglotc",
133151
packages=[],
152+
install_requires=_sqlglot_requirement(),
134153
ext_modules=mypycify(
135154
_source_paths(), opt_level=os.environ.get("MYPYC_OPT", "2"), separate=True, verbose=True
136155
),

0 commit comments

Comments
 (0)