Skip to content
Snippets Groups Projects
Commit 5ef69716 authored by Hkorb's avatar Hkorb
Browse files

fixes setup.py

parent 31002729
No related branches found
No related tags found
1 merge request!84Python bindings, amd, actuator line
......@@ -10,8 +10,11 @@ from setuptools.command.install import install
from setuptools.command.develop import develop
from distutils.version import LooseVersion
# Installation via pip: pip install -e .
# If GPU backend: pip install -e . --install-option="--GPU"
"""
Install python wrapper of virtual fluids
Install GPU backend with option --GPU
(pass to pip via --install-option="--GPU")
"""
vf_cmake_args = [
"-DBUILD_VF_PYTHON_BINDINGS=ON",
......@@ -36,6 +39,7 @@ vf_gpu_cmake_args = [
"-DBUILD_VF_UNIT_TESTS:BOOL=OFF",
]
GPU = False
class CommandMixin:
user_options = [
......@@ -46,12 +50,23 @@ class CommandMixin:
super().initialize_options()
self.GPU = False
def finalize_options(self):
super().finalize_options()
def run(self):
global GPU
GPU = GPU or self.GPU
super().run()
class InstallCommand(CommandMixin, install):
user_options = getattr(install, 'user_options', []) + CommandMixin.user_options
class DevelopCommand(CommandMixin, develop):
user_options = getattr(develop, 'user_options', []) + CommandMixin.user_options
class CMakeExtension(Extension):
def __init__(self, name, sourcedir=''):
Extension.__init__(self, name, sources=[])
......@@ -99,7 +114,7 @@ class CMakeBuild(CommandMixin, build_ext):
build_args += ['--', '-j2']
cmake_args.extend(vf_cmake_args)
cmake_args.extend(vf_gpu_cmake_args if self.GPU else vf_cpu_cmake_args)
cmake_args.extend(vf_gpu_cmake_args if GPU else vf_cpu_cmake_args)
env = os.environ.copy()
env['CXXFLAGS'] = '{} -DVERSION_INFO=\\"{}\\"'.format(env.get('CXXFLAGS', ''),
......@@ -117,6 +132,6 @@ setup(
name='pyfluids',
version='0.0.1',
ext_modules=[CMakeExtension('pyfluids')],
cmdclass={"install": InstallCommand, "develop": DevelopCommand, "build_ext":CMakeBuild},
cmdclass={"install": InstallCommand, "develop": DevelopCommand, "build_ext": CMakeBuild},
zip_safe=False,
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment