diff --git a/pyproject.toml b/pyproject.toml index e8aff829e..38aadbea8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=61", "cffi>=1.3.0", "pkgconfig"] +requires = ["setuptools>=61", "cffi>=1.3.0"] build-backend = "setuptools.build_meta" [project] diff --git a/setup.py b/setup.py index 01ad2dfa3..80c417692 100644 --- a/setup.py +++ b/setup.py @@ -292,8 +292,11 @@ def build_extensions(self): # ABI?: py_limited_api=True, ) - pkgconfig.configure_extension(extension, secp256k1_package, static=False) - package_info = pkgconfig.parse(secp256k1_package, static=False) + extension.extra_compile_args = [str(subprocess.check_output(['pkg-config', '--cflags-only-I', 'libsecp256k1']))] # noqa S603 + extension.extra_link_args = [ + str(subprocess.check_output(['pkg-config', '--libs-only-L', 'libsecp256k1'])), # noqa S603 + str(subprocess.check_output(['pkg-config', '--libs-only-l', 'libsecp256k1'])), # noqa S603 + ] # Apparently, the linker on Windows interprets -lxxx as xxx.lib, not libxxx.lib for i, v in enumerate(extension.__dict__.get('extra_link_args')): @@ -317,7 +320,7 @@ def build_extensions(self): license='MIT OR Apache-2.0', python_requires='>=3.7', - install_requires=['asn1crypto', 'cffi>=1.3.0', 'pkgconfig'], + install_requires=['asn1crypto', 'cffi>=1.3.0'], packages=find_packages(exclude=('_cffi_build', '_cffi_build.*', 'libsecp256k1', 'tests')), package_data=package_data, @@ -357,5 +360,5 @@ def build_extensions(self): 'Topic :: Software Development :: Libraries', 'Topic :: Security :: Cryptography', ], - **setup_kwargs + **setup_kwargs ) diff --git a/setup_support.py b/setup_support.py index 25f4ef757..0e471444a 100644 --- a/setup_support.py +++ b/setup_support.py @@ -58,8 +58,6 @@ def build_flags(library, type_, path): def _find_lib(): - pkgconfig = __import__('pkgconfig') - if 'COINCURVE_IGNORE_SYSTEM_LIB' in os.environ: return False @@ -72,16 +70,22 @@ def _find_lib(): sources=[os.path.join('coincurve', '_libsecp256k1.c')], ) - pkgconfig.configure_extension(extension, 'libsecp256k1', static=False) - package_info = pkgconfig.parse('libsecp256k1', static=False) + if subprocess.check_output(['pkg-config', '--exists', 'libsecp256k1']): # noqa S603 + return False + + extension.extra_compile_args = [str(subprocess.check_output(['pkg-config', '--cflags-only-I', 'libsecp256k1']))] # noqa S603 + extension.extra_link_args = [ + str(subprocess.check_output(['pkg-config', '--libs-only-L', 'libsecp256k1'])), # noqa S603 + str(subprocess.check_output(['pkg-config', '--libs-only-l', 'libsecp256k1'])), # noqa S603 + ] if os.name == 'nt' or sys.platform == 'win32': ffi.dlopen('libsecp256k1-2') else: ffi.dlopen('secp256k1') - return os.path.exists(os.path.join(package_info['include_dirs'][0], 'secp256k1_ecdh.h')) - except (OSError, pkgconfig.pkgconfig.PackageNotFoundError): + return os.path.exists(os.path.join(extension.extra_compile_args[0][2:], 'secp256k1_ecdh.h')) + except OSError: if 'LIB_DIR' in os.environ: for path in glob.glob(os.path.join(os.environ['LIB_DIR'], '*secp256k1*')): with suppress(OSError):