summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2025-03-09 11:02:26 +0000
committerMichael Williamson <mike@zwobble.org>2025-03-09 11:17:50 +0000
commite646b6470312adf7b183a10cfdbf7095d2499421 (patch)
tree8c41d4656ed2e2ce39364c8d01808c38e80073cd
parent99599e79b82516f029b5809ccfe50bba994f1d83 (diff)
Include jq.pyx instead of jq.c
-rw-r--r--.github/workflows/build.yml4
-rw-r--r--CHANGELOG.rst2
-rw-r--r--MANIFEST.in2
-rw-r--r--makefile8
-rw-r--r--pyproject.toml5
-rw-r--r--setup.py5
6 files changed, 10 insertions, 16 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 96e75b5..51e7a63 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -27,8 +27,6 @@ jobs:
- run: pip install tox virtualenv
- - run: "make jq.c"
-
- run: tox -e py
if: ${{ !matrix.use-system-libs }}
@@ -52,8 +50,6 @@ jobs:
with:
python-version: '3.11'
- - run: make jq.c
-
- run: pip install build twine
- name: Build sdist
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 277c160..7aa6186 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -6,6 +6,8 @@ Changelog
* Drop support for Python 3.6
+* Distribute Cython sources instead of C sources to improve compatibility.
+
1.8.0
-----
diff --git a/MANIFEST.in b/MANIFEST.in
index 929b9b3..560151a 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -3,3 +3,5 @@ include LICENSE
include deps/*.tar.gz
recursive-include tests *.py
include tox.ini
+include jq.pyx
+exclude *.c
diff --git a/makefile b/makefile
index 865029d..1d08b2e 100644
--- a/makefile
+++ b/makefile
@@ -3,7 +3,7 @@
test: bootstrap
_virtualenv/bin/py.test tests
-upload: jq.c
+upload:
python setup.py sdist upload
make clean
@@ -14,7 +14,7 @@ clean:
rm -f MANIFEST
rm -rf dist
-bootstrap: _virtualenv jq.c
+bootstrap: _virtualenv
_virtualenv/bin/pip install -e .
ifneq ($(wildcard test-requirements.txt),)
_virtualenv/bin/pip install -r test-requirements.txt
@@ -26,7 +26,3 @@ _virtualenv:
_virtualenv/bin/pip install --upgrade pip
_virtualenv/bin/pip install --upgrade setuptools
_virtualenv/bin/pip install --upgrade wheel
-
-jq.c: _virtualenv jq.pyx
- _virtualenv/bin/pip install cython==3.0.10
- _virtualenv/bin/cython jq.pyx
diff --git a/pyproject.toml b/pyproject.toml
index c94c102..74df2b9 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,14 +1,11 @@
[build-system]
requires = [
+ "cython==3.0.10",
"setuptools>=43",
"wheel",
]
build-backend = "setuptools.build_meta"
[tool.cibuildwheel]
-before-build = [
- "pip install cython==3.0.10",
- "cython {project}/jq.pyx",
-]
test-requires = "-r test-requirements.txt"
test-command = "pytest {project}/tests"
diff --git a/setup.py b/setup.py
index 353f2db..19bdcb4 100644
--- a/setup.py
+++ b/setup.py
@@ -8,6 +8,7 @@ import sys
import sysconfig
import tarfile
+from Cython.Build import cythonize
from setuptools import setup
from setuptools.command.build_ext import build_ext
from setuptools.extension import Extension
@@ -96,7 +97,7 @@ else:
jq_extension = Extension(
"jq",
- sources=["jq.c"],
+ sources=["jq.pyx"],
define_macros=[("MS_WIN64" , 1)] if os.name == "nt" and sys.maxsize > 2**32 else None, # https://github.com/cython/cython/issues/2670
include_dirs=[os.path.join(jq_lib_dir, "src")],
extra_link_args=["-lm"] + (["-Wl,-Bstatic", "-lpthread", "-lshlwapi", "-static-libgcc"] if os.name == 'nt' else []) + link_args_deps,
@@ -112,7 +113,7 @@ setup(
url='https://github.com/mwilliamson/jq.py',
python_requires='>=3.7',
license='BSD 2-Clause',
- ext_modules = [jq_extension],
+ ext_modules = cythonize([jq_extension]),
cmdclass={"build_ext": jq_build_ext},
classifiers=[
'Development Status :: 5 - Production/Stable',