Logo AND Algorithmique Numérique Distribuée

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