Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[TO DELETE] Mess with instr includes.
[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_python=ON',
54                       '-Dminimal-bindings=ON',
55                       '-Dpybind11_DIR=' + get_cmake_dir()
56                       ]
57
58         cfg = 'Debug' if self.debug else 'Release'
59         build_args = ['--config', cfg]
60
61         cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg]
62         build_args += ['--', '-j4']
63
64         env = os.environ.copy()
65         env['CXXFLAGS'] = '{} -DVERSION_INFO=\\"{}\\"'.format(env.get('CXXFLAGS', ''),
66                                                               self.distribution.get_version())
67         if not os.path.exists(self.build_temp):
68             os.makedirs(self.build_temp)
69         subprocess.check_call(['cmake', ext.sourcedir] +
70                               cmake_args, cwd=self.build_temp, env=env)
71         subprocess.check_call(['cmake', '--build', '.'] +
72                               build_args, cwd=self.build_temp)
73
74
75 setup(
76     name='simgrid',
77     version='3.35.1',
78     author='Da SimGrid Team',
79     author_email='simgrid-community@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, pybind11 and a "
86                       "C++ compiler before using pip3. On Debian/Ubuntu, this is as easy as\n"
87                       "sudo apt install cmake libboost-dev pybind11-dev g++ gcc"),
88     ext_modules=[CMakeExtension('simgrid')],
89     cmdclass=dict(build_ext=CMakeBuild),
90     install_requires=['pybind11>=2.4'],
91     setup_requires=['pybind11>=2.4'],
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         "Programming Language :: Python :: 3",
104         "Programming Language :: C++",
105         "Programming Language :: C",
106         "Programming Language :: Fortran",
107         "Topic :: System :: Distributed Computing",
108         "Topic :: System :: Systems Administration",
109     ],
110     url="https://simgrid.org",
111     project_urls={
112         'Tracker': 'https://framagit.org/simgrid/simgrid/issues/',
113         'Source':  'https://framagit.org/simgrid/simgrid/',
114         'Documentation': 'https://simgrid.org/doc/latest/',
115     },
116 )