Skip to content

Commit 6283eaf

Browse files
committed
Use proper options for flags
1 parent 2ed5a68 commit 6283eaf

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

setup.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,29 @@ class BuildExt(build_ext):
7171
'msvc': ['/EHsc'],
7272
'unix': [],
7373
}
74+
l_opts = {
75+
'msvc': [],
76+
'unix': [],
77+
}
7478

7579
if sys.platform == 'darwin':
80+
l_opts['unix'] += ['-stdlib=libc++', '-mmacosx-version-min=10.7']
7681
c_opts['unix'] += ['-stdlib=libc++', '-mmacosx-version-min=10.7']
7782

7883
def build_extensions(self):
7984
ct = self.compiler.compiler_type
80-
opts = self.c_opts.get(ct, [])
85+
c_opts = self.c_opts.get(ct, [])
86+
l_opts = self.l_opts.get(ct, [])
8187
if ct == 'unix':
82-
opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version())
83-
opts.append(cpp_flag(self.compiler))
88+
c_opts.append(cpp_flag(self.compiler))
8489
if has_flag(self.compiler, '-fvisibility=hidden'):
85-
opts.append('-fvisibility=hidden')
86-
elif ct == 'msvc':
87-
opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
90+
c_opts.append('-fvisibility=hidden')
91+
8892
for ext in self.extensions:
89-
ext.extra_compile_args = opts
93+
ext.extra_compile_args = c_opts
94+
ext.extra_link_args = l_opts
95+
ext.define_macros = [('VERSION_INFO', '"{}"'.format(self.distribution.get_version()))]
96+
9097
build_ext.build_extensions(self)
9198

9299
setup(

0 commit comments

Comments
 (0)