File: setup.py

package info (click to toggle)
simgrid 4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 39,192 kB
  • sloc: cpp: 124,913; ansic: 66,744; python: 8,560; java: 6,773; fortran: 6,079; f90: 5,123; xml: 4,587; sh: 2,194; perl: 1,436; makefile: 111; lisp: 49; javascript: 7; sed: 6
file content (129 lines) | stat: -rwxr-xr-x 5,279 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# Copyright (c) 2019-2025. The SimGrid Team. All rights reserved.

# This program is free software; you can redistribute it and/or modify it
# under the terms of the license (GNU LGPL-2.1-only) which comes with this package.

# python3 setup.py sdist # Build a source distrib (building binary distribs is complex on linux)

# twine upload --repository-url https://test.pypi.org/legacy/ dist/simgrid-*.tar.gz # Upload to test
# pip3 install --user --index-url https://test.pypi.org/simple  simgrid

# Once it works, upload to the real infra.  /!\ you cannot modify a file once uploaded
# twine upload dist/simgrid-*.tar.gz

import os
import platform
import re
import subprocess
import sys
from distutils.version import LooseVersion

from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext

ENABLE_SMPI = False

if "--enable-smpi" in sys.argv:
    ENABLE_SMPI = True
    sys.argv.remove("--enable-smpi")


class CMakeExtension(Extension):
    def __init__(self, name, sourcedir=''):
        Extension.__init__(self, name, sources=[])
        self.sourcedir = os.path.abspath(sourcedir)


class CMakeBuild(build_ext):
    def run(self):
        try:
            out = subprocess.check_output(['cmake', '--version'])
        except OSError:
            raise RuntimeError(
                "CMake must be installed to build python bindings of SimGrid")

        if not os.path.exists("MANIFEST.in"):
            raise RuntimeError(
                "Please generate a MANIFEST.in file (configure SimGrid, and copy it here if you build out of tree)")

        for ext in self.extensions:
            self.build_extension(ext)

    def build_extension(self, ext):
        from pybind11 import get_cmake_dir
        extdir = os.path.abspath(os.path.dirname(
            self.get_ext_fullpath(ext.name)))
        enable_smpi = 'ON' if ENABLE_SMPI else 'OFF'
        cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir,
                      '-DPYTHON_EXECUTABLE=' + sys.executable,
                      '-Denable_smpi=' + enable_smpi,
                      '-Denable_java=OFF',
                      '-Denable_python=ON',
                      '-Dminimal-bindings=ON',
                      '-Dpybind11_DIR=' + get_cmake_dir()
                      ]

        cfg = 'Debug' if self.debug else 'Release'
        build_args = ['--config', cfg]

        cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg]
        build_args += ['--'] # no extra argument to make

        env = os.environ.copy()
        env['CXXFLAGS'] = '{} -DVERSION_INFO=\\"{}\\"'.format(env.get('CXXFLAGS', ''),
                                                              self.distribution.get_version())
        env['LDFLAGS'] = '{} -L{}'.format(env.get('LDFLAGS', ''), extdir)
        env['MAKEFLAGS'] = '-j'+str(os.cpu_count())
        # env['VERBOSE'] = "1" # Please, make, be verbose about the commands you run

        if not os.path.exists(self.build_temp):
            os.makedirs(self.build_temp)
        subprocess.check_call(['cmake', ext.sourcedir] +
                              cmake_args, cwd=self.build_temp, env=env)
        subprocess.check_call(['cmake', '--build', '.'] +
                              build_args, cwd=self.build_temp, env=env)


setup(
    name='simgrid',
    version='4.1',
    author='Da SimGrid Team',
    author_email='simgrid-community@inria.fr',
    description='Toolkit for scalable simulation of distributed applications',
    long_description=("SimGrid is a scientific instrument to study the behavior of "
                      "large-scale distributed systems such as Grids, Clouds, HPC or P2P "
                      "systems. It can be used to evaluate heuristics, prototype applications "
                      "or even assess legacy MPI applications.\n\n"
                      "This package contains a native library. Please install cmake, boost, pybind11 and a "
                      "C++ compiler before using pip3. On Debian/Ubuntu, this is as easy as\n"
                      "sudo apt install cmake libboost-dev pybind11-dev g++ gcc"),
    ext_modules=[CMakeExtension('simgrid')],
    cmdclass=dict(build_ext=CMakeBuild),
    install_requires=['pybind11>=2.4'],
    setup_requires=['pybind11>=2.4'],
    zip_safe=False,
    classifiers=[
        "Development Status :: 4 - Beta",
        "Environment :: Console",
        "Intended Audience :: Education",
        "Intended Audience :: Developers",
        "Intended Audience :: Science/Research",
        "Intended Audience :: System Administrators",
        "License :: OSI Approved :: GNU Lesser General Public License v2 (LGPLv2)",
        "Operating System :: POSIX",
        "Operating System :: MacOS",
        "Programming Language :: Python :: 3",
        "Programming Language :: C++",
        "Programming Language :: C",
        "Programming Language :: Fortran",
        "Programming Language :: Java",
        "Topic :: System :: Distributed Computing",
        "Topic :: System :: Systems Administration",
    ],
    url="https://simgrid.org",
    project_urls={
        'Tracker': 'https://framagit.org/simgrid/simgrid/issues/',
        'Source':  'https://framagit.org/simgrid/simgrid/',
        'Documentation': 'https://simgrid.org/doc/latest/',
    },
)