1 # Copyright (c) 2019-2022. The SimGrid Team. All rights reserved.
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.
6 # python3 setup.py sdist # Build a source distrib (building binary distribs is complex on linux)
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
11 # Once it works, upload to the real infra. /!\ you cannot modify a file once uploaded
12 # twine upload dist/simgrid-*.tar.gz
20 from setuptools import setup, Extension
21 from setuptools.command.build_ext import build_ext
22 from distutils.version import LooseVersion
25 class CMakeExtension(Extension):
26 def __init__(self, name, sourcedir=''):
27 Extension.__init__(self, name, sources=[])
28 self.sourcedir = os.path.abspath(sourcedir)
31 class CMakeBuild(build_ext):
34 out = subprocess.check_output(['cmake', '--version'])
37 "CMake must be installed to build python bindings of SimGrid")
39 if not os.path.exists("MANIFEST.in"):
41 "Please generate a MANIFEST.in file (configure simgrid, and copy it here if you build out of tree)")
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")
49 for ext in self.extensions:
50 self.build_extension(ext)
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,
61 '-Dminimal-bindings=ON',
62 '-Dpybind11_DIR=' + get_cmake_dir()
65 cfg = 'Debug' if self.debug else 'Release'
66 build_args = ['--config', cfg]
68 if platform.system() == "Windows":
70 '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}'.format(cfg.upper(), extdir)]
71 if sys.maxsize > 2**32:
72 cmake_args += ['-A', 'x64']
73 build_args += ['--', '/m']
75 cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg]
76 build_args += ['--', '-j4']
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)
92 author='Da SimGrid Team',
93 author_email='simgrid-community@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'],
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",
126 url="https://simgrid.org",
128 'Tracker': 'https://framagit.org/simgrid/simgrid/issues/',
129 'Source': 'https://framagit.org/simgrid/simgrid/',
130 'Documentation': 'https://simgrid.org/doc/latest/',