Skip to content

Commit

Permalink
Fixing windows python build
Browse files Browse the repository at this point in the history
  • Loading branch information
msoos committed Oct 16, 2023
1 parent a0ac130 commit cd4e228
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
8 changes: 4 additions & 4 deletions python/src/pyunigen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
14 changes: 11 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 = [
Expand Down Expand Up @@ -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++",
)
Expand Down

0 comments on commit cd4e228

Please sign in to comment.