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