Previous The C++ module file |
Parent How to create a saxpy python module |
Outline | Next Peformances tests |
Now, let's write the setup.py file :
First, we have to import tools to make the installation of our module :
1 2 3 4 5 6 7 8 9 |
from setuptools import setup from setuptools import Extension from setuptools import find_packages import sys import os from platform import system import subprocess import numpy as np |
1 2 3 4 5 6 7 8 |
try: from Cython.Distutils import build_ext except ImportError: use_cython = False print("Cython not found") raise Exception('Please install Cython on your system') else: use_cython = True |
1 2 3 4 5 6 7 |
NAME = 'saxpypython' VERSION = '1.0.0' AUTHOR = 'Asterics developers' AUTHOR_EMAIL = 'pierre.aubert@lapp.in2p3.fr' URL = '' DESCRIPTION = 'Asterics HPC saxpy python module' LICENSE = 'Cecil-C' |
1 2 3 4 5 6 7 8 |
# Remove the "-Wstrict-prototypes" compiler option, which isn't valid for C++. import distutils.sysconfig cfg_vars = distutils.sysconfig.get_config_vars() for key, value in cfg_vars.items(): if type(value) == str: value = value.replace("-Wstrict-prototypes", "") value = value.replace("-DNDEBUG", "") cfg_vars[key] = value |
1 |
extra_compile_args = ['-Werror', '-march=native', '-mtune=native', '-ftree-vectorize', '-mavx2', '-O3', '-DVECTOR_ALIGNEMENT=32', '-g'] |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
packageName = 'saxpypython' ext_modules = [ Extension(packageName, ['@CMAKE_CURRENT_SOURCE_DIR@/saxpypython.cpp', '@CMAKE_CURRENT_SOURCE_DIR@/saxpy_intrinsics.cpp', '@CMAKE_CURRENT_SOURCE_DIR@/saxpyWrapper.cpp' ], libraries=[], library_dirs=[], runtime_library_dirs=[], extra_link_args=[], extra_compile_args=extra_compile_args, include_dirs=['@CMAKE_CURRENT_SOURCE_DIR@/', np.get_include()] ) ] |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
try: setup(name = NAME, version=VERSION, ext_modules=ext_modules, description=DESCRIPTION, install_requires=['numpy', 'cython'], author=AUTHOR, author_email=AUTHOR_EMAIL, license=LICENSE, url=URL, classifiers=[ 'Intended Audience :: Science/Research', 'License :: OSI Approved ::Cecil-C', 'Operating System :: OS Independent', 'Programming Language :: Python :: 3', 'Topic :: Scientific/Engineering :: Astronomy', 'Development Status :: 3 - Alpha'], ) except Exception as e: print(str(e)) sys.exit(-1) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
''' Auteur : Pierre Aubert Mail : aubertp7@gmail.com Licence : CeCILL-C ''' from setuptools import setup from setuptools import Extension from setuptools import find_packages import sys import os from platform import system import subprocess import numpy as np try: from Cython.Distutils import build_ext except ImportError: use_cython = False print("Cython not found") raise Exception('Please install Cython on your system') else: use_cython = True NAME = 'saxpypython' VERSION = '1.0.0' AUTHOR = 'Asterics developers' AUTHOR_EMAIL = 'pierre.aubert@lapp.in2p3.fr' URL = '' DESCRIPTION = 'Asterics HPC saxpy python module' LICENSE = 'Cecil-C' # Remove the "-Wstrict-prototypes" compiler option, which isn't valid for C++. import distutils.sysconfig cfg_vars = distutils.sysconfig.get_config_vars() for key, value in cfg_vars.items(): if type(value) == str: value = value.replace("-Wstrict-prototypes", "") value = value.replace("-DNDEBUG", "") cfg_vars[key] = value extra_compile_args = ['-Werror', '-march=native', '-mtune=native', '-ftree-vectorize', '-mavx2', '-O3', '-DVECTOR_ALIGNEMENT=32', '-g'] packageName = 'saxpypython' ext_modules = [ Extension(packageName, ['@CMAKE_CURRENT_SOURCE_DIR@/saxpypython.cpp', '@CMAKE_CURRENT_SOURCE_DIR@/saxpy_intrinsics.cpp', '@CMAKE_CURRENT_SOURCE_DIR@/saxpyWrapper.cpp' ], libraries=[], library_dirs=[], runtime_library_dirs=[], extra_link_args=[], extra_compile_args=extra_compile_args, include_dirs=['@CMAKE_CURRENT_SOURCE_DIR@/', np.get_include()] ) ] try: setup(name = NAME, version=VERSION, ext_modules=ext_modules, description=DESCRIPTION, install_requires=['numpy', 'cython'], author=AUTHOR, author_email=AUTHOR_EMAIL, license=LICENSE, url=URL, classifiers=[ 'Intended Audience :: Science/Research', 'License :: OSI Approved ::Cecil-C', 'Operating System :: OS Independent', 'Programming Language :: Python :: 3', 'Topic :: Scientific/Engineering :: Astronomy', 'Development Status :: 3 - Alpha'], ) except Exception as e: print(str(e)) sys.exit(-1) |
Previous The C++ module file |
Parent How to create a saxpy python module |
Outline | Next Peformances tests |