3 # python3 setup.py sdist # Build a source distrib (building binary distribs is complex on linux)
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
8 # Once it works, upload to the real infra. /!\ you cannot modify a file once uploaded
9 # twine upload dist/simgrid-*.tar.gz
17 from setuptools import setup, Extension
18 from setuptools.command.build_ext import build_ext
19 from distutils.version import LooseVersion
22 class CMakeExtension(Extension):
23 def __init__(self, name, sourcedir=''):
24 Extension.__init__(self, name, sources=[])
25 self.sourcedir = os.path.abspath(sourcedir)
28 class CMakeBuild(build_ext):
31 out = subprocess.check_output(['cmake', '--version'])
33 raise RuntimeError("CMake must be installed to build python bindings of SimGrid")
35 if not os.path.exists("MANIFEST.in"):
36 raise RuntimeError("Please generate a MANIFEST.in file (configure simgrid, and copy it here if you build out of tree)")
38 if platform.system() == "Windows":
39 cmake_version = LooseVersion(re.search(r'version\s*([\d.]+)', out.decode()).group(1))
40 if cmake_version < '3.1.0':
41 raise RuntimeError("CMake >= 3.1.0 is required on Windows")
43 for ext in self.extensions:
44 self.build_extension(ext)
46 def build_extension(self, ext):
47 extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
48 cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir,
49 '-DPYTHON_EXECUTABLE=' + sys.executable,
53 '-Dminimal-bindings=ON']
55 cfg = 'Debug' if self.debug else 'Release'
56 build_args = ['--config', cfg]
58 if platform.system() == "Windows":
59 cmake_args += ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}'.format(cfg.upper(), extdir)]
60 if sys.maxsize > 2**32:
61 cmake_args += ['-A', 'x64']
62 build_args += ['--', '/m']
64 cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg]
65 build_args += ['--', '-j4']
67 env = os.environ.copy()
68 env['CXXFLAGS'] = '{} -DVERSION_INFO=\\"{}\\"'.format(env.get('CXXFLAGS', ''),
69 self.distribution.get_version())
70 if not os.path.exists(self.build_temp):
71 os.makedirs(self.build_temp)
72 subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env)
73 subprocess.check_call(['cmake', '--build', '.'] + build_args, cwd=self.build_temp)
78 author='Da SimGrid Team',
79 author_email='simgrid-devel@lists.gforge.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 and a "
86 "C++ compiler before using pip. On Debian/Ubuntu, this is as easy as\n"
87 "sudo apt install g++ gcc cmake libboost-all-dev"),
88 ext_modules=[CMakeExtension('simgrid')],
89 cmdclass=dict(build_ext=CMakeBuild),
90 install_requires=['pybind11>=2.3'],
91 setup_requires=['pybind11>=2.3'],
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 "Operating System :: Microsoft :: Windows",
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",
112 url="https://simgrid.org",
114 'Tracker': 'https://framagit.org/simgrid/simgrid/issues/',
115 'Source': 'https://framagit.org/simgrid/simgrid/',
116 'Documentation': 'https://simgrid.org/doc/latest/',