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:
26
26
jobs :
27
27
build_wheels :
28
28
strategy :
29
+ fail-fast : false
29
30
matrix :
30
31
os : ["ubuntu-latest", "macos-latest", "windows-latest"]
31
32
@@ -35,10 +36,10 @@ jobs:
35
36
- run : make requirements
36
37
- name : Set up QEMU # Needed to build aarch64 wheels
37
38
if : runner.os == 'Linux'
38
- uses : docker/setup-qemu-action@v2
39
+ uses : docker/setup-qemu-action@v3
39
40
with :
40
41
platforms : all
41
- - uses : pypa/cibuildwheel@v2.17 .0
42
+ - uses : pypa/cibuildwheel@v2.20 .0
42
43
- uses : actions/upload-artifact@v4
43
44
with :
44
45
path : wheelhouse/*.whl
Original file line number Diff line number Diff line change 21
21
lint :
22
22
runs-on : ubuntu-latest
23
23
steps :
24
- - uses : actions/checkout@v3
24
+ - uses : actions/checkout@v4
25
25
- name : Set up Python
26
- uses : actions/setup-python@v4
26
+ uses : actions/setup-python@v5
27
27
with :
28
28
python-version : " 3.8"
29
29
- name : Install dependencies
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ concurrency:
20
20
jobs :
21
21
build_test :
22
22
strategy :
23
+ fail-fast : false
23
24
matrix :
24
25
os : ["ubuntu-latest", "macos-latest"]
25
26
28
29
steps :
29
30
- uses : actions/checkout@v4
30
31
- name : Set up Python 3.8
31
- uses : actions/setup-python@v4
32
+ uses : actions/setup-python@v5
32
33
with :
33
34
python-version : " 3.8"
34
35
- 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:
31
31
$(RM ) ada_url/_ada_wrapper.abi3.so
32
32
$(RM ) ada_url/ada.o
33
33
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
-
38
34
.PHONY : package
39
- package : c_lib
35
+ package :
40
36
python -m build --no-isolation
41
- python ./update_sdist.py
42
37
twine check dist/*
Original file line number Diff line number Diff line change 1
1
from cffi import FFI
2
2
from os .path import dirname , join
3
+ from setuptools .extension import Extension
3
4
from sys import platform
4
5
5
6
file_dir = dirname (__file__ )
6
7
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
+
7
18
libraries = ['stdc++' ] if platform == 'linux' else []
8
19
9
20
ffi_builder = FFI ()
10
21
ffi_builder .set_source (
11
22
'ada_url._ada_wrapper' ,
12
23
'# include "ada_c.h"' ,
13
- include_dirs = [file_dir ],
14
24
libraries = libraries ,
15
- extra_objects = [join (file_dir , 'ada.o' )],
25
+ include_dirs = [file_dir ],
26
+ extra_objects = [ada_obj ],
16
27
)
17
28
18
29
cdef_lines = []
Original file line number Diff line number Diff line change @@ -30,7 +30,6 @@ After that, you're ready to build the package:
30
30
.. code-block :: sh
31
31
32
32
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"
34
33
python -m build --no-isolation
35
34
36
35
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 = [
73
73
74
74
[tool .cibuildwheel .linux ]
75
75
archs = [" x86_64" , " aarch64" ]
76
- before-all = " make c_lib"
77
76
78
77
[tool .cibuildwheel .macos ]
79
78
archs = [" x86_64" , " universal2" , " arm64" ]
80
79
environment = { MACOSX_DEPLOYMENT_TARGET =" 10.15" }
81
- before-build = " make clean && make c_lib "
80
+ before-build = " make clean"
82
81
83
82
[tool .cibuildwheel .windows ]
84
83
archs = [" 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 1
1
from 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 )
2
26
3
27
setup (
28
+ cmdclass = {'build_ext' : build_ext },
4
29
cffi_modules = [
5
30
'./ada_url/ada_build.py:ffi_builder' ,
6
31
],
You can’t perform that action at this time.
0 commit comments