diff --git a/.github/workflows/build_dist.yml b/.github/workflows/build_dist.yml index 2c93cdd..6fd9b2f 100644 --- a/.github/workflows/build_dist.yml +++ b/.github/workflows/build_dist.yml @@ -53,6 +53,7 @@ jobs: - name: Build wheels uses: pypa/cibuildwheel@v2.11.4 env: + CIBW_ENVIRONMENT: PYLZ4_USE_SYSTEM_LZ4="False" CIBW_ARCHS_LINUX: "x86_64 i686 aarch64" CIBW_ARCHS_MACOS: "x86_64 arm64" # universal2" CIBW_ARCHS_WINDOWS: "AMD64 x86" diff --git a/README.rst b/README.rst index 15ba444..a75bc4d 100644 --- a/README.rst +++ b/README.rst @@ -5,14 +5,10 @@ python-lz4 Status ====== -.. image:: https://travis-ci.org/python-lz4/python-lz4.svg?branch=master - :target: https://travis-ci.org/python-lz4/python-lz4 +.. image:: https://github.com/python-lz4/python-lz4/actions/workflows/build_dist.yml/badge.svg + :target: https://github.com/python-lz4/python-lz4/actions/workflows/build_dist.yml :alt: Build Status -.. image:: https://ci.appveyor.com/api/projects/status/r2qvw9mlfo63lklo/branch/master?svg=true - :target: https://ci.appveyor.com/project/jonathanunderwood/python-lz4 - :alt: Build Status Windows - .. image:: https://readthedocs.org/projects/python-lz4/badge/?version=stable :target: https://readthedocs.org/projects/python-lz4/ :alt: Documentation diff --git a/setup.py b/setup.py index 2f2704f..387f5c8 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,9 @@ #!/usr/bin/env python import os from setuptools import setup, find_packages, Extension +from setuptools.command.build_ext import new_compiler import sys -from distutils import ccompiler + # Note: if updating LZ4_REQUIRED_VERSION you need to update docs/install.rst as # well. @@ -35,12 +36,11 @@ def pkgconfig_installed_check(lib, required_version, default): liblz4_found = pkgconfig_installed_check('liblz4', LZ4_REQUIRED_VERSION, default=False) # Establish if we want to build experimental functionality or not. -experimental = os.environ.get("PYLZ4_EXPERIMENTAL", False) -if experimental is not False: - if experimental.upper() in ("1", "TRUE"): - experimental = True - else: - experimental = False +experimental_env = os.environ.get("PYLZ4_EXPERIMENTAL", "False") +if experimental_env.upper() in ("1", "TRUE"): + experimental = True +else: + experimental = False # Set up the extension modules. If a system wide lz4 library is found, and is # recent enough, we'll use that. Otherwise we'll build with the bundled one. If @@ -67,7 +67,13 @@ def pkgconfig_installed_check(lib, required_version, default): 'lz4/stream/_stream.c' ] -if liblz4_found is True: +use_system_liblz4_env = os.environ.get("PYLZ4_USE_SYSTEM_LZ4", "True") +if use_system_liblz4_env.upper() in ("1", "TRUE"): + use_system_liblz4 = True +else: + use_system_liblz4 = False + +if liblz4_found is True and use_system_liblz4 is True: extension_kwargs['libraries'] = ['lz4'] else: extension_kwargs['include_dirs'] = ['lz4libs'] @@ -97,7 +103,7 @@ def pkgconfig_installed_check(lib, required_version, default): ] ) -compiler = ccompiler.get_default_compiler() +compiler = new_compiler().compiler_type if compiler == 'msvc': extension_kwargs['extra_compile_args'] = [ @@ -107,7 +113,7 @@ def pkgconfig_installed_check(lib, required_version, default): '/wd4820', ] elif compiler in ('unix', 'mingw32'): - if liblz4_found: + if liblz4_found is True and use_system_liblz4 is True: extension_kwargs = pkgconfig_parse('liblz4') else: extension_kwargs['extra_compile_args'] = [