Skip to content

Commit 9edd053

Browse files
authored
Merge pull request #56 from Tapanhaz/master
Stripped debug symbols
2 parents ec288b9 + c88a5af commit 9edd053

File tree

2 files changed

+50
-8
lines changed

2 files changed

+50
-8
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description = "Ultra-fast websocket client and server for asyncio"
44
authors = [{name = "Taras Kozlov", email = "tarasko.projects@gmail.com"}]
55
requires-python = '>=3.9'
66
readme = "README.rst"
7-
license = "MIT"
7+
license-files = ["LICENSE"]
88
dynamic = ["version"]
99
keywords = ["websocket", "networking"]
1010
dependencies = ["multidict"]

setup.py

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,71 @@
1-
import sys
21
import os
3-
from setuptools import Extension, setup
2+
import sys
43
from Cython.Build import cythonize
4+
from setuptools import Extension, setup
5+
from setuptools.command.build_ext import build_ext
56

67
vi = sys.version_info
78
if vi < (3, 9):
89
raise RuntimeError('picows requires Python 3.9 or greater')
910

11+
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+
1034
if os.name == 'nt':
35+
compile_args = ["/O2", "/DNDEBUG"]
36+
link_args = []
1137
libraries = ["Ws2_32"]
1238
else:
39+
compile_args = ["-O2", "-Wall", "-DNDEBUG", "-fno-strict-overflow", "-Wsign-compare", "-fPIC"]
40+
link_args = ["-Wl,-s"]
1341
libraries = None
1442

1543
cython_modules = [
16-
Extension("picows.picows", ["picows/picows.pyx"], libraries=libraries)
17-
]
44+
Extension(
45+
"picows.picows",
46+
["picows/picows.pyx"],
47+
libraries=libraries,
48+
extra_compile_args=compile_args,
49+
extra_link_args=link_args,
50+
)
51+
]
1852

1953
if os.getenv("PICOWS_BUILD_EXAMPLES") is not None:
20-
cython_modules.append(Extension("examples.echo_client_cython", ["examples/echo_client_cython.pyx"]))
54+
cython_modules.append(
55+
Extension(
56+
"examples.echo_client_cython",
57+
["examples/echo_client_cython.pyx"],
58+
extra_compile_args=compile_args,
59+
extra_link_args=link_args,
60+
)
61+
)
2162

2263
setup(
64+
cmdclass={'build_ext': CustomBuildExt},
2365
ext_modules=cythonize(
2466
cython_modules,
2567
compiler_directives={
26-
'language_level': sys.version_info[0],
68+
'language_level': vi[0],
2769
'profile': False,
2870
'nonecheck': False,
2971
'boundscheck': False,
@@ -32,7 +74,7 @@
3274
'optimize.use_switch': False,
3375
'cdivision': True
3476
},
35-
annotate=True,
77+
annotate=False,
3678
gdb_debug=False
3779
),
3880
)

0 commit comments

Comments
 (0)