-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
188 lines (172 loc) · 6.25 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# -*- coding: utf-8 -*-
"""
Copyright (c) 2023, University of Southampton
All rights reserved.
Licensed under the BSD 3-Clause License.
See LICENSE.md file in the project root for full license information.
"""
import os
import os.path
import subprocess
from setuptools import find_packages, setup
classifiers = [
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Scientific/Engineering",
"Topic :: Software Development",
]
def return_version():
"""Append annotation to version string to indicate development versions.
An empty (modulo comments and blank lines) .oplab_pipeline_commit_hash is used
to indicate a release, in which case nothing is appended to version
string as defined above.
"""
version = ""
path_to_hashfile = os.path.join(
os.path.dirname(__file__), ".oplab_pipeline_commit_hash"
)
if os.path.exists(path_to_hashfile):
commit_version = ""
with open(path_to_hashfile, "r") as f:
for line in f:
line = line.strip()
if len(line) == 0 or line[0] == "#":
# Ignore blank lines and comments, the latter being
# any line that begins with #.
continue
# First non-blank line is assumed to be the commit hash
commit_version = line
break
if len(commit_version) > 0:
version = commit_version
else:
version += ".dev0+unknown.commit"
return version
def git_command(args):
prefix = ["git"]
return subprocess.check_output(prefix + args).decode().strip()
def git_pep440_version():
# Is Git installed?
try:
subprocess.call(["git", "--version"], stdout=subprocess.PIPE)
except OSError:
print("The command git --version was not successful. Is git installed?")
return None
version_full = git_command(["describe", "--tags", "--dirty=.dirty"])
version_tag = git_command(["describe", "--tags", "--abbrev=0"])
version_tail = version_full[len(version_tag) :] # noqa
if version_tail == ".dirty":
version_tail = "+dirty"
return version_tag + version_tail.replace("-", ".dev", 1).replace("-", "+", 1)
def run_setup():
"""Get version from git, then install."""
# load long description from README.md
readme_file = "README.md"
if os.path.exists(readme_file):
long_description = open(readme_file, encoding="utf-8", errors="ignore").read()
else:
print("Could not find readme file to extract long_description.")
long_description = ""
# If .git directory is present, create oplab_pipeline_commit_hash accordingly
# to indicate version information
if os.path.exists(".git"):
# Provide commit hash or empty file to indicate release
sha1 = git_pep440_version()
print("SHA1 is", sha1)
if sha1 is None:
sha1 = "unknown-commit"
elif sha1 == "release":
sha1 = ""
commit_hash_header = (
"# DO NOT EDIT! "
"This file was automatically generated by setup.py of oplab_pipeline" # noqa
)
with open(".oplab_pipeline_commit_hash", "w") as f:
f.write(commit_hash_header + "\n")
f.write(sha1 + "\n")
print(
"Written .oplab_pipeline_commit_hash with the hash",
commit_hash_header,
"\n",
sha1,
)
else:
print(
"No .git repository was found. Will not be able to retrieve the version number."
)
oplab_pipeline_version = return_version()
setup(
name="oplab_pipeline",
version=oplab_pipeline_version,
author="Ocean Perception - University of Southampton",
author_email="miquel.massot-campos@soton.ac.uk",
description="Toolchain for AUV dive processing, camera calibration and image correction", # noqa
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/ocean-perception/oplab_pipeline",
packages=find_packages(where="src"),
package_dir={"": "src"},
classifiers=classifiers,
license="BSD",
entry_points={ # Optional
"console_scripts": [
"auv_nav = auv_nav.auv_nav:main",
"auv_cal = auv_cal.auv_cal:main",
"correct_images = correct_images.correct_images:main",
],
},
scripts=[
"src/scripts/debayer_folder.py",
"src/scripts/extract_rosbag_images.py",
"src/scripts/merge_dataset_csv.py",
"src/scripts/pixel_stats_folder.py",
"src/scripts/auv_cd.sh",
],
include_package_data=True,
package_data={
"": [
"default_yaml/*/*/*.yaml",
"default_yaml/*/*.yaml",
"default_yaml/*.yaml",
".oplab_pipeline_commit_hash",
]
},
install_requires=[
"argcomplete>=1.12.3",
"argparse>=1.1",
"colour_demosaicing>=0.1.5",
"geographiclib>=1.50",
"imageio>=2.6.1",
"joblib>=0.14.1",
"matplotlib>=3.2.1",
"numba>=0.56.4",
"numpy>=1.23.0",
"opencv-python-headless>=4.1.2",
"pandas>=0.25.3",
"pillow>=7.2.0",
"plotly>=4.7.1",
"plyfile>=0.7.2",
"prettytable>=3.5.0",
"psutil>=5.8.0",
"pynmea2>=1.15.0",
"pytz>=2019.3",
"PyYAML>=3.12",
"scikit_image>=0.17",
"scipy>=1.4.1",
"tqdm>=4.64.0",
"wheel>=0.30.0",
],
)
if __name__ == "__main__":
run_setup()