Skip to content

Commit 30cbaf9

Browse files
tobymaoclaude
andauthored
build: speed up CI and dev builds (#7303)
* build: speed up CI and dev builds - Parallelize CI wheel builds (1 job per python version × platform) - Skip musllinux wheels (users fall back to optimized sdist) - Default MYPYC_OPT to 3 so pip/sdist installs are optimized - Use setup.py build_ext --inplace for faster dev builds (42s vs 100s) - Replace stock mypy with sqlglot-mypy fork in dev deps Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: copy mypyc runtime .so to sqlglot/ for install-devc The setup.py build_ext --inplace path places the main mypyc runtime .so in sqlglotc/, but shim .so files in sqlglot/ need to import it. Copy it to sqlglot/ so Python can find it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: place mypyc runtime .so in repo root for install-devc The mypyc runtime .so must be on sys.path for the shim .so files to import it. Place it in the repo root (parent of sqlglot/) which is always on sys.path. Also update hidec/showc/clean to handle it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: remove unused build_py variable Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * refactor: extract FIND_SO variable in Makefile Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: use site-packages exclusion for venv-safe .so discovery Excludes any venv regardless of directory name (.env, .venv, etc.) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 23e604c commit 30cbaf9

4 files changed

Lines changed: 21 additions & 22 deletions

File tree

.github/workflows/package-publish.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ permissions:
1111
jobs:
1212
# Build mypyc wheels for each platform and Python version.
1313
build-wheels:
14-
name: Build wheels (${{ matrix.os }}, ${{ matrix.archs }})
15-
runs-on: ${{ matrix.os }}
14+
name: Build wheels (${{ matrix.platform.os }}, ${{ matrix.platform.archs }}, ${{ matrix.python }})
15+
runs-on: ${{ matrix.platform.os }}
1616
strategy:
1717
matrix:
18-
include:
18+
python: ["cp39", "cp310", "cp311", "cp312", "cp313", "cp314"]
19+
platform:
1920
- os: ubuntu-latest
2021
archs: x86_64
2122
- os: ubuntu-24.04-arm
@@ -33,12 +34,13 @@ jobs:
3334
package-dir: sqlglotc
3435
output-dir: wheelhouse
3536
env:
36-
CIBW_BUILD: cp39-* cp310-* cp311-* cp312-* cp313-* cp314-*
37-
CIBW_ARCHS: ${{ matrix.archs }}
37+
CIBW_BUILD: ${{ matrix.python }}-*
38+
CIBW_SKIP: "*-musllinux_*"
39+
CIBW_ARCHS: ${{ matrix.platform.archs }}
3840
CIBW_ENVIRONMENT: MYPYC_OPT=3
3941
- uses: actions/upload-artifact@v4
4042
with:
41-
name: wheels-${{ matrix.os }}-${{ matrix.archs }}
43+
name: wheels-${{ matrix.platform.os }}-${{ matrix.platform.archs }}-${{ matrix.python }}
4244
path: ./wheelhouse/*.whl
4345

4446
# Build the sqlglotc sdist (source-only, no wheels — always compiles on install).

Makefile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ else
77
endif
88

99
SO_BACKUP := /tmp/sqlglot_so_backup
10+
FIND_SO := find . -name "*.so" -not -path "*/build/*" -not -path "*/site-packages/*"
1011

1112
hidec:
12-
rm -rf $(SO_BACKUP) && find sqlglot sqlglotc -name "*.so" | tar cf $(SO_BACKUP) -T - 2>/dev/null && find sqlglot sqlglotc -name "*.so" -delete; true
13+
rm -rf $(SO_BACKUP) && $(FIND_SO) | tar cf $(SO_BACKUP) -T - 2>/dev/null && $(FIND_SO) -delete; true
1314

1415
showc:
1516
tar xf $(SO_BACKUP) 2>/dev/null; rm -f $(SO_BACKUP); true
1617

1718
clean:
1819
rm -rf build sqlglotc/build sqlglotc/dist sqlglotc/*.egg-info sqlglotc/sqlglot
19-
find sqlglot sqlglotc build -name "*.so" -delete 2>/dev/null; true
20+
$(FIND_SO) -delete 2>/dev/null; true
2021

2122
install:
2223
$(PIP) install -e .
@@ -36,11 +37,11 @@ install-dev:
3637
fi; \
3738
fi
3839

39-
install-devc: clean
40-
cd sqlglotc && $(PIP) install -e .
40+
install-devc:
41+
cd sqlglotc && MYPYC_OPT=0 python setup.py build_ext --inplace
4142

4243
install-devc-release: clean
43-
MYPYC_OPT=3 $(MAKE) install-devc
44+
cd sqlglotc && $(PIP) install -e .
4445

4546
install-pre-commit:
4647
pre-commit install

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
extras_require={
55
"dev": [
66
"duckdb>=0.6",
7-
"mypy",
7+
"sqlglot-mypy>=1.19.1.post1",
8+
"setuptools_scm",
89
"pandas",
910
"pandas-stubs",
1011
"python-dateutil",

sqlglotc/setup.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ def _source_paths():
5858
class build_ext(_build_ext):
5959
def copy_extensions_to_source(self):
6060
"""For editable installs, put sqlglot.* .so files in the sqlglot source dir."""
61-
build_py = self.get_finalized_command("build_py")
6261
for ext in self.extensions:
6362
fullname = self.get_ext_fullname(ext.name)
6463
filename = self.get_ext_filename(fullname)
@@ -69,14 +68,10 @@ def copy_extensions_to_source(self):
6968
sub_module = ".".join(parts[1:])
7069
dst = os.path.join(sqlglot_src, self.get_ext_filename(sub_module))
7170
else:
72-
# Default: mypyc runtime helper (e.g., HASH__mypyc) goes in current dir.
73-
package = ".".join(parts[:-1])
74-
package_dir = build_py.get_package_dir(package)
75-
dst = (
76-
os.path.join(package_dir, os.path.basename(filename))
77-
if package_dir
78-
else os.path.basename(filename)
79-
)
71+
# Place the mypyc runtime helper (e.g., HASH__mypyc) in the repo root
72+
# so it is importable (must be on sys.path, not inside a package).
73+
repo_root = os.path.dirname(sqlglot_src) if os.path.isdir(sqlglot_src) else here
74+
dst = os.path.join(repo_root, os.path.basename(filename))
8075
self.copy_file(src, dst, level=self.verbose)
8176

8277

@@ -105,6 +100,6 @@ def run(self):
105100
setup(
106101
name="sqlglotc",
107102
packages=[],
108-
ext_modules=mypycify(_source_paths(), opt_level=os.environ.get("MYPYC_OPT", "0")),
103+
ext_modules=mypycify(_source_paths(), opt_level=os.environ.get("MYPYC_OPT", "3")),
109104
cmdclass={"build_ext": build_ext, "sdist": sdist},
110105
)

0 commit comments

Comments
 (0)