diff --git a/mmgen/data/version b/mmgen/data/version index 04bf7588..87c2e23f 100644 --- a/mmgen/data/version +++ b/mmgen/data/version @@ -1 +1 @@ -14.0.dev15 +14.0.dev16 diff --git a/setup.py b/setup.py index 14a601b0..7af63587 100755 --- a/setup.py +++ b/setup.py @@ -8,6 +8,10 @@ # https://github.com/mmgen/mmgen # https://gitlab.com/mmgen/mmgen +# MSYS2 Note (2023-10-26): +# mingw-w64-ucrt-x86_64-python package is missing static lib, so we must build dynamic extmod +# linked to installed libsecp256k1 + import os,platform from pathlib import Path from subprocess import run,PIPE @@ -22,10 +26,19 @@ home = Path(os.environ['HOME']) cache_path = home.joinpath('.cache','mmgen') src_path = home.joinpath('.cache','mmgen','secp256k1') -lib_file = src_path.joinpath('.libs', 'libsecp256k1.a') +if have_msys2: + root = Path().resolve().anchor + installed_lib_file = Path(root, 'msys64', 'ucrt64', 'lib', 'libsecp256k1.dll.a') + lib_file = src_path.joinpath('.libs', 'libsecp256k1.dll.a') +else: + installed_lib_file = None + lib_file = src_path.joinpath('.libs', 'libsecp256k1.a') def build_libsecp256k1(): + if installed_lib_file and installed_lib_file.exists(): # see ‘MSYS2 Note’ above + return + def fix_broken_aclocal_path(): os.environ['ACLOCAL_PATH'] = '/C/msys64/ucrt64/share/aclocal:/C/msys64/usr/share/aclocal' @@ -57,6 +70,9 @@ def build_libsecp256k1(): print('Executing {}'.format(' '.join(cmd))) run(cmd,check=True,cwd=src_path) + if installed_lib_file and not installed_lib_file.exists(): # see ‘MSYS2 Note’ above + run(['mingw32-make','install','MAKE=mingw32-make'],check=True,cwd=src_path) + class my_build_ext(build_ext): def build_extension(self,ext): build_libsecp256k1() @@ -70,5 +86,7 @@ setup( libraries = ['gmp'] if have_msys2 else [], include_dirs = [str(src_path.joinpath('include'))], extra_objects = [str(lib_file)], + extra_compile_args = ['-shared'] if have_msys2 else [], + extra_link_args = ['-shared'] if have_msys2 else [], )] )