Logo AND Algorithmique Numérique Distribuée

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