Skip to content

Commit 8d6a261

Browse files
committed
Merge pull request #65 from AquaBindi/python-freebsd
Fix FreeBSD platform
2 parents 6e11732 + 4f15f57 commit 8d6a261

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

docs/changes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Version 0.8.1
66

77
To be released.
88

9+
- Fixed broken FreeBSD build. [:issue:`65` by Toshiharu Moriyama]
10+
911

1012
Version 0.8.0
1113
-------------

setup.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,22 @@ def spawn(self, cmd):
6969
spawn(cmd, dry_run=self.dry_run)
7070
from distutils.msvc9compiler import MSVCCompiler
7171
MSVCCompiler.spawn = spawn
72-
flags = ['/EHsc']
72+
flags = ['-c', '-O2', '/EHsc']
7373
link_flags = []
7474
else:
7575
flags = ['-fPIC', '-std=c++0x', '-Wall', '-Wno-parentheses']
7676
platform.mac_ver()
7777
if platform.system() in ['Darwin', 'FreeBSD']:
78-
os.environ['CC'] = os.environ['CXX'] = 'c++'
78+
os.environ.setdefault('CC', 'clang')
79+
os.environ.setdefault('CXX', 'clang++')
7980
orig_customize_compiler = distutils.sysconfig.customize_compiler
8081

8182
def customize_compiler(compiler):
8283
orig_customize_compiler(compiler)
83-
compiler.compiler[0] = 'c++'
84-
compiler.compiler_so[0] = 'c++'
85-
compiler.compiler_cxx[0] = 'c++'
86-
compiler.linker_so[0] = 'c++'
84+
compiler.compiler[0] = os.environ['CC']
85+
compiler.compiler_so[0] = os.environ['CXX']
86+
compiler.compiler_cxx[0] = os.environ['CXX']
87+
compiler.linker_so[0] = os.environ['CXX']
8788
return compiler
8889
distutils.sysconfig.customize_compiler = customize_compiler
8990
flags.extend([
@@ -120,15 +121,21 @@ def restore_cencode():
120121
if os.path.isfile(cencode_path):
121122
with open(cencode_path, 'w') as f:
122123
f.write(cencode_body)
123-
link_flags = ['-fPIC', '-lstdc++']
124+
125+
flags = ['-c', '-O3'] + flags
126+
127+
if platform.system() == 'FreeBSD':
128+
link_flags = ['-fPIC', '-lc++']
129+
else:
130+
link_flags = ['-fPIC', '-lstdc++']
124131

125132
sass_extension = Extension(
126133
'_sass',
127134
sources,
128135
library_dirs=[os.path.join('.', LIBSASS_DIR)],
129136
include_dirs=[os.path.join('.', LIBSASS_DIR)],
130137
depends=libsass_headers,
131-
extra_compile_args=['-c', '-O2'] + flags,
138+
extra_compile_args=flags,
132139
extra_link_args=link_flags,
133140
)
134141

0 commit comments

Comments
 (0)