Skip to content

Commit 4ccde87

Browse files
jschuellerDanielBok
authored andcommitted
Try to build with stable API
1 parent 65094a6 commit 4ccde87

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

.github/workflows/build.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,15 @@ jobs:
6262
with:
6363
submodules: true
6464

65-
- name: Setup Python 3.11
65+
- name: Setup Python 3.6
6666
uses: actions/setup-python@v2
6767
with:
68-
python-version: '3.11'
68+
python-version: '3.6'
6969

7070
- name: Build wheels
7171
env:
72-
# only build CPython-3.8 and later and skip 32-bit builds and skip windows
73-
# CIBW_BUILD: cp38-* cp39-* cp310-* cp311-*
74-
CIBW_BUILD: cp311-*
72+
# only build CPython-3.6+ and skip 32-bit builds and skip windows
73+
CIBW_BUILD: cp36-*
7574
CIBW_SKIP: "*-win* *-manylinux_i686 *-musllinux*"
7675
# use latest build
7776
CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux2014_x86_64

extensions.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ def build_extension(self, ext: Extension):
5757
ext.source_dir.as_posix()
5858
]
5959

60+
if platform.system() == "Windows":
61+
cmd += "-DPYTHON_EXTENSION_MODULE_SUFFIX=.abi3.so"
62+
else:
63+
cmd += "-DPYTHON_EXTENSION_MODULE_SUFFIX=.abi3.pyd"
64+
abi3_flag = "-DPy_LIMITED_API=0x03060000"
65+
6066
if platform.system() == "Windows":
6167
cmd.insert(2, f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{self.config.upper()}={_ed}")
6268

@@ -65,7 +71,7 @@ def build_extension(self, ext: Extension):
6571
cwd=build_dir,
6672
env={
6773
**os.environ.copy(),
68-
"CXXFLAGS": f'{os.environ.get("CXXFLAGS", "")} -DVERSION_INFO="{self.distribution.get_version()}"'
74+
"CXXFLAGS": f'{os.environ.get("CXXFLAGS", "")} -DVERSION_INFO="{self.distribution.get_version()}" {abi3_flag}'
6975
})
7076

7177
# build the DLL

setup.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
from extensions import NLOptBuild, NLOptBuildExtension
77

8+
from wheel.bdist_wheel import bdist_wheel
9+
810
with open("README.md") as f:
911
long_description = f.read()
1012

@@ -16,10 +18,23 @@
1618
version.append(m.group(1))
1719
version = ".".join(version)
1820

21+
22+
class bdist_wheel_abi3(bdist_wheel):
23+
def get_tag(self):
24+
python, abi, plat = super().get_tag()
25+
26+
if python.startswith("cp"):
27+
# on CPython, our wheels are abi3 and compatible back to 3.6
28+
return "cp36", "abi3", plat
29+
30+
return python, abi, plat
31+
32+
1933
setup(
2034
version=version,
2135
install_requires=["numpy >=1.18.5"],
2236
ext_modules=[NLOptBuildExtension("nlopt._nlopt", version)],
23-
cmdclass={"build_ext": NLOptBuild},
37+
cmdclass={"build_ext": NLOptBuild,
38+
"bdist_wheel": bdist_wheel_abi3},
2439
zip_safe=False,
2540
)

0 commit comments

Comments
 (0)