forked from Klebert-Engineering/python-cmake-wheel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py.in
87 lines (69 loc) · 2.45 KB
/
setup.py.in
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
#!/usr/bin/env python3
import os, sys, platform
import zipfile
import subprocess
import re
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
from distutils.command.bdist import bdist as _bdist
from distutils.command.sdist import sdist as _sdist
from distutils.command.install_lib import install_lib as _install_lib
if not os.path.exists('@WHEEL_DEPLOY_DIRECTORY@'):
os.makedirs('@WHEEL_DEPLOY_DIRECTORY@', exist_ok=True)
# This is necessary to inform distutils that we are building
# a binary extension module, but we don't need to do anything.
class CMakeExtension(Extension):
def __init__(self, name, **kwa):
Extension.__init__(self, name, sources=[], **kwa)
class cmake_build_ext(build_ext):
def run(self):
self.build_temp = '@CMAKE_BINARY_DIR@'
self.build_lib = '@WHEEL_PACKAGE_DIR@'
if platform.system() == 'Linux':
self.fix_linux_loader_paths()
def fix_linux_loader_paths(self):
for f in os.listdir('@WHEEL_PACKAGE_DIR@'):
print(f"cmake_build_ext: Fixing {f}")
file_path = os.path.join('@WHEEL_PACKAGE_DIR@', f)
if f.endswith('.so'):
self.spawn(['patchelf', '--set-rpath', '$ORIGIN', file_path])
class bdist(_bdist):
def finalize_options(self):
_bdist.finalize_options(self)
self.dist_dir = '@WHEEL_DEPLOY_DIRECTORY@'
self.bdist_base = '@WHEEL_LIB_DIR@'
class sdist(_sdist):
def finalize_options(self):
_sdist.finalize_options(self)
self.dist_dir = '@WHEEL_DEPLOY_DIRECTORY@'
class install_lib(_install_lib):
def finalize_options(self):
_install_lib.finalize_options(self)
self.build_dir = '@WHEEL_LIB_DIR@'
setup(
name = "@WHEEL_NAME@",
version = "@WHEEL_VERSION@",
description = "@WHEEL_DESCRIPTION@",
author = "@WHEEL_AUTHOR@",
url = "@WHEEL_URL@",
ext_modules = [CMakeExtension("@WHEEL_TARGET@")],
keywords = "@WHEEL_NAME@",
python_requires = "@WHEEL_PYTHON_REQUIRES@",
install_requires = [
@WHEEL_MODULE_DEPENDENCIES_PYLIST@
],
package_dir = {"": "@[email protected]"},
packages = ["@WHEEL_NAME@"],
package_data = {
"@WHEEL_NAME@": ["*"]
},
cmdclass = {
'bdist': bdist,
'sdist': sdist,
'install_lib': install_lib,
'build_ext': cmake_build_ext,
},
entry_points = {
'maliput.backends': ["@WHEEL_MALIPUT_PLUGIN_ENTRY_POINT@"]
}
)