Skip to content

Commit

Permalink
update setup.py to build ngtpy for a pypi distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
masajiro committed Sep 14, 2022
1 parent f3dec77 commit 55580de
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ if(${UNIX})
message(STATUS "Compile option -march=native is disabled.")
add_compile_options(-O2 -DNDEBUG)
else()
add_compile_options(-Ofast -march=native -DNDEBUG)
if(${NGT_AVX2})
add_compile_options(-Ofast -march=haswell -DNDEBUG)
else()
add_compile_options(-Ofast -march=native -DNDEBUG)
endif()
endif()
endif()
add_compile_options(-Wall)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.2
2.0.3
24 changes: 23 additions & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@

static_library_option = '--static-library'
static_library_native_option = '--static-library-native'
static_library_avx2_option = '--static-library-avx2'
included_library_option = '--included-library'
shared_library_without_avx_option = '--shared-library-without-avx'
shared_library_option = '--shared-library'
shared_library_avx2_option = '--shared-library-avx2'
version_file = 'VERSION'

static_library = False
Expand All @@ -27,6 +29,12 @@
sys.argv.remove(static_library_native_option)
static_library_native = True

static_library_avx2 = False
if static_library_avx2_option in sys.argv:
print('use the NGT static library with avx2')
sys.argv.remove(static_library_avx2_option)
static_library_avx2 = True

included_library = False
if included_library_option in sys.argv:
print('use the NGT included library')
Expand All @@ -45,6 +53,12 @@
sys.argv.remove(shared_library_option)
shared_library = True

shared_library_avx2 = False
if shared_library_avx2_option in sys.argv:
print('use the shared library with avx2')
sys.argv.remove(shared_library_avx2_option)
shared_library_avx2 = True

if sys.version_info.major >= 3:
from setuptools import Extension

Expand Down Expand Up @@ -94,6 +108,14 @@
'extra_compile_args': ['-std=c++11', '-Ofast', '-DNDEBUG'],
'sources': ['src/ngtpy.cpp']
}
elif static_library_avx2 or shared_library_avx2:
params = {
'include_dirs': ['/usr/local/include',
pybind11.get_include(True),
pybind11.get_include(False)],
'extra_compile_args': ['-std=c++11', '-Ofast', '-march=haswell', '-DNDEBUG'],
'sources': ['src/ngtpy.cpp']
}
else:
params = {
'include_dirs': ['/usr/local/include',
Expand Down Expand Up @@ -123,7 +145,7 @@
'extra_objects': ['../build-ngtpy-release/lib/NGT/libngt.a'],
'libraries': [openmplib, 'blas', 'lapack'],
}
if static_library or static_library_native:
if static_library or static_library_native or static_library_avx2:
params.update(static_lib_params)
elif included_library:
params.update(included_lib_params)
Expand Down

0 comments on commit 55580de

Please sign in to comment.