Skip to content

Commit

Permalink
Fix compilation in Mac OS X
Browse files Browse the repository at this point in the history
  • Loading branch information
vmg authored and nostrademons committed Feb 17, 2015
1 parent bee092c commit 455128d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
#!/usr/bin/env python
import sys
from setuptools import setup
from setuptools.command.sdist import sdist

_name_of_lib = 'libgumbo.so'
if sys.platform.startswith('darwin'):
_name_of_lib = 'libgumbo.dylib'
elif sys.platform.startswith('win'):
_name_of_lib = 'gumbo.dll'

class CustomSdistCommand(sdist):
"""Customized Sdist command, to copy libgumbo.so into the Python directory
so that it can be installed with `pip install`."""
def run(self):
try:
import shutil
shutil.copyfile('.libs/libgumbo.so', 'python/gumbo/libgumbo.so')
shutil.copyfile('.libs/' + _name_of_lib,
'python/gumbo/' + _name_of_lib)
sdist.run(self)
except IOError as e:
print(e)
Expand Down Expand Up @@ -172,6 +180,6 @@ def run(self):
classifiers=CLASSIFIERS,
packages=['gumbo'],
package_dir={'': 'python'},
package_data={'gumbo': ['libgumbo.so']},
package_data={'gumbo': [_name_of_lib]},
cmdclass={ 'sdist': CustomSdistCommand },
zip_safe=False)

0 comments on commit 455128d

Please sign in to comment.