|
5 | 5 |
|
6 | 6 | # python3 setup.py sdist # Build a source distrib (building binary distribs is complex on linux) |
7 | 7 |
|
8 | | -# twine upload --repository-url https://test.pypi.org/legacy/ dist/fsmod-*.tar.gz # Upload to test |
9 | | -# pip3 install --user --index-url https://test.pypi.org/simple fsmod |
| 8 | +# python3 -m build --sdist # Build a source distrib (building binary distribs is complex on linux) |
| 9 | + |
| 10 | +# twine upload --repository-url https://test.pypi.org/legacy/ dist/dtlmod-*.tar.gz # Upload to test |
| 11 | +# pip3 install --extra-index-url https://test.pypi.org/simple dtlmod |
10 | 12 |
|
11 | 13 | # Once it works, upload to the real infra. /!\ you cannot modify a file once uploaded |
12 | | -# twine upload dist/fsmod-*.tar.gz |
| 14 | +# twine upload dist/dtlmod-*.tar.gz |
13 | 15 |
|
14 | 16 | import os |
15 | | -import platform |
16 | | -import re |
17 | | -import subprocess |
18 | 17 | import sys |
19 | | -from distutils.version import LooseVersion |
20 | | - |
21 | | -from setuptools import Extension, setup |
| 18 | +import subprocess |
| 19 | +from setuptools import setup, Extension |
22 | 20 | from setuptools.command.build_ext import build_ext |
23 | 21 |
|
24 | 22 | class CMakeExtension(Extension): |
25 | | - def __init__(self, name, sourcedir=''): |
26 | | - Extension.__init__(self, name, sources=[]) |
| 23 | + def __init__(self, name, sourcedir=""): |
| 24 | + super().__init__(name, sources=[]) |
27 | 25 | self.sourcedir = os.path.abspath(sourcedir) |
28 | 26 |
|
29 | 27 | class CMakeBuild(build_ext): |
30 | 28 | def run(self): |
31 | 29 | try: |
32 | | - out = subprocess.check_output(['cmake', '--version']) |
| 30 | + subprocess.check_output(["cmake", "--version"]) |
33 | 31 | except OSError: |
34 | | - raise RuntimeError( |
35 | | - "CMake must be installed to build python bindings of FSMod") |
36 | | - |
37 | | - if not os.path.exists("MANIFEST.in"): |
38 | | - raise RuntimeError( |
39 | | - "Please generate a MANIFEST.in file at the root of the source directory") |
| 32 | + raise RuntimeError("CMake must be installed to build the file-system-module") |
40 | 33 |
|
41 | 34 | for ext in self.extensions: |
42 | 35 | self.build_extension(ext) |
43 | 36 |
|
44 | 37 | def build_extension(self, ext): |
45 | 38 | from pybind11 import get_cmake_dir |
46 | | - extdir = os.path.abspath(os.path.dirname( |
47 | | - self.get_ext_fullpath(ext.name))) |
48 | | - cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir, |
49 | | - '-DPYTHON_EXECUTABLE=' + sys.executable, |
50 | | - '-Denable_python=ON', |
51 | | - '-Dpybind11_DIR=' + get_cmake_dir() |
52 | | - ] |
53 | | - |
54 | | - build_args = [] |
55 | | - |
56 | | - env = os.environ.copy() |
57 | | - env['CXXFLAGS'] = '{} -DVERSION_INFO=\\"{}\\"'.format(env.get('CXXFLAGS', ''), |
58 | | - self.distribution.get_version()) |
59 | | - env['LDFLAGS'] = '{} -L{}'.format(env.get('LDFLAGS', ''), extdir) |
60 | | - env['MAKEFLAGS'] = '-j'+str(os.cpu_count()) |
61 | | - # env['VERBOSE'] = "1" # Please, make, be verbose about the commands you run |
62 | 39 |
|
63 | | - if not os.path.exists(self.build_temp): |
64 | | - os.makedirs(self.build_temp) |
65 | | - subprocess.check_call(['cmake', ext.sourcedir] + |
66 | | - cmake_args, cwd=self.build_temp, env=env) |
67 | | - subprocess.check_call(['cmake', '--build', '.'] + |
68 | | - build_args, cwd=self.build_temp, env=env) |
| 40 | + extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name))) |
| 41 | + cmake_args = [ |
| 42 | + f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={extdir}", |
| 43 | + f"-DPYTHON_EXECUTABLE={sys.executable}", |
| 44 | + "-Denable_python=ON", |
| 45 | + f"-Dpybind11_DIR={get_cmake_dir()}", |
| 46 | + ] |
69 | 47 |
|
| 48 | + os.makedirs(self.build_temp, exist_ok=True) |
| 49 | + subprocess.check_call(["cmake", ext.sourcedir] + cmake_args, cwd=self.build_temp) |
| 50 | + subprocess.check_call(["cmake", "--build", "."], cwd=self.build_temp) |
70 | 51 |
|
71 | 52 | setup( |
72 | | - name='fsmod', |
73 | | - version='0.4.0', |
74 | | - author='The FSMod Team', |
75 | | - author_email='simgrid-community@inria.fr', |
76 | | - description='File System Module for SimGrid', |
77 | | - long_description=("This project implements a simulated file system "module" on top of SimGrid, to be " |
78 | | - "used in any SimGrid-based simulator. It supports the notion of partitions that store " |
79 | | - "directories that store files, with the expected operations (e.g., create files, move " |
80 | | - "files, unlink files, unlink directories, check for existence), and the notion of a file " |
81 | | - "descriptor with POSIX-like operations (open, seek, read, write, close).\n\n" |
82 | | - "This package contains a native library. Please install cmake, boost, pybind11 and a " |
83 | | - "C++ compiler before using pip3. On Debian/Ubuntu, this is as easy as\n" |
84 | | - "sudo apt install cmake libboost-dev pybind11-dev g++ gcc"), |
85 | | - ext_modules=[CMakeExtension('fsmod')], |
86 | | - cmdclass=dict(build_ext=CMakeBuild), |
87 | | - install_requires=['pybind11>=2.4'], |
88 | | - setup_requires=['pybind11>=2.4'], |
89 | | - zip_safe=False, |
90 | | - classifiers=[ |
91 | | - "Development Status :: 4 - Beta", |
92 | | - "Environment :: Console", |
93 | | - "Intended Audience :: Education", |
94 | | - "Intended Audience :: Developers", |
95 | | - "Intended Audience :: Science/Research", |
96 | | - "Intended Audience :: System Administrators", |
97 | | - "License :: OSI Approved :: GNU Lesser General Public License v2 (LGPLv2)", |
98 | | - "Operating System :: POSIX", |
99 | | - "Operating System :: MacOS", |
100 | | - "Programming Language :: Python :: 3", |
101 | | - "Programming Language :: C++", |
102 | | - "Topic :: System :: Distributed Computing", |
103 | | - "Topic :: System :: Systems Administration", |
104 | | - ], |
105 | | - project_urls={ |
106 | | - 'Source': 'https://github.com/simgrid/file-system-module', |
107 | | - }, |
| 53 | + ext_modules=[CMakeExtension("fsmod")], |
| 54 | + cmdclass={"build_ext": CMakeBuild}, |
108 | 55 | ) |
0 commit comments