Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Correctly terminate a Comm which is failing immediately.
[simgrid.git] / setup.py
1
2
3 # python3 setup.py sdist # Build a source distrib (building binary distribs is complex on linux)
4
5 # twine upload --repository-url https://test.pypi.org/legacy/ dist/simgrid-*.tar.gz # Upload to test
6 # pip3 install --user --index-url https://test.pypi.org/simple  simgrid
7
8 # Once it works, upload to the real infra.  /!\ you cannot modify a file once uploaded
9 # twine upload dist/simgrid-*.tar.gz
10
11 import os
12 import re
13 import sys
14 import platform
15 import subprocess
16
17 from setuptools import setup, Extension
18 from setuptools.command.build_ext import build_ext
19 from distutils.version import LooseVersion
20
21
22 class CMakeExtension(Extension):
23     def __init__(self, name, sourcedir=''):
24         Extension.__init__(self, name, sources=[])
25         self.sourcedir = os.path.abspath(sourcedir)
26
27
28 class CMakeBuild(build_ext):
29     def run(self):
30         try:
31             out = subprocess.check_output(['cmake', '--version'])
32         except OSError:
33             raise RuntimeError("CMake must be installed to build python bindings of SimGrid")
34         
35         if not os.path.exists("MANIFEST.in"):
36             raise RuntimeError("Please generate a MANIFEST.in file (configure simgrid, and copy it here if you build out of tree)")
37
38         if platform.system() == "Windows":
39             cmake_version = LooseVersion(re.search(r'version\s*([\d.]+)', out.decode()).group(1))
40             if cmake_version < '3.1.0':
41                 raise RuntimeError("CMake >= 3.1.0 is required on Windows")
42
43         for ext in self.extensions:
44             self.build_extension(ext)
45
46     def build_extension(self, ext):
47         extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
48         cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir,
49                       '-DPYTHON_EXECUTABLE=' + sys.executable,
50                       '-Denable_smpi=OFF',
51                       '-Denable_java=OFF',
52                       '-Denable_python=ON',
53                       '-Dminimal-bindings=ON']
54
55         cfg = 'Debug' if self.debug else 'Release'
56         build_args = ['--config', cfg]
57
58         if platform.system() == "Windows":
59             cmake_args += ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}'.format(cfg.upper(), extdir)]
60             if sys.maxsize > 2**32:
61                 cmake_args += ['-A', 'x64']
62             build_args += ['--', '/m']
63         else:
64             cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg]
65             build_args += ['--', '-j4']
66
67         env = os.environ.copy()
68         env['CXXFLAGS'] = '{} -DVERSION_INFO=\\"{}\\"'.format(env.get('CXXFLAGS', ''),
69                                                               self.distribution.get_version())
70         if not os.path.exists(self.build_temp):
71             os.makedirs(self.build_temp)
72         subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env)
73         subprocess.check_call(['cmake', '--build', '.'] + build_args, cwd=self.build_temp)
74
75 setup(
76     name='simgrid',
77     version='3.23.1',
78     author='Da SimGrid Team',
79     author_email='simgrid-devel@lists.gforge.inria.fr',
80     description='Toolkit for scalable simulation of distributed applications',
81     long_description=("SimGrid is a scientific instrument to study the behavior of "
82                       "large-scale distributed systems such as Grids, Clouds, HPC or P2P "
83                       "systems. It can be used to evaluate heuristics, prototype applications "
84                       "or even assess legacy MPI applications.\n\n"
85                       "This package contains a native library. Please install cmake boost and a "
86                       "C++ compiler before using pip. On Debian/Ubuntu, this is as easy as\n"                      
87                       "sudo apt install g++ gcc cmake libboost-all-dev"),
88     ext_modules=[CMakeExtension('simgrid')],
89     cmdclass=dict(build_ext=CMakeBuild),
90     install_requires=['pybind11>=2.3'],
91     setup_requires=['pybind11>=2.3'],
92     zip_safe=False,
93     classifiers=[
94       "Development Status :: 4 - Beta",
95       "Environment :: Console",
96       "Intended Audience :: Education",
97       "Intended Audience :: Developers",
98       "Intended Audience :: Science/Research",
99       "Intended Audience :: System Administrators",
100       "License :: OSI Approved :: GNU Lesser General Public License v2 (LGPLv2)",
101       "Operating System :: POSIX",
102       "Operating System :: MacOS",
103       "Operating System :: Microsoft :: Windows",
104       "Programming Language :: Python :: 3",
105       "Programming Language :: C++",
106       "Programming Language :: C",
107       "Programming Language :: Fortran",
108       "Programming Language :: Java",
109       "Topic :: System :: Distributed Computing",
110       "Topic :: System :: Systems Administration",
111     ],
112     url="https://simgrid.org",
113     project_urls={
114       'Tracker': 'https://framagit.org/simgrid/simgrid/issues/',
115       'Source':  'https://framagit.org/simgrid/simgrid/',
116       'Documentation': 'https://simgrid.org/doc/latest/',
117     },
118 )