Update compiler options and patches.

pull/493/head
KmolYuan 2019-10-26 11:33:02 +08:00
parent 1771ae45ca
commit 74bc01193a
5 changed files with 20 additions and 10 deletions

View File

@ -1,3 +0,0 @@
#ifndef SOLVESPACE_CONFIG_H
#define SOLVESPACE_CONFIG_H
#endif

View File

@ -0,0 +1,15 @@
--- pyconfig.h 2016-01-27 10:54:56.000000000 +0300
+++ pyconfig.h 2016-03-28 11:46:48.000000000 +0300
@@ -100,6 +100,12 @@
/* Compiler specific defines */
+#ifdef __MINGW32__
+#ifdef _WIN64
+#define MS_WIN64
+#endif
+#endif
+
/* ------------------------------------------------------------------------*/
/* Microsoft C defines _MSC_VER */
#ifdef _MSC_VER

View File

@ -16,7 +16,8 @@ echo compiler=%COMPILER%>> "%DISTUTILS%"
echo patched file "%DISTUTILS%" echo patched file "%DISTUTILS%"
REM Apply the patch of "cygwinccompiler.py". REM Apply the patch of "cygwinccompiler.py".
REM Unix "patch" command of Msys. REM Unix "patch" command of Msys.
patch -N "%PYTHON_DIR%\lib\distutils\cygwinccompiler.py" "%HERE%\patch.diff" patch -N "%PYTHON_DIR%\lib\distutils\cygwinccompiler.py" "%HERE%\cygwinccompiler.diff"
patch -N "%PYTHON_DIR%\include\pyconfig.h" "%HERE%\pyconfig.diff"
REM Copy "vcruntime140.dll" to "libs". REM Copy "vcruntime140.dll" to "libs".
copy "%PYTHON_DIR%\vcruntime140.dll" "%PYTHON_DIR%\libs" copy "%PYTHON_DIR%\vcruntime140.dll" "%PYTHON_DIR%\libs"

View File

@ -22,7 +22,6 @@ from distutils import sysconfig
include_path = pth_join('python_solvespace', 'include') include_path = pth_join('python_solvespace', 'include')
src_path = pth_join('python_solvespace', 'src') src_path = pth_join('python_solvespace', 'src')
platform_path = pth_join(src_path, 'platform') platform_path = pth_join(src_path, 'platform')
extra_path = 'platform'
ver = sysconfig.get_config_var('VERSION') ver = sysconfig.get_config_var('VERSION')
lib = sysconfig.get_config_var('BINDIR') lib = sysconfig.get_config_var('BINDIR')
@ -76,9 +75,6 @@ if {'sdist', 'bdist'} & set(sys.argv):
for s in ('utilwin', 'utilunix', 'platform'): for s in ('utilwin', 'utilunix', 'platform'):
sources.append(pth_join(platform_path, f'{s}.cpp')) sources.append(pth_join(platform_path, f'{s}.cpp'))
elif system() == 'Windows': elif system() == 'Windows':
# Avoid compile error with CYTHON_USE_PYLONG_INTERNALS.
# https://github.com/cython/cython/issues/2670#issuecomment-432212671
macros.append(('MS_WIN64', None))
# Disable format warning # Disable format warning
compile_args.append('-Wno-format') compile_args.append('-Wno-format')
# Solvespace arguments # Solvespace arguments
@ -92,7 +88,7 @@ else:
def copy_source(dry_run): def copy_source(dry_run):
dir_util.copy_tree(pth_join('..', 'include'), include_path, dry_run=dry_run) dir_util.copy_tree(pth_join('..', 'include'), include_path, dry_run=dry_run)
dir_util.mkpath(pth_join('python_solvespace', 'src')) dir_util.mkpath(src_path)
for root, _, files in walk(pth_join('..', 'src')): for root, _, files in walk(pth_join('..', 'src')):
for f in files: for f in files:
if not f.endswith('.h'): if not f.endswith('.h'):
@ -104,6 +100,7 @@ def copy_source(dry_run):
file_util.copy_file(f, f_new, dry_run=dry_run) file_util.copy_file(f, f_new, dry_run=dry_run)
for f in sources[1:]: for f in sources[1:]:
file_util.copy_file(f.replace('python_solvespace', '..'), f, dry_run=dry_run) file_util.copy_file(f.replace('python_solvespace', '..'), f, dry_run=dry_run)
open(pth_join(platform_path, 'config.h'), 'a').close()
class Build(build_ext): class Build(build_ext):
@ -153,7 +150,7 @@ setup(
"python_solvespace.slvs", "python_solvespace.slvs",
sources, sources,
language="c++", language="c++",
include_dirs=[include_path, src_path, platform_path, extra_path] include_dirs=[include_path, src_path, platform_path]
)], )],
cmdclass={'build_ext': Build, 'sdist': PackSource}, cmdclass={'build_ext': Build, 'sdist': PackSource},
zip_safe=False, zip_safe=False,