-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsetup.py
111 lines (93 loc) · 3.22 KB
/
setup.py
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
#!/usr/bin/env python
import sys
from os import path, walk
from pathlib import Path
from setuptools import setup, find_packages
from setuptools.command.build_py import build_py
package_name = "bullet_utils"
package_version = "1.0.0"
class custom_build_py(build_py):
"""Build the documentation prior to the package.
Args:
build_py (class): inherit from the build_py class which builds the current
python package.
"""
def run(self):
# Try to build the doc and install it.
try:
# Get the mpi_cmake_module build doc method
from mpi_cmake_modules.documentation_builder import (
build_documentation,
)
build_documentation(
str((Path(self.build_lib) / package_name / "doc").absolute()),
str(Path(__file__).parent.absolute()),
package_version,
)
except ImportError as e:
print(
"The documentation is not being built as the "
"mpi_cmake_modules is not found",
file=sys.stderr,
)
# distutils uses old-style classes, so no super()
build_py.run(self)
def find_resources(package_name):
"""Find the relative path of files under the resource folder."""
resources = []
package_dir = path.join("src", package_name)
resources_dir = path.join(package_dir, "resources")
for (root, _, files) in walk(resources_dir):
for afile in files:
if (
afile != package_name
and not afile.endswith(".DS_Store")
and not afile.endswith(".py")
):
rel_dir = path.relpath(root, package_dir)
src = path.join(rel_dir, afile)
resources.append(src)
return resources
with open(path.join(path.dirname(path.realpath(__file__)), "readme.md"), "r") as fh:
long_description = fh.read()
# Find the resource files.
resources = find_resources(package_name)
# Install nodes and demos.
scripts_list = []
for (root, _, files) in walk(path.join("demos")):
for demo_file in files:
scripts_list.append(path.join(root, demo_file))
# Setup the package
setup(
name=package_name,
version="1.0.0",
package_dir={
"": "src",
},
packages=find_packages(where="src"),
package_data={package_name: resources},
scripts=scripts_list,
# required dependencies.
install_requires=["setuptools", "pybullet", "importlib_resources"],
# optional (hack) dependencies.
tests_require=["pytest", "mpi_cmake_modules"],
#
zip_safe=True,
maintainer="mnaveau",
maintainer_email="[email protected]",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/pypa/sampleproject",
description="Wrapper around the pybullet interface using pinocchio.",
license="BSD-3-clause",
entry_points={
"console_scripts": [],
},
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: BSD-3-clause",
"Operating System :: OS Independent",
],
python_requires=">=3.6",
cmdclass={"build_py": custom_build_py},
)