From 693e93ec6abf6d17a9be87d152fa525a0cf3fbc1 Mon Sep 17 00:00:00 2001 From: Tester Date: Thu, 1 Feb 2024 13:02:34 +0330 Subject: [PATCH 1/8] Improve wheels and sdist --- MANIFEST.in | 9 +++-- Makefile | 6 +-- curl_cffi/build.py | 63 ++++++++++++++++++++++--------- {curl_cffi/ffi => ffi}/cdef.c | 0 {curl_cffi/ffi => ffi}/shim.c | 0 {curl_cffi/ffi => ffi}/shim.h | 0 pyproject.toml | 25 ++++++------ setup.py | 71 +++++++++++++++++++++++++++-------- 8 files changed, 122 insertions(+), 52 deletions(-) rename {curl_cffi/ffi => ffi}/cdef.c (100%) rename {curl_cffi/ffi => ffi}/shim.c (100%) rename {curl_cffi/ffi => ffi}/shim.h (100%) diff --git a/MANIFEST.in b/MANIFEST.in index b3c68460..3318a7e1 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,6 @@ -include curl_cffi/_wrapper.* -include curl_cffi/ffi/* -include curl_cffi/include/curl/* +recursive-include tests/* + +include ffi/* +include include/curl/* +include scripts/build.py +include Makefile diff --git a/Makefile b/Makefile index ad8f4c58..1633082f 100644 --- a/Makefile +++ b/Makefile @@ -18,8 +18,8 @@ curl-impersonate-$(VERSION)/chrome/patches: $(CURL_VERSION) for p in $=1.12.0", + "cffi>=1.12.0", "certifi", ] readme = "README.md" @@ -27,14 +27,12 @@ classifiers = [ [project.optional-dependencies] dev = [ "autoflake==1.4", - "black==22.8.0", "coverage==6.4.1", "cryptography==38.0.3", "flake8==6.0.0", "flake8-bugbear==22.7.1", "flake8-pie==0.15.0", "httpx==0.23.1", - "isort==5.10.1", "mypy==0.971", "types-certifi==2021.10.8.2", "pytest==7.1.2", @@ -49,7 +47,7 @@ dev = [ ] build = [ "cibuildwheel", - "wheel" + "wheel", ] test = [ "cryptography==38.0.3", @@ -68,20 +66,15 @@ test = [ "fastapi==0.100.0", ] -[tool.ruff.lint] -# Enable the isort rules. -extend-select = ["I"] + +[build-system] +requires = ["wheel", "setuptools", "cffi>=1.12.0"] +build-backend = "setuptools.build_meta" [tool.setuptools] packages = ["curl_cffi", "curl_cffi.requests"] package-data = { curl_cffi = ["libcurl.dll"] } -# include-package-data = true - - -[build-system] -requires = ["wheel", "setuptools", "cffi>=1.12.0"] -build-backend = "setuptools.build_meta" [tool.cibuildwheel] @@ -103,6 +96,7 @@ test-command = "python -bb -m pytest {project}/tests/unittest" test-extras = ["test"] test-skip = "pp*" + # configure cibuildwheel to build native archs ('auto'), and some emulated ones [tool.cibuildwheel.linux] archs = ["auto", "aarch64"] @@ -117,3 +111,8 @@ before-all = "gmake preprocess" [tool.pytest.ini_options] # pythonpath = [ "." ] asyncio_mode = "auto" + + +[tool.ruff.lint] +# Enable the isort rules. +extend-select = ["I"] diff --git a/setup.py b/setup.py index 5d693f32..8be7ae1e 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ import os +import sys import platform import shutil import struct @@ -23,33 +24,66 @@ def get_tag(self): return python, abi, plat -def download_so(): - uname = platform.uname() - machine = uname.machine +def abs_machine(): + machine = platform.machine() + + pointer_bits = struct.calcsize("P") * 8 + if pointer_bits not in (32, 64): + raise Exception("Unsupported pointer size") + + is_64 = pointer_bits == 64 + + # x86 based archs + if machine in ('AMD64', 'x86_64', 'i686'): + return "x86_64" if is_64 else "i686" + # arm based archs + elif machine in ('aarch64', 'arm64', 'armv6l', 'armv7l'): + return "aarch64" if is_64 else "arm" + else: + raise Exception("Unsupported processor") + - # do not download if target platfrom dll not found +def download_so(): + system = platform.system() + machine = abs_machine() - if uname.system == "Windows": + if system == "Windows": sysname = "win32" - if struct.calcsize("P") * 8 == 64: - machine = "x86_64" + so_name = "libcurl.dll" + + if machine == "x86_64": libdir = "./lib64" - else: - machine = "i686" + elif machine == "i686": libdir = "./lib32" - so_name = "libcurl.dll" - elif uname.system == "Darwin": + else: + so_name = "SKIP" + + elif system == "Darwin": sysname = "macos" - libdir = "/Users/runner/work/_temp/install/lib" so_name = "libcurl-impersonate-chrome.4.dylib" + + if machine in ("x86_64", "aarch64"): + libdir = "/Users/runner/work/_temp/install/lib" + else: + so_name = "SKIP" + else: sysname = "linux-gnu" - libdir = os.path.expanduser("~/.local/lib") so_name = "libcurl-impersonate-chrome.so" + if machine in ("x86_64", "arm", "aarch64"): + libdir = os.path.expanduser("~/.local/lib") + else: + so_name = "SKIP" + + if so_name == "SKIP": + print(f"libcurl for {sysname} platform is not available on github.") + return + if (Path(libdir) / so_name).exists(): print(".so files alreay downloaded.") return + file = "libcurl-impersonate.tar.gz" url = ( f"https://github.com/yifeikong/curl-impersonate/releases/download/" @@ -63,7 +97,8 @@ def download_so(): print("Unpacking downloaded files...") os.makedirs(libdir, exist_ok=True) shutil.unpack_archive(file, libdir) - if uname.system == "Windows": + + if system == "Windows": shutil.copy2(f"{libdir}/libcurl.dll", "curl_cffi") @@ -73,11 +108,15 @@ def run(self): super().run() +# this option is only valid in setup.py +kwargs = {"cffi_modules": ["curl_cffi/build.py:ffibuilder"]} +if len(sys.argv) > 1 and sys.argv[1] != 'bdist_wheel': + kwargs = {} + setup( - # this option is only valid in setup.py - cffi_modules=["curl_cffi/build.py:ffibuilder"], cmdclass={ "bdist_wheel": bdist_wheel_abi3, # type: ignore "build": my_build, # type: ignore }, + **kwargs, ) From 051ff06134d0d35fe94e23663409018cdb42ebb1 Mon Sep 17 00:00:00 2001 From: Tester Date: Thu, 1 Feb 2024 13:20:59 +0330 Subject: [PATCH 2/8] monkeypatch for macos-arm64 --- curl_cffi/build.py | 1 + setup.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/curl_cffi/build.py b/curl_cffi/build.py index ac45c287..06093743 100644 --- a/curl_cffi/build.py +++ b/curl_cffi/build.py @@ -55,6 +55,7 @@ def abs_machine(): """ #include "shim.h" """, + # FIXME from `curl-impersonate` libraries=["curl-impersonate-chrome"] if system != "Windows" else ["libcurl"], library_dirs=[libdir], source_extension=".c", diff --git a/setup.py b/setup.py index 8be7ae1e..c56713e0 100644 --- a/setup.py +++ b/setup.py @@ -64,6 +64,9 @@ def download_so(): if machine in ("x86_64", "aarch64"): libdir = "/Users/runner/work/_temp/install/lib" + # FIXME from `curl-impersonate` + if machine == "aarch64": + machine = "arm64" else: so_name = "SKIP" From 5ed9cad78f9159a2b1ac0d79b282f4363183d6bf Mon Sep 17 00:00:00 2001 From: Tester Date: Thu, 1 Feb 2024 13:31:12 +0330 Subject: [PATCH 3/8] revert --- setup.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/setup.py b/setup.py index c56713e0..7bbbb186 100644 --- a/setup.py +++ b/setup.py @@ -1,14 +1,13 @@ import os -import sys import platform import shutil import struct +from distutils.command.build import build from pathlib import Path -from setuptools import setup from urllib.request import urlretrieve -from wheel.bdist_wheel import bdist_wheel -from distutils.command.build import build +from setuptools import setup +from wheel.bdist_wheel import bdist_wheel __version__ = "0.6.0b9" @@ -111,15 +110,11 @@ def run(self): super().run() -# this option is only valid in setup.py -kwargs = {"cffi_modules": ["curl_cffi/build.py:ffibuilder"]} -if len(sys.argv) > 1 and sys.argv[1] != 'bdist_wheel': - kwargs = {} - setup( + # this option is only valid in setup.py + cffi_modules=["curl_cffi/build.py:ffibuilder"], cmdclass={ "bdist_wheel": bdist_wheel_abi3, # type: ignore "build": my_build, # type: ignore }, - **kwargs, ) From 22b5f7a20e4e0b2cf5e3c5fb812431e810c34d6a Mon Sep 17 00:00:00 2001 From: Tester Date: Thu, 1 Feb 2024 14:23:02 +0330 Subject: [PATCH 4/8] move `build.py` --- {curl_cffi => scripts}/build.py | 4 ++-- setup.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename {curl_cffi => scripts}/build.py (100%) diff --git a/curl_cffi/build.py b/scripts/build.py similarity index 100% rename from curl_cffi/build.py rename to scripts/build.py index 06093743..e5e8b5bb 100644 --- a/curl_cffi/build.py +++ b/scripts/build.py @@ -31,9 +31,9 @@ def abs_machine(): if system == "Windows": if machine == "x86_64": - libdir = "./lib32" - elif machine == "i686": libdir = "./lib64" + elif machine == "i686": + libdir = "./lib32" else: libdir = "ERROR" elif system == "Darwin": diff --git a/setup.py b/setup.py index 7bbbb186..71eb8a21 100644 --- a/setup.py +++ b/setup.py @@ -112,7 +112,7 @@ def run(self): setup( # this option is only valid in setup.py - cffi_modules=["curl_cffi/build.py:ffibuilder"], + cffi_modules=["scripts/build.py:ffibuilder"], cmdclass={ "bdist_wheel": bdist_wheel_abi3, # type: ignore "build": my_build, # type: ignore From a64de8a62c5bd05325e7e80d5bea1a0cd88aa037 Mon Sep 17 00:00:00 2001 From: Yifei Kong Date: Sun, 4 Feb 2024 20:39:29 +0800 Subject: [PATCH 5/8] Store supported archs in a json file, removing duplicated detection --- libs.json | 74 +++++++++++++++++++++++++++++++++++++++++++ scripts/build.py | 56 ++++++++++----------------------- setup.py | 82 +++++++++++++----------------------------------- 3 files changed, 111 insertions(+), 101 deletions(-) create mode 100644 libs.json diff --git a/libs.json b/libs.json new file mode 100644 index 00000000..e1a67e9d --- /dev/null +++ b/libs.json @@ -0,0 +1,74 @@ +[ + { + "system": "Windows", + "machine": "AMD64", + "pointer_size": 64, + "libdir": "./lib64", + "sysname": "win32", + "so_name": "libcurl.dll", + "so_arch": "x86_64", + }, + { + "system": "Windows", + "machine": "i686", + "pointer_size": 32, + "libdir": "./lib32", + "sysname": "win32", + "so_name": "libcurl.dll", + "so_arch": "i686", + }, + { + "system": "Darwin", + "machine": "x86_64", + "pointer_size": 64, + "libdir": "/Users/runner/work/_temp/install/lib", + "sysname": "macos", + "so_name": "libcurl-impersonate-chrome.4.dylib", + "so_arch": "x86_64", + }, + { + "system": "Darwin", + "machine": "arm64", + "pointer_size": 64, + "libdir": "/Users/runner/work/_temp/install/lib", + "sysname": "macos", + "so_name": "libcurl-impersonate-chrome.4.dylib", + "so_arch": "arm64", + }, + { + "system": "Linux", + "machine": "x86_64", + "pointer_size": 64, + "libdir": "~/.local/lib", + "sysname": "linux-gnu", + "so_name": "libcurl-impersonate-chrome.so", + "so_arch": "x86_64", + }, + { + "system": "Linux", + "machine": "aarch64", + "pointer_size": 64, + "libdir": "~/.local/lib", + "sysname": "linux-gnu", + "so_name": "libcurl-impersonate-chrome.so", + "so_arch": "aarch64", + }, + { + "system": "Linux", + "machine": "armv6l", + "pointer_size": 32, + "libdir": "~/.local/lib", + "sysname": "linux-gnu", + "so_name": "libcurl-impersonate-chrome.so", + "so_arch": "armv6l", + }, + { + "system": "Linux", + "machine": "armv7l", + "pointer_size": 32, + "libdir": "~/.local/lib", + "sysname": "linux-gnu", + "so_name": "libcurl-impersonate-chrome.so", + "so_arch": "armv7l", + }, +] diff --git a/scripts/build.py b/scripts/build.py index 66f7af68..ca635b88 100644 --- a/scripts/build.py +++ b/scripts/build.py @@ -1,4 +1,4 @@ -import os +import json import platform import struct from pathlib import Path @@ -6,50 +6,26 @@ from cffi import FFI -def abs_machine(): - machine = platform.machine() - - pointer_bits = struct.calcsize("P") * 8 - if pointer_bits not in (32, 64): - raise Exception("Unsupported pointer size") - - is_64 = pointer_bits == 64 - - # x86 based archs - if machine in ('AMD64', 'x86_64', 'i686'): - return "x86_64" if is_64 else "i686" - # arm based archs - elif machine in ('aarch64', 'arm64', 'armv6l', 'armv7l'): - return "aarch64" if is_64 else "arm" - else: - raise Exception("Unsupported processor") +def detect_arch(): + with open(Path(__file__).parent.parent / "libs.json") as f: + archs = json.loads(f.read()) + uname = platform.uname() + pointer_size = struct.calcsize("P") * 8 + for arch in archs: + if ( + arch["system"] == uname.system + and arch["machine"] == uname.machine + and arch["pointer_size"] == pointer_size + ): + return arch + raise Exception(f"Unsupported arch: {uname}") ffibuilder = FFI() system = platform.system() -machine = abs_machine() root_dir = Path(__file__).parent.parent +arch = detect_arch() -if system == "Windows": - if machine == "x86_64": - libdir = "./lib64" - elif machine == "i686": - libdir = "./lib32" - else: - libdir = "ERROR" -elif system == "Darwin": - if machine in ("x86_64", "aarch64"): - libdir = "/Users/runner/work/_temp/install/lib" - else: - libdir = "ERROR" -else: - if machine in ("x86_64", "arm", "aarch64"): - libdir = os.path.expanduser("~/.local/lib") - else: - libdir = "ERROR" - -if libdir == "ERROR": - raise Exception("Unsupported platform") ffibuilder.set_source( "curl_cffi._wrapper", @@ -58,7 +34,7 @@ def abs_machine(): """, # FIXME from `curl-impersonate` libraries=["curl-impersonate-chrome"] if system != "Windows" else ["libcurl"], - library_dirs=[libdir], + library_dirs=[arch["libdir"]], source_extension=".c", include_dirs=[ str(root_dir / "include"), diff --git a/setup.py b/setup.py index 71eb8a21..4689a142 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,4 @@ +import json import os import platform import shutil @@ -23,66 +24,25 @@ def get_tag(self): return python, abi, plat -def abs_machine(): - machine = platform.machine() - - pointer_bits = struct.calcsize("P") * 8 - if pointer_bits not in (32, 64): - raise Exception("Unsupported pointer size") - - is_64 = pointer_bits == 64 - - # x86 based archs - if machine in ('AMD64', 'x86_64', 'i686'): - return "x86_64" if is_64 else "i686" - # arm based archs - elif machine in ('aarch64', 'arm64', 'armv6l', 'armv7l'): - return "aarch64" if is_64 else "arm" - else: - raise Exception("Unsupported processor") +def detect_arch(): + with open(Path(__file__).parent / "libs.json") as f: + archs = json.loads(f.read()) + uname = platform.uname() + pointer_size = struct.calcsize("P") * 8 + for arch in archs: + if ( + arch["system"] == uname.system + and arch["machine"] == uname.machine + and arch["pointer_size"] == pointer_size + ): + return arch + raise Exception(f"Unsupported arch: {uname}") def download_so(): - system = platform.system() - machine = abs_machine() - - if system == "Windows": - sysname = "win32" - so_name = "libcurl.dll" - - if machine == "x86_64": - libdir = "./lib64" - elif machine == "i686": - libdir = "./lib32" - else: - so_name = "SKIP" - - elif system == "Darwin": - sysname = "macos" - so_name = "libcurl-impersonate-chrome.4.dylib" - - if machine in ("x86_64", "aarch64"): - libdir = "/Users/runner/work/_temp/install/lib" - # FIXME from `curl-impersonate` - if machine == "aarch64": - machine = "arm64" - else: - so_name = "SKIP" - - else: - sysname = "linux-gnu" - so_name = "libcurl-impersonate-chrome.so" - - if machine in ("x86_64", "arm", "aarch64"): - libdir = os.path.expanduser("~/.local/lib") - else: - so_name = "SKIP" - - if so_name == "SKIP": - print(f"libcurl for {sysname} platform is not available on github.") - return + arch = detect_arch() - if (Path(libdir) / so_name).exists(): + if (Path(arch["libdir"]) / arch["so_name"]).exists(): print(".so files alreay downloaded.") return @@ -90,18 +50,18 @@ def download_so(): url = ( f"https://github.com/yifeikong/curl-impersonate/releases/download/" f"v{__version__}/libcurl-impersonate-v{__version__}" - f".{machine}-{sysname}.tar.gz" + f".{arch['so_arch']}-{arch['sysname']}.tar.gz" ) print(f"Downloading libcurl-impersonate-chrome from {url}...") urlretrieve(url, file) print("Unpacking downloaded files...") - os.makedirs(libdir, exist_ok=True) - shutil.unpack_archive(file, libdir) + os.makedirs(arch["libdir"], exist_ok=True) + shutil.unpack_archive(file, arch["libdir"]) - if system == "Windows": - shutil.copy2(f"{libdir}/libcurl.dll", "curl_cffi") + if arch["system"] == "Windows": + shutil.copy2(f"{arch['libdir']}/libcurl.dll", "curl_cffi") class my_build(build): From 03964803b4f7a9808c75db1522aac86e9629da51 Mon Sep 17 00:00:00 2001 From: Yifei Kong Date: Mon, 5 Feb 2024 10:47:42 +0800 Subject: [PATCH 6/8] Move download_so to build.py --- MANIFEST.in | 2 +- libs.json | 18 +++++++-------- scripts/build.py | 32 +++++++++++++++++++++++++- setup.py | 58 ------------------------------------------------ 4 files changed, 41 insertions(+), 69 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 3318a7e1..0d9ea856 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,4 @@ -recursive-include tests/* +recursive-include tests * include ffi/* include include/curl/* diff --git a/libs.json b/libs.json index e1a67e9d..7a2d1090 100644 --- a/libs.json +++ b/libs.json @@ -6,7 +6,7 @@ "libdir": "./lib64", "sysname": "win32", "so_name": "libcurl.dll", - "so_arch": "x86_64", + "so_arch": "x86_64" }, { "system": "Windows", @@ -15,7 +15,7 @@ "libdir": "./lib32", "sysname": "win32", "so_name": "libcurl.dll", - "so_arch": "i686", + "so_arch": "i686" }, { "system": "Darwin", @@ -24,7 +24,7 @@ "libdir": "/Users/runner/work/_temp/install/lib", "sysname": "macos", "so_name": "libcurl-impersonate-chrome.4.dylib", - "so_arch": "x86_64", + "so_arch": "x86_64" }, { "system": "Darwin", @@ -33,7 +33,7 @@ "libdir": "/Users/runner/work/_temp/install/lib", "sysname": "macos", "so_name": "libcurl-impersonate-chrome.4.dylib", - "so_arch": "arm64", + "so_arch": "arm64" }, { "system": "Linux", @@ -42,7 +42,7 @@ "libdir": "~/.local/lib", "sysname": "linux-gnu", "so_name": "libcurl-impersonate-chrome.so", - "so_arch": "x86_64", + "so_arch": "x86_64" }, { "system": "Linux", @@ -51,7 +51,7 @@ "libdir": "~/.local/lib", "sysname": "linux-gnu", "so_name": "libcurl-impersonate-chrome.so", - "so_arch": "aarch64", + "so_arch": "aarch64" }, { "system": "Linux", @@ -60,7 +60,7 @@ "libdir": "~/.local/lib", "sysname": "linux-gnu", "so_name": "libcurl-impersonate-chrome.so", - "so_arch": "armv6l", + "so_arch": "armv6l" }, { "system": "Linux", @@ -69,6 +69,6 @@ "libdir": "~/.local/lib", "sysname": "linux-gnu", "so_name": "libcurl-impersonate-chrome.so", - "so_arch": "armv7l", - }, + "so_arch": "armv7l" + } ] diff --git a/scripts/build.py b/scripts/build.py index ca635b88..2c3fe9e1 100644 --- a/scripts/build.py +++ b/scripts/build.py @@ -1,10 +1,15 @@ import json +import os import platform +import shutil import struct from pathlib import Path +from urllib.request import urlretrieve from cffi import FFI +__version__ = "0.6.0b9" + def detect_arch(): with open(Path(__file__).parent.parent / "libs.json") as f: @@ -21,10 +26,35 @@ def detect_arch(): raise Exception(f"Unsupported arch: {uname}") +arch = detect_arch() + +def download_so(): + if (Path(arch["libdir"]) / arch["so_name"]).exists(): + print(".so files alreay downloaded.") + return + + file = "libcurl-impersonate.tar.gz" + url = ( + f"https://github.com/yifeikong/curl-impersonate/releases/download/" + f"v{__version__}/libcurl-impersonate-v{__version__}" + f".{arch['so_arch']}-{arch['sysname']}.tar.gz" + ) + + print(f"Downloading libcurl-impersonate-chrome from {url}...") + urlretrieve(url, file) + + print("Unpacking downloaded files...") + os.makedirs(arch["libdir"], exist_ok=True) + shutil.unpack_archive(file, arch["libdir"]) + + if arch["system"] == "Windows": + shutil.copy2(f"{arch['libdir']}/libcurl.dll", "curl_cffi") + + ffibuilder = FFI() system = platform.system() root_dir = Path(__file__).parent.parent -arch = detect_arch() +download_so() ffibuilder.set_source( diff --git a/setup.py b/setup.py index 4689a142..711ff902 100644 --- a/setup.py +++ b/setup.py @@ -1,17 +1,6 @@ -import json -import os -import platform -import shutil -import struct -from distutils.command.build import build -from pathlib import Path -from urllib.request import urlretrieve - from setuptools import setup from wheel.bdist_wheel import bdist_wheel -__version__ = "0.6.0b9" - class bdist_wheel_abi3(bdist_wheel): def get_tag(self): @@ -24,57 +13,10 @@ def get_tag(self): return python, abi, plat -def detect_arch(): - with open(Path(__file__).parent / "libs.json") as f: - archs = json.loads(f.read()) - uname = platform.uname() - pointer_size = struct.calcsize("P") * 8 - for arch in archs: - if ( - arch["system"] == uname.system - and arch["machine"] == uname.machine - and arch["pointer_size"] == pointer_size - ): - return arch - raise Exception(f"Unsupported arch: {uname}") - - -def download_so(): - arch = detect_arch() - - if (Path(arch["libdir"]) / arch["so_name"]).exists(): - print(".so files alreay downloaded.") - return - - file = "libcurl-impersonate.tar.gz" - url = ( - f"https://github.com/yifeikong/curl-impersonate/releases/download/" - f"v{__version__}/libcurl-impersonate-v{__version__}" - f".{arch['so_arch']}-{arch['sysname']}.tar.gz" - ) - - print(f"Downloading libcurl-impersonate-chrome from {url}...") - urlretrieve(url, file) - - print("Unpacking downloaded files...") - os.makedirs(arch["libdir"], exist_ok=True) - shutil.unpack_archive(file, arch["libdir"]) - - if arch["system"] == "Windows": - shutil.copy2(f"{arch['libdir']}/libcurl.dll", "curl_cffi") - - -class my_build(build): - def run(self): - download_so() - super().run() - - setup( # this option is only valid in setup.py cffi_modules=["scripts/build.py:ffibuilder"], cmdclass={ "bdist_wheel": bdist_wheel_abi3, # type: ignore - "build": my_build, # type: ignore }, ) From 692d3cb393624c08188f198b87be9ab9acf457a8 Mon Sep 17 00:00:00 2001 From: Yifei Kong Date: Mon, 5 Feb 2024 11:53:54 +0800 Subject: [PATCH 7/8] Fix build spec, add missing file --- MANIFEST.in | 1 + libs.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index 0d9ea856..bb194bb8 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -4,3 +4,4 @@ include ffi/* include include/curl/* include scripts/build.py include Makefile +include libs.json diff --git a/libs.json b/libs.json index 7a2d1090..1b662838 100644 --- a/libs.json +++ b/libs.json @@ -10,7 +10,7 @@ }, { "system": "Windows", - "machine": "i686", + "machine": "AMD64", "pointer_size": 32, "libdir": "./lib32", "sysname": "win32", From 53534cee087cef8d47897aad521a4d984ca4eb35 Mon Sep 17 00:00:00 2001 From: Yifei Kong Date: Mon, 5 Feb 2024 11:58:51 +0800 Subject: [PATCH 8/8] Add missing expanduser for libdir --- scripts/build.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/build.py b/scripts/build.py index 2c3fe9e1..d6d73dad 100644 --- a/scripts/build.py +++ b/scripts/build.py @@ -22,6 +22,7 @@ def detect_arch(): and arch["machine"] == uname.machine and arch["pointer_size"] == pointer_size ): + arch["libdir"] = os.path.expanduser(arch["libdir"]) return arch raise Exception(f"Unsupported arch: {uname}")