-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
48 lines (39 loc) · 1.55 KB
/
setup.py
File metadata and controls
48 lines (39 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from setuptools import setup, Extension
import sys
import sysconfig
import os
import re
if sys.platform == 'darwin':
if os.environ.get('MACOSX_DEPLOYMENT_TARGET') is None:
depl_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
os.environ['MACOSX_DEPLOYMENT_TARGET'] = depl_target if depl_target is not None else '10.15'
flags = ["/std:c++20"] if sys.platform == "win32" else \
["-std=c++20", "-fvisibility=hidden", "-fvisibility-inlines-hidden", "-flto"]
lflags = [] if sys.platform == "win32" else \
["-flto"]
# If clang is used on Linux link with libc++
if sysconfig.get_platform().startswith('linux') and \
sysconfig.get_config_var('CXX').startswith('clang++'):
flags += ['-stdlib=libc++']
lflags += ['-stdlib=libc++']
# PyPy on macOS has broken LDCXXSHARED. Sigh
if sysconfig.get_platform().startswith('macosx') and \
sysconfig.get_config_var('implementation') == 'PyPy' and \
os.environ.get('LDCXXSHARED') is None :
ldcxxshared = sysconfig.get_config_var('LDCXXSHARED')
ldshared = sysconfig.get_config_var('LDSHARED')
ldcxxshared = re.sub(r'^gcc', 'g++', ldshared)
os.environ['LDCXXSHARED'] = ldcxxshared
defines: list[tuple[str, str | None]] = [("PY_SSIZE_T_CLEAN", None)]
setup(
ext_modules=[
Extension(
"processtitle._processtitle",
sources=["src/extension.cpp"],
include_dirs=["src/cpp/external"],
extra_compile_args=flags,
extra_link_args=lflags,
define_macros=defines,
)
]
)