diff --git a/python/src/pyunigen.cpp b/python/src/pyunigen.cpp index d46111f..c12019f 100644 --- a/python/src/pyunigen.cpp +++ b/python/src/pyunigen.cpp @@ -483,9 +483,12 @@ PyMODINIT_FUNC PyInit_pyunigen(void) }; m = PyModule_Create(&moduledef); + if (!m) return NULL; // Add the version string so users know what version of UniGen // they're using. +#if defined(_MSC_VER) +#else if (PyModule_AddStringConstant(m, "__version__", UNIGEN_FULL_VERSION) == -1) { Py_DECREF(m); return NULL; @@ -494,10 +497,7 @@ PyMODINIT_FUNC PyInit_pyunigen(void) Py_DECREF(m); return NULL; } - - if (!m) { - return NULL; - } +#endif // Add the PySampler type Py_INCREF(&pyunigen_PySamplerType); diff --git a/setup.py b/setup.py index d234ba4..798d4a6 100644 --- a/setup.py +++ b/setup.py @@ -25,11 +25,11 @@ import sys import os -import platform from setuptools import Extension, setup import sysconfig import toml import pathlib +from sys import platform def _parse_toml(pyproject_path): pyproject_text = pyproject_path.read_text() @@ -47,6 +47,14 @@ def _parse_toml(pyproject_path): def gen_modules(version): + if platform == "win32" or platform == "cygwin": + extra_compile_args_val = ['/std:c++17', "/DCMS_LOCAL_BUILD=1", "/DUNIGEN_FULL_VERSION=\""+version+"\""] + define_macros_val = [("TRACE", "")] + + else: + extra_compile_args_val = ['-std=c++17'] + define_macros_val = [('CMS_LOCAL_BUILD', 1),("TRACE", ""),("UNIGEN_FULL_VERSION", "\""+version+"\"")] + modules = Extension( name = "pyunigen", sources = [ @@ -105,8 +113,8 @@ def gen_modules(version): "python/arjun/python/src/GitSHA1.cpp", "python/arjun/src/simplify.cpp", ], - extra_compile_args = ['-std=c++17'], - define_macros = [('CMS_LOCAL_BUILD', 1),("TRACE", ""),("UNIGEN_FULL_VERSION", "\""+version+"\"")], + extra_compile_args = extra_compile_args_val, + define_macros = define_macros_val, include_dirs = ["src/", "python/cryptominisat/src/", "python/cryptominisat/src/picosat/", "python/arjun/src/", "python/approxmc/src/"], language = "c++", )