Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
d9f7f2279157d9bf9368ef4bd7f54a711d23e538
[simgrid.git] / setup.py
1 # Copyright (c) 2019-2023. 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-2.1-only) 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         for ext in self.extensions:
44             self.build_extension(ext)
45
46     def build_extension(self, ext):
47         from pybind11 import get_cmake_dir
48         extdir = os.path.abspath(os.path.dirname(
49             self.get_ext_fullpath(ext.name)))
50         cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir,
51                       '-DPYTHON_EXECUTABLE=' + sys.executable,
52                       '-Denable_smpi=OFF',
53                       '-Denable_java=OFF',
54                       '-Denable_python=ON',
55                       '-Dminimal-bindings=ON',
56                       '-Dpybind11_DIR=' + get_cmake_dir()
57                       ]
58
59         cfg = 'Debug' if self.debug else 'Release'
60         build_args = ['--config', cfg]
61
62         cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg]
63         build_args += ['--', '-j4']
64
65         env = os.environ.copy()
66         env['CXXFLAGS'] = '{} -DVERSION_INFO=\\"{}\\"'.format(env.get('CXXFLAGS', ''),
67                                                               self.distribution.get_version())
68         if not os.path.exists(self.build_temp):
69             os.makedirs(self.build_temp)
70         subprocess.check_call(['cmake', ext.sourcedir] +
71                               cmake_args, cwd=self.build_temp, env=env)
72         subprocess.check_call(['cmake', '--build', '.'] +
73                               build_args, cwd=self.build_temp)
74
75
76 setup(
77     name='simgrid',
78     version='3.32.1',
79     author='Da SimGrid Team',
80     author_email='simgrid-community@inria.fr',
81     description='Toolkit for scalable simulation of distributed applications',
82     long_description=("SimGrid is a scientific instrument to study the behavior of "
83                       "large-scale distributed systems such as Grids, Clouds, HPC or P2P "
84                       "systems. It can be used to evaluate heuristics, prototype applications "
85                       "or even assess legacy MPI applications.\n\n"
86                       "This package contains a native library. Please install cmake, boost, pybind11 and a "
87                       "C++ compiler before using pip3. On Debian/Ubuntu, this is as easy as\n"
88                       "sudo apt install cmake libboost-dev pybind11-dev g++ gcc"),
89     ext_modules=[CMakeExtension('simgrid')],
90     cmdclass=dict(build_ext=CMakeBuild),
91     install_requires=['pybind11>=2.4'],
92     setup_requires=['pybind11>=2.4'],
93     zip_safe=False,
94     classifiers=[
95         "Development Status :: 4 - Beta",
96         "Environment :: Console",
97         "Intended Audience :: Education",
98         "Intended Audience :: Developers",
99         "Intended Audience :: Science/Research",
100         "Intended Audience :: System Administrators",
101         "License :: OSI Approved :: GNU Lesser General Public License v2 (LGPLv2)",
102         "Operating System :: POSIX",
103         "Operating System :: MacOS",
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 )