diff --git a/MANIFEST.in b/MANIFEST.in index d6618e1b8..04ce10827 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,4 @@ include MANIFEST.in -include dmoj/cptbox/_cptbox.pyx include dmoj/cptbox/*.cpp include dmoj/cptbox/*.h include dmoj/cptbox/syscalls/aliases.list @@ -11,9 +10,8 @@ include dmoj/wbox/dmsec32.dll include dmoj/wbox/dmsec64.dll include dmoj/wbox/getaddr32.exe include dmoj/wbox/getaddr64.exe -include dmoj/wbox/_wbox.pyx include dmoj/wbox/*.cpp include dmoj/wbox/*.h -exclude dmoj/cptbox/_cptbox.cpp -exclude dmoj/cptbox/_wbox.cpp +exclude dmoj/cptbox/_cptbox.pyx +exclude dmoj/wbox/_wbox.pyx diff --git a/setup.py b/setup.py index 960a882f7..e4d1948ca 100644 --- a/setup.py +++ b/setup.py @@ -16,13 +16,17 @@ from setuptools.command import build_ext from setuptools.command.build_ext import build_ext as build_ext_old +has_pyx = os.path.exists(os.path.join(os.path.dirname(__file__), 'dmoj', 'cptbox', '_cptbox.pyx')) + try: from Cython.Build import cythonize except ImportError: - print('You need to install cython first before installing DMOJ.', file=sys.stderr) - print('Run: pip install cython', file=sys.stderr) - print('Or if you do not have pip: easy_install cython', file=sys.stderr) - sys.exit(1) + if has_pyx: + print('You need to install cython first before installing DMOJ.', file=sys.stderr) + print('Run: pip install cython', file=sys.stderr) + print('Or if you do not have pip: easy_install cython', file=sys.stderr) + sys.exit(1) + cythonize = lambda x: x class build_ext_dmoj(build_ext_old): @@ -64,16 +68,21 @@ def unavailable(self, e): cptbox_sources = ['_cptbox.pyx', 'helper.cpp', 'ptdebug.cpp', 'ptdebug_x86.cpp', 'ptdebug_x64.cpp', 'ptdebug_x86_on_x64.cpp', 'ptdebug_x32.cpp', 'ptdebug_arm.cpp', 'ptproc.cpp'] +if not has_pyx: + wbox_sources[0] = wbox_sources[0].replace('.pyx', '.cpp') + cptbox_sources[0] = cptbox_sources[0].replace('.pyx', '.cpp') + SOURCE_DIR = os.path.dirname(__file__) wbox_sources = [os.path.join(SOURCE_DIR, 'dmoj', 'wbox', f) for f in wbox_sources] cptbox_sources = [os.path.join(SOURCE_DIR, 'dmoj', 'cptbox', f) for f in cptbox_sources] extensions = [Extension('dmoj.checkers._checker', sources=['dmoj/checkers/_checker.c'])] -if os.name == 'nt': +if os.name == 'nt' or 'sdist' in sys.argv: extensions += [Extension('dmoj.wbox._wbox', sources=wbox_sources, language='c++', libraries=['netapi32', 'advapi32', 'ole32'], define_macros=[('UNICODE', None)])] -else: + +if os.name != 'nt' or 'sdist' in sys.argv: libs = ['rt'] if sys.platform.startswith('freebsd'): libs += ['procstat'] @@ -90,7 +99,7 @@ def unavailable(self, e): setup( name='dmoj', - version='0.1', + version='1.0.0', packages=find_packages(), package_data={ 'dmoj.cptbox': ['syscalls/aliases.list', 'syscalls/*.tbl'],