Skip to content

Commit

Permalink
enable build in conda env for win32
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Jochheim committed Jan 13, 2025
1 parent 93a4816 commit 57bf326
Showing 1 changed file with 28 additions and 19 deletions.
47 changes: 28 additions & 19 deletions build/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ def locate_boost():
if in_conda():
if "CONDA_PREFIX" in os.environ.keys():
data_pathname = os.environ["CONDA_PREFIX"]
if sys.platform =="win32":
data_pathname = os.path.join(data_pathname, "Library")
else:
data_pathname = sysconfig.get_path("data") # just for readthedocs build
include_dirs = data_pathname + os.path.sep + 'include'
Expand Down Expand Up @@ -262,28 +264,35 @@ def build_extensions(self):

print('- extra link args: %s' % self.extensions[0].extra_link_args)

# Replace current compiler to g++
self.compiler.compiler_so[0] = "g++"
self.compiler.compiler_so.insert(2, "-shared")
if sys.platform != "win32":
# Replace current compiler to g++
self.compiler.compiler_so[0] = "g++"
self.compiler.compiler_so.insert(2, "-shared")

# Remove compiler flags if we can
remove_flags = ["-Wstrict-prototypes", "-Wall"]
for remove_flag in remove_flags:
try:
self.compiler.compiler_so.remove(remove_flag)
except ValueError:
print('Warning: compiler flag %s is not present, cannot remove it.' % remove_flag)
pass
# Remove compiler flags if we can
remove_flags = ["-Wstrict-prototypes", "-Wall"]
for remove_flag in remove_flags:
try:
self.compiler.compiler_so.remove(remove_flag)
except ValueError:
print('Warning: compiler flag %s is not present, cannot remove it.' % remove_flag)
pass

# Source: https://stackoverflow.com/questions/9723793/undefined-reference-to-boostsystemsystem-category-when-compiling
vina_compiler_options = [
"-std=c++11",
"-Wno-long-long",
"-pedantic",
'-DBOOST_ERROR_CODE_HEADER_ONLY'
]

print('- compiler options: %s' % (self.compiler.compiler_so + vina_compiler_options))
if sys.platform=="win32":
vina_compiler_options = [
"/std=c++11",
'/DBOOST_ERROR_CODE_HEADER_ONLY'
]
print('%s compiler options: %s' % (self.compiler.compiler_type, vina_compiler_options))
else:
vina_compiler_options = [
"/std:c++11",
"/Wall",
'-DBOOST_ERROR_CODE_HEADER_ONLY'
]
print('- compiler options: %s' % (self.compiler.compiler_so + vina_compiler_options))


for ext in self.extensions:
ext.extra_compile_args += vina_compiler_options
Expand Down

0 comments on commit 57bf326

Please sign in to comment.