diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index 9e79cd0..c2d5d8a 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -51,14 +51,14 @@ jobs: run: | rm -rf build wheelhouse touch libarchive/_libarchive.i - make clean export LD_LIBRARY_PATH=/usr/local/lib64/:/usr/local/lib:$LD_LIBRARY_PATH - make install + export LIBARCHIVE_PREFIX=/usr/local + python3 setup.py install - name: Build wheels run: | - make wheel + pip wheel --wheel-dir dist/ . auditwheel repair dist/*.whl python3 -m pip install --force-reinstall wheelhouse/*,whl diff --git a/setup.py b/setup.py index 8703f5f..dddc13c 100644 --- a/setup.py +++ b/setup.py @@ -36,13 +36,22 @@ except ImportError: import subprocess + +# Use a provided libarchive else default to hard-coded path. +libarchivePrefix = environ.get('LIBARCHIVE_PREFIX') + +includePath = f"{libarchivePrefix or '/usr'}/include" # retreive the version number form SWIG generated file +print("includePath:", (libarchivePrefix, includePath)) + cmd = [ 'awk', - '/ARCHIVE_VERSION_NUMBER/ { if (match($0,"[[:digit:]]+")) print substr($0, RSTART,RLENGTH) }', - "libarchive/_libarchive_wrap.c", + '/#define.*ARCHIVE_VERSION_NUMBER/ { if (match($0,"[[:digit:]]+")) print substr($0, RSTART,RLENGTH) }', + f"{includePath}/archive.h" ] + p = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) +print("awk output:", p.stdout.decode('utf-8')) vnum = int(p.stdout) name = 'python-libarchive-ext' @@ -78,8 +87,6 @@ class build_ext_extra(build_ext, object): super(build_ext_extra, self).build_extension(ext) -# Use a provided libarchive else default to hard-coded path. -libarchivePrefix = environ.get('LIBARCHIVE_PREFIX') if libarchivePrefix: extra_compile_args = ['-I{0}/include'.format(libarchivePrefix)] extra_link_args = ['-Wl,-rpath={0}/lib'.format(libarchivePrefix)] @@ -90,7 +97,7 @@ else: __libarchive = Extension( name='libarchive.__libarchive', - sources=['libarchive/_libarchive.i', 'libarchive/_libarchive_wrap.c'], + sources=['libarchive/_libarchive.i'], libraries=['archive'], extra_compile_args=extra_compile_args, extra_link_args=extra_link_args,