diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-09-01 18:21:57 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-09-01 19:13:40 +0100 |
| commit | 53b4c25087aa1b62f1bf3c5feace21c28f529418 (patch) | |
| tree | 9dbb4a714ff8057064d45252261b25621026cbd4 | |
| parent | c2c7ed1f25b51947ebb690f6b8464c78fe83bb2b (diff) | |
Add environment variable for using system libjq and libonig
| -rw-r--r-- | .github/workflows/build.yml | 15 | ||||
| -rw-r--r-- | CHANGELOG.rst | 8 | ||||
| -rw-r--r-- | README.rst | 5 | ||||
| -rw-r--r-- | setup.py | 25 | ||||
| -rw-r--r-- | tox.ini | 1 |
5 files changed, 47 insertions, 7 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8f5f70a..563a18c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,6 +10,11 @@ jobs: matrix: os: [ubuntu-20.04, macos-11] python-version: [3.5, 3.6, 3.7, 3.8, 3.9, "3.10", "3.11", "3.12-dev", "pypy-3.7"] + use-system-libs: [false] + include: + - os: ubuntu-20.04 + python-version: "3.11" + use-system-libs: true steps: @@ -25,6 +30,16 @@ jobs: - run: "make jq.c" - run: tox -e py + if: ${{ !matrix.use-system-libs }} + + - run: | + # Remove deps to make sure they're not being used + rm -r deps + + sudo apt-get install -y libjq-dev libonig-dev + + JQPY_USE_SYSTEM_LIBS=1 tox -e py + if: ${{ matrix.use-system-libs }} build_sdist: name: Build source distribution diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 76dbe09..13877aa 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,14 @@ Changelog ========= +1.6.0 +----- + +* Add support for building with Cython 3. + +* Add support for building with the system libjq and libonig instead of building + using the bundled source. + 1.5.0 ----- @@ -15,7 +15,7 @@ On these platforms, you should be able to install jq with a normal pip install: pip install jq If a wheel is not available, -the source for jq 1.6 is downloaded over HTTPS and built. +the source for jq 1.6 is built. This requires: * Autoreconf @@ -26,6 +26,9 @@ This requires: * Python headers. +Alternatively, set the environment variable ``JQPY_USE_SYSTEM_LIBS`` to ``1`` when installing the package +to use the libjq and libonig versions available on the system rather than building them. + Debian, Ubuntu or relatives ~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -32,7 +32,7 @@ oniguruma_lib_tarball_path = _dep_source_path("onig-{}.tar.gz".format(oniguruma_ oniguruma_lib_build_dir = _dep_build_path("onig-{}".format(oniguruma_version)) oniguruma_lib_install_dir = _dep_build_path("onig-install-{}".format(oniguruma_version)) -class jq_build_ext(build_ext): +class jq_with_deps_build_ext(build_ext): def run(self): if not os.path.exists(_dep_build_path(".")): os.makedirs(_dep_build_path(".")) @@ -83,15 +83,28 @@ class jq_build_ext(build_ext): tarfile.open(tarball_path, "r:gz").extractall(_dep_build_path(".")) +use_system_libs = bool(os.environ.get("JQPY_USE_SYSTEM_LIBS")) + + +if use_system_libs: + jq_build_ext = build_ext + link_args_deps = ["-ljq", "-lonig"] + extra_objects = [] +else: + jq_build_ext = jq_with_deps_build_ext + link_args_deps = [] + extra_objects = [ + os.path.join(jq_lib_dir, ".libs/libjq.a"), + os.path.join(oniguruma_lib_install_dir, "lib/libonig.a"), + ] + + jq_extension = Extension( "jq", sources=["jq.c"], include_dirs=[os.path.join(jq_lib_dir, "src")], - extra_link_args=["-lm"], - extra_objects=[ - os.path.join(jq_lib_dir, ".libs/libjq.a"), - os.path.join(oniguruma_lib_install_dir, "lib/libonig.a"), - ], + extra_link_args=["-lm"] + link_args_deps, + extra_objects=extra_objects, ) setup( @@ -6,6 +6,7 @@ changedir = {envtmpdir} deps=-r{toxinidir}/test-requirements.txt commands= py.test {toxinidir}/tests +passenv = JQPY_USE_SYSTEM_LIBS [pytest] python_files = *_tests.py |
