Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix return type for get_maxpid().
[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(
34                 "CMake must be installed to build python bindings of SimGrid")
35
36         if not os.path.exists("MANIFEST.in"):
37             raise RuntimeError(
38                 "Please generate a MANIFEST.in file (configure simgrid, and copy it here if you build out of tree)")
39
40         if platform.system() == "Windows":
41             cmake_version = LooseVersion(
42                 re.search(r'version\s*([\d.]+)', out.decode()).group(1))
43             if cmake_version < '3.1.0':
44                 raise RuntimeError("CMake >= 3.1.0 is required on Windows")
45
46         for ext in self.extensions:
47             self.build_extension(ext)
48
49     def build_extension(self, ext):
50         from pybind11 import get_cmake_dir
51         extdir = os.path.abspath(os.path.dirname(
52             self.get_ext_fullpath(ext.name)))
53         cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir,
54                       '-DPYTHON_EXECUTABLE=' + sys.executable,
55                       '-Denable_smpi=OFF',
56                       '-Denable_java=OFF',
57                       '-Denable_python=ON',
58                       '-Dminimal-bindings=ON',
59                       '-Dpybind11_DIR=' + get_cmake_dir()
60                       ]
61
62         cfg = 'Debug' if self.debug else 'Release'
63         build_args = ['--config', cfg]
64
65         if platform.system() == "Windows":
66             cmake_args += [
67                 '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}'.format(cfg.upper(), extdir)]
68             if sys.maxsize > 2**32:
69                 cmake_args += ['-A', 'x64']
70             build_args += ['--', '/m']
71         else:
72             cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg]
73             build_args += ['--', '-j4']
74
75         env = os.environ.copy()
76         env['CXXFLAGS'] = '{} -DVERSION_INFO=\\"{}\\"'.format(env.get('CXXFLAGS', ''),
77                                                               self.distribution.get_version())
78         if not os.path.exists(self.build_temp):
79             os.makedirs(self.build_temp)
80         subprocess.check_call(['cmake', ext.sourcedir] +
81                               cmake_args, cwd=self.build_temp, env=env)
82         subprocess.check_call(['cmake', '--build', '.'] +
83                               build_args, cwd=self.build_temp)
84
85
86 setup(
87     name='simgrid',
88     version='3.25.1',
89     author='Da SimGrid Team',
90     author_email='simgrid-devel@lists.gforge.inria.fr',
91     description='Toolkit for scalable simulation of distributed applications',
92     long_description=("SimGrid is a scientific instrument to study the behavior of "
93                       "large-scale distributed systems such as Grids, Clouds, HPC or P2P "
94                       "systems. It can be used to evaluate heuristics, prototype applications "
95                       "or even assess legacy MPI applications.\n\n"
96                       "This package contains a native library. Please install cmake, boost, pybind11 and a "
97                       "C++ compiler before using pip3. On Debian/Ubuntu, this is as easy as\n"
98                       "sudo apt install cmake libboost-dev pybind11-dev g++ gcc"),
99     ext_modules=[CMakeExtension('simgrid')],
100     cmdclass=dict(build_ext=CMakeBuild),
101     install_requires=['pybind11>=2.4'],
102     setup_requires=['pybind11>=2.4'],
103     zip_safe=False,
104     classifiers=[
105         "Development Status :: 4 - Beta",
106         "Environment :: Console",
107         "Intended Audience :: Education",
108         "Intended Audience :: Developers",
109         "Intended Audience :: Science/Research",
110         "Intended Audience :: System Administrators",
111         "License :: OSI Approved :: GNU Lesser General Public License v2 (LGPLv2)",
112         "Operating System :: POSIX",
113         "Operating System :: MacOS",
114         "Operating System :: Microsoft :: Windows",
115         "Programming Language :: Python :: 3",
116         "Programming Language :: C++",
117         "Programming Language :: C",
118         "Programming Language :: Fortran",
119         "Programming Language :: Java",
120         "Topic :: System :: Distributed Computing",
121         "Topic :: System :: Systems Administration",
122     ],
123     url="https://simgrid.org",
124     project_urls={
125         'Tracker': 'https://framagit.org/simgrid/simgrid/issues/',
126         'Source':  'https://framagit.org/simgrid/simgrid/',
127         'Documentation': 'https://simgrid.org/doc/latest/',
128     },
129 )