Skip to content

Commit

Permalink
Fix bugs in install options.
Browse files Browse the repository at this point in the history
  • Loading branch information
emfomy committed Apr 2, 2019
1 parent 90e918a commit 92f71b2
Showing 1 changed file with 23 additions and 26 deletions.
49 changes: 23 additions & 26 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
class InstallCommand(install):

user_options = install.user_options + [
('no-ws', None, 'without CKIP Word Segmentation'),
('no-parser', None, 'without CKIP Parser'),
('no-ws', None, 'without CKIPWS'),
('no-parser', None, 'without CKIP-Parser'),
]

def __init__(self, *args, **kwargs):
Expand All @@ -40,31 +40,15 @@ def initialize_options(self):
def finalize_options(self):
super().finalize_options()

print('*'*100)
print(self.no_ws)
print(self.no_parser)
print('*'*100)
if self.no_ws:
print('Disable CKIPWS support!')
i = next((i for i, ext_module in enumerate(self.distribution.ext_modules) if ext_module.name == 'ckipws'), None)
if i is not None: del self.distribution.ext_modules[i]

if not self.no_ws:
self.__extensions.append(Extension('ckipws',
sources=['ckipws/ckipws.pyx'],
libraries=['WordSeg'],
))

if not self.no_parser:
self.__extensions.append(Extension('ckipparser',
sources=['ckipparser/ckipparser.pyx'],
libraries=['CKIPCoreNLP', 'CKIPParser', 'CKIPSRL', 'CKIPWS'],
))

def run(self):

print('*'*100)
print(self.user_options)
print('*'*100)

self.distribution.ext_modules = cythonize(self.__extensions, build_dir='build')
super().run()
if self.no_parser:
print('Disable CKIP-Parser support!')
i = next((i for i, ext_module in enumerate(self.distribution.ext_modules) if ext_module.name == 'ckipparser'), None)
if i is not None: del self.distribution.ext_modules[i]

setup(
name=about.__title__,
Expand Down Expand Up @@ -95,6 +79,19 @@ def run(self):
'Operating System :: POSIX :: Linux',
'Natural Language :: Chinese (Traditional)',
],
ext_modules=cythonize(
[
Extension('ckipws',
sources=['ckipws/ckipws.pyx'],
libraries=['WordSeg'],
),
Extension('ckipparser',
sources=['ckipparser/ckipparser.pyx'],
libraries=['CKIPCoreNLP', 'CKIPParser', 'CKIPSRL', 'CKIPWS'],
),
],
build_dir='build',
),
cmdclass={
'install': InstallCommand,
},
Expand Down

0 comments on commit 92f71b2

Please sign in to comment.