Skip to content
Snippets Groups Projects
Commit 65f0df46 authored by Cristian Lalescu's avatar Cristian Lalescu
Browse files

install python package from cmake

parent 3b492861
No related branches found
No related tags found
1 merge request!23WIP: Feature/use cmake
Pipeline #45062 canceled
......@@ -120,3 +120,7 @@ export(TARGETS bfps FILE "${PROJECT_BINARY_DIR}/BFPSLibraryDepends.cmake")
install(EXPORT BFPS_EXPORT DESTINATION lib/)
#####################################################################################
## Install the python wrapper
install(CODE "execute_process(COMMAND python setup.py install --force --prefix=${CMAKE_INSTALL_PREFIX} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})")
#######################################################################
# #
# Copyright 2015 Max Planck Institute #
# for Dynamics and Self-Organization #
# #
# This file is part of bfps. #
# #
# bfps is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published #
# by the Free Software Foundation, either version 3 of the License, #
# or (at your option) any later version. #
# #
# bfps is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with bfps. If not, see <http://www.gnu.org/licenses/> #
# #
# Contact: Cristian.Lalescu@ds.mpg.de #
# #
#######################################################################
import os
import subprocess
src_file_list = ['hdf5_tools',
'full_code/get_rfields',
'full_code/NSVE_field_stats',
'full_code/native_binary_to_hdf5',
'full_code/postprocess',
'full_code/code_base',
'full_code/direct_numerical_simulation',
'full_code/NSVE',
'full_code/NSVEparticles',
'field_binary_IO',
'vorticity_equation',
'field',
'kspace',
'field_layout',
'field_descriptor',
'rFFTW_distributed_particles',
'distributed_particles',
'particles',
'particles_base',
'rFFTW_interpolator',
'interpolator',
'interpolator_base',
'fluid_solver',
'fluid_solver_base',
'fftw_tools',
'spline_n1',
'spline_n2',
'spline_n3',
'spline_n4',
'spline_n5',
'spline_n6',
'spline_n7',
'spline_n8',
'spline_n9',
'spline_n10',
'Lagrange_polys',
'scope_timer']
def get_file_dependency_list(src_file):
p = subprocess.Popen(
['g++', '-Ibfps/cpp', '-MM', 'bfps/cpp/' + src_file + '.cpp'],
stdout = subprocess.PIPE)
out, err = p.communicate()
p.terminate()
deps = str(out, 'ASCII').replace('\\\n', '')
return deps
def get_dependency_list():
ofile = open('dependencies.txt', 'w')
for src_file in src_file_list:
p = subprocess.Popen(
['g++', '-Ibfps/cpp', '-MM', 'bfps/cpp/' + src_file + '.cpp'],
stdout = subprocess.PIPE)
out, err = p.communicate()
p.terminate()
deps = str(out, 'ASCII').replace('\\\n', '')
print(deps.split()[0])
ofile.write(' '.join(deps.split()[1:]) + '\n')
ofile.close()
return None
if __name__ == '__main__':
#pass
get_dependency_list()
#######################################################################
# #
# Copyright 2015 Max Planck Institute #
# for Dynamics and Self-Organization #
# Copyright 2015-2019 Max Planck Institute #
# for Dynamics and Self-Organization #
# #
# This file is part of bfps. #
# #
......@@ -86,97 +86,6 @@ else:
print('This is bfps version ' + VERSION)
### lists of files and MANIFEST.in
src_file_list = [
'full_code/code_base',
'full_code/direct_numerical_simulation',
'full_code/NSVE',
'full_code/joint_acc_vel_stats',
'full_code/test',
'full_code/filter_test',
'full_code/field_test',
'full_code/symmetrize_test',
'full_code/field_output_test',
'full_code/get_rfields',
'full_code/field_single_to_double',
'full_code/resize',
'full_code/NSVE_field_stats',
'full_code/native_binary_to_hdf5',
'full_code/postprocess',
'field',
'kspace',
'field_layout',
'hdf5_tools',
'fftw_tools',
'vorticity_equation',
'field_binary_IO',
'spline_n1',
'spline_n2',
'spline_n3',
'spline_n4',
'spline_n5',
'spline_n6',
'spline_n7',
'spline_n8',
'spline_n9',
'spline_n10',
'Lagrange_polys',
'scope_timer',
'full_code/test_interpolation',
'full_code/NSVEparticles',
'full_code/NSVEcomplex_particles',
'full_code/NSVEp_extra_sampling',
'particles/particles_inner_computer']
particle_headers = [
'cpp/particles/abstract_particles_input.hpp',
'cpp/particles/abstract_particles_output.hpp',
'cpp/particles/abstract_particles_system.hpp',
'cpp/particles/alltoall_exchanger.hpp',
'cpp/particles/env_utils.hpp',
'cpp/particles/lock_free_bool_array.hpp',
'cpp/particles/p2p_computer_empty.hpp',
'cpp/particles/p2p_computer.hpp',
'cpp/particles/p2p_distr_mpi.hpp',
'cpp/particles/p2p_tree.hpp',
'cpp/particles/particles_adams_bashforth.hpp',
'cpp/particles/particles_distr_mpi.hpp',
'cpp/particles/particles_field_computer.hpp',
'cpp/particles/particles_generic_interp.hpp',
'cpp/particles/particles_inner_computer_empty.hpp',
'cpp/particles/particles_input_hdf5.hpp',
'cpp/particles/particles_output_hdf5.hpp',
'cpp/particles/particles_output_mpiio.hpp',
'cpp/particles/particles_output_sampling_hdf5.hpp',
'cpp/particles/particles_sampling.hpp',
'cpp/particles/particles_system_builder.hpp',
'cpp/particles/particles_system.hpp',
'cpp/particles/particles_utils.hpp']
full_code_headers = ['cpp/full_code/main_code.hpp',
'cpp/full_code/codes_with_no_output.hpp',
'cpp/full_code/NSVE_no_output.hpp',
'cpp/full_code/NSVEparticles_no_output.hpp']
header_list = (['cpp/base.hpp'] +
['cpp/fftw_interface.hpp'] +
['cpp/bfps_timer.hpp'] +
['cpp/omputils.hpp'] +
['cpp/shared_array.hpp'] +
['cpp/spline.hpp'] +
['cpp/' + fname + '.hpp'
for fname in src_file_list] +
particle_headers +
full_code_headers)
with open('MANIFEST.in', 'w') as manifest_in_file:
for fname in (['bfps/cpp/' + ff + '.cpp' for ff in src_file_list] +
['bfps/' + ff for ff in header_list]):
manifest_in_file.write('include {0}\n'.format(fname))
### libraries
libraries = extra_libraries
......@@ -204,66 +113,6 @@ class CompileLibCommand(distutils.cmd.Command):
self.disable_fftw_omp = (int(self.disable_fftw_omp) == 1)
return None
def run(self):
if not os.path.isdir('obj'):
os.makedirs('obj')
need_to_compile = True
if not os.path.isdir('obj/full_code'):
os.makedirs('obj/full_code')
need_to_compile = True
if not os.path.isdir('obj/particles'):
os.makedirs('obj/particles')
need_to_compile = True
if not os.path.isfile('bfps/libbfps.a'):
need_to_compile = True
else:
need_to_compile = False
ofile = 'bfps/libbfps.a'
libtime = datetime.datetime.fromtimestamp(os.path.getctime(ofile))
latest = libtime
eca = extra_compile_args
eca += ['-fPIC']
if self.timing_output:
eca += ['-DUSE_TIMINGOUTPUT']
if self.split_fftw_many:
eca += ['-DSPLIT_FFTW_MANY']
if self.fftw_estimate:
eca += ['-DUSE_FFTWESTIMATE']
if self.disable_fftw_omp:
eca += ['-DNO_FFTWOMP']
os.makedirs('cmake_build_dir', exist_ok = True)
os.chdir('cmake_build_dir')
subprocess.check_call(['cmake', '..'])
subprocess.check_call(['make', '-j4'])
os.chdir('..')
subprocess.check_call(['cp', 'cmake_build_dir/libbfps.a', 'bfps/'])
#for fname in src_file_list:
# ifile = 'bfps/cpp/' + fname + '.cpp'
# ofile = 'obj/' + fname + '.o'
# if not os.path.exists(ofile):
# need_to_compile_file = True
# else:
# need_to_compile_file = False
# if not need_to_compile:
# latest = libtime
# dependency_list = get_file_dependency_list(fname)
# for depname in dependency_list.split()[1:]:
# latest = max(latest,
# datetime.datetime.fromtimestamp(os.path.getctime(depname)))
# need_to_compile_file = (latest > libtime)
# if need_to_compile_file:
# command_strings = [compiler, '-c']
# command_strings += ['bfps/cpp/' + fname + '.cpp']
# command_strings += ['-o', 'obj/' + fname + '.o']
# command_strings += eca
# command_strings += ['-I' + idir for idir in include_dirs]
# command_strings.append('-Ibfps/cpp/')
# print(' '.join(command_strings))
# subprocess.check_call(command_strings)
#command_strings = ['ar', 'rvs', 'bfps/libbfps.a']
#command_strings += ['obj/' + fname + '.o' for fname in src_file_list]
#print(' '.join(command_strings))
#subprocess.check_call(command_strings)
### save compiling information
pickle.dump(
{'include_dirs' : include_dirs,
......@@ -278,26 +127,13 @@ class CompileLibCommand(distutils.cmd.Command):
protocol = 2)
return None
def get_file_dependency_list(src_file):
p = subprocess.Popen(
['g++', '-std=c++11', '-Ibfps/cpp', '-MM', 'bfps/cpp/' + src_file + '.cpp'],
stdout = subprocess.PIPE)
out, err = p.communicate()
p.terminate()
deps = str(out, 'ASCII').replace('\\\n', '')
return deps
from setuptools import setup
setup(
name = 'bfps',
packages = ['bfps', 'bfps/test'],
install_requires = ['numpy>=1.8', 'h5py>=2.2.1'],
cmdclass={'compile_library' : CompileLibCommand},
package_data = {'bfps': header_list +
['libbfps.a',
'install_info.pickle'] +
['test/B32p1e4_checkpoint_0.h5']},
package_data = {'bfps': ['test/B32p1e4_checkpoint_0.h5']},
entry_points = {
'console_scripts': [
'bfps = bfps.__main__:main',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment