File tree Expand file tree Collapse file tree 9 files changed +54
-17
lines changed Expand file tree Collapse file tree 9 files changed +54
-17
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ concurrency:
2626jobs :
2727 build_wheels :
2828 strategy :
29+ fail-fast : false
2930 matrix :
3031 os : ["ubuntu-latest", "macos-latest", "windows-latest"]
3132
@@ -35,10 +36,10 @@ jobs:
3536 - run : make requirements
3637 - name : Set up QEMU # Needed to build aarch64 wheels
3738 if : runner.os == 'Linux'
38- uses : docker/setup-qemu-action@v2
39+ uses : docker/setup-qemu-action@v3
3940 with :
4041 platforms : all
41- - uses : pypa/cibuildwheel@v2.17 .0
42+ - uses : pypa/cibuildwheel@v2.20 .0
4243 - uses : actions/upload-artifact@v4
4344 with :
4445 path : wheelhouse/*.whl
Original file line number Diff line number Diff line change 2121 lint :
2222 runs-on : ubuntu-latest
2323 steps :
24- - uses : actions/checkout@v3
24+ - uses : actions/checkout@v4
2525 - name : Set up Python
26- uses : actions/setup-python@v4
26+ uses : actions/setup-python@v5
2727 with :
2828 python-version : " 3.8"
2929 - name : Install dependencies
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ concurrency:
2020jobs :
2121 build_test :
2222 strategy :
23+ fail-fast : false
2324 matrix :
2425 os : ["ubuntu-latest", "macos-latest"]
2526
2829 steps :
2930 - uses : actions/checkout@v4
3031 - name : Set up Python 3.8
31- uses : actions/setup-python@v4
32+ uses : actions/setup-python@v5
3233 with :
3334 python-version : " 3.8"
3435 - name : Install dependencies
Original file line number Diff line number Diff line change 1+ include ada_url/*.c
2+ include ada_url/*.cpp
3+ include ada_url/*.h
4+ exclude ada_url/*.o
5+ exclude ada_url/_ada_wrapper.*
Original file line number Diff line number Diff line change @@ -31,12 +31,7 @@ clean:
3131 $(RM ) ada_url/_ada_wrapper.abi3.so
3232 $(RM ) ada_url/ada.o
3333
34- .PHONY : c_lib
35- c_lib :
36- $(CXX ) -c " ada_url/ada.cpp" -fPIC -std=" c++17" -O2 -o " ada_url/ada.o" $(ARCHFLAGS )
37-
3834.PHONY : package
39- package : c_lib
35+ package :
4036 python -m build --no-isolation
41- python ./update_sdist.py
4237 twine check dist/*
Original file line number Diff line number Diff line change 11from cffi import FFI
22from os .path import dirname , join
3+ from setuptools .extension import Extension
34from sys import platform
45
56file_dir = dirname (__file__ )
67
8+ compile_args = ['/std:c++17' ] if platform == 'win32' else ['-std=c++17' ]
9+
10+ ada_obj = Extension (
11+ 'ada' ,
12+ language = "c++" ,
13+ sources = ['ada_url/ada.cpp' ],
14+ include_dirs = [file_dir ],
15+ extra_compile_args = compile_args ,
16+ )
17+
718libraries = ['stdc++' ] if platform == 'linux' else []
819
920ffi_builder = FFI ()
1021ffi_builder .set_source (
1122 'ada_url._ada_wrapper' ,
1223 '# include "ada_c.h"' ,
13- include_dirs = [file_dir ],
1424 libraries = libraries ,
15- extra_objects = [join (file_dir , 'ada.o' )],
25+ include_dirs = [file_dir ],
26+ extra_objects = [ada_obj ],
1627)
1728
1829cdef_lines = []
Original file line number Diff line number Diff line change @@ -30,7 +30,6 @@ After that, you're ready to build the package:
3030.. code-block :: sh
3131
3232 python -m pip install -r requirements/development.txt
33- c++ -c " ada_url/ada.cpp" -fPIC -std=" c++17" -O2 -o " ada_url/ada.o"
3433 python -m build --no-isolation
3534
3635 This will create a `.whl ` file in the `dist ` directory. You can install it in other
Original file line number Diff line number Diff line change @@ -73,13 +73,13 @@ build = [
7373
7474[tool .cibuildwheel .linux ]
7575archs = [" x86_64" , " aarch64" ]
76- before-all = " make c_lib"
7776
7877[tool .cibuildwheel .macos ]
7978archs = [" x86_64" , " universal2" , " arm64" ]
8079environment = { MACOSX_DEPLOYMENT_TARGET =" 10.15" }
81- before-build = " make clean && make c_lib "
80+ before-build = " make clean"
8281
8382[tool .cibuildwheel .windows ]
8483archs = [" AMD64" ]
85- before-build = ' "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Auxiliary\\Build\\vcvars64.bat" && cl "ada_url\\ada.cpp" /c /nologo /Fo"ada_url\\ada.o" /O2 /GL /MD /W3 /EHsc /std:c++17'
84+ # https://github.com/python-cffi/cffi/issues/117
85+ environment = { SETUPTOOLS_USE_DISTUTILS =" stdlib" }
Original file line number Diff line number Diff line change 11from setuptools import setup
2+ from setuptools .command .build_ext import build_ext as _build_ext
3+ from setuptools .extension import Extension
4+
5+
6+ class build_ext (_build_ext ):
7+ def build_extension (self , ext ):
8+ for i , extra in enumerate (ext .extra_objects ):
9+ if isinstance (extra , Extension ):
10+ sources = sorted (extra .sources )
11+ extra_args = extra .extra_compile_args or []
12+ macros = extra .define_macros [:]
13+ for undef in extra .undef_macros :
14+ macros .append ((undef ,))
15+ objects = self .compiler .compile (
16+ sources ,
17+ output_dir = self .build_temp ,
18+ macros = macros ,
19+ include_dirs = extra .include_dirs ,
20+ debug = self .debug ,
21+ extra_postargs = extra_args ,
22+ depends = extra .depends ,
23+ )
24+ ext .extra_objects [i ] = objects [0 ]
25+ return super ().build_extension (ext )
226
327setup (
28+ cmdclass = {'build_ext' : build_ext },
429 cffi_modules = [
530 './ada_url/ada_build.py:ffi_builder' ,
631 ],
You can’t perform that action at this time.
0 commit comments