Skip to content

Commit ee954d5

Browse files
authored
Merge pull request #61 from tarasko/feature/clean_strip
Simply setup.py, strip release builds using cibuildwheel options
2 parents 9edd053 + 4ac99c9 commit ee954d5

File tree

4 files changed

+11
-32
lines changed

4 files changed

+11
-32
lines changed

.github/workflows/run-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ jobs:
7777
with:
7878
python-version: ${{ matrix.pyver }}
7979

80+
- name: Show Python build OPT flags (they are automatically added when building extensions)
81+
run: python -c "import sysconfig; print(sysconfig.get_config_var('OPT'))"
82+
8083
- name: Install dependencies
8184
run: |
8285
python -m pip install --upgrade pip

HISTORY.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ picows Release History
99
------------------
1010

1111
* Drop python 3.8 support
12+
* Strip extensions on Linux and MacOS. Reduce package size
1213

1314
1.9.0 (2025-06-05)
1415
------------------

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,10 @@ asyncio_default_fixture_loop_scope = "function"
5050
files = "picows"
5151
ignore_missing_imports = true
5252
strict = true
53+
54+
[tool.cibuildwheel]
55+
# Python that is used by github workers is build with -g flag
56+
# This flag is automatically passed when extensions are built
57+
# Add -g0 to negate -g.
58+
# This only affects our release builds when we are using cibuildwheel
59+
environment = "CFLAGS='-g0'"

setup.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,22 @@
22
import sys
33
from Cython.Build import cythonize
44
from setuptools import Extension, setup
5-
from setuptools.command.build_ext import build_ext
65

76
vi = sys.version_info
87
if vi < (3, 9):
98
raise RuntimeError('picows requires Python 3.9 or greater')
109

1110

12-
class CustomBuildExt(build_ext):
13-
def build_extensions(self):
14-
for ext in self.extensions:
15-
if ext.extra_compile_args:
16-
ext.extra_compile_args = [
17-
flag for flag in ext.extra_compile_args if flag != '-g'
18-
]
19-
if ext.extra_link_args:
20-
ext.extra_link_args = [
21-
flag for flag in ext.extra_link_args if flag != '-g'
22-
]
23-
24-
if os.name != 'nt':
25-
self.compiler.compiler_so = [
26-
flag for flag in self.compiler.compiler_so if flag != '-g'
27-
]
28-
self.compiler.linker_so = [
29-
flag for flag in self.compiler.linker_so if flag != '-g'
30-
]
31-
super().build_extensions()
32-
33-
3411
if os.name == 'nt':
35-
compile_args = ["/O2", "/DNDEBUG"]
36-
link_args = []
3712
libraries = ["Ws2_32"]
3813
else:
39-
compile_args = ["-O2", "-Wall", "-DNDEBUG", "-fno-strict-overflow", "-Wsign-compare", "-fPIC"]
40-
link_args = ["-Wl,-s"]
4114
libraries = None
4215

4316
cython_modules = [
4417
Extension(
4518
"picows.picows",
4619
["picows/picows.pyx"],
4720
libraries=libraries,
48-
extra_compile_args=compile_args,
49-
extra_link_args=link_args,
5021
)
5122
]
5223

@@ -55,13 +26,10 @@ def build_extensions(self):
5526
Extension(
5627
"examples.echo_client_cython",
5728
["examples/echo_client_cython.pyx"],
58-
extra_compile_args=compile_args,
59-
extra_link_args=link_args,
6029
)
6130
)
6231

6332
setup(
64-
cmdclass={'build_ext': CustomBuildExt},
6533
ext_modules=cythonize(
6634
cython_modules,
6735
compiler_directives={

0 commit comments

Comments
 (0)