-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
86 lines (73 loc) · 2.64 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
from pathlib import Path
from setuptools import setup, find_packages, Command
import subprocess
import os
import sys
__version__ = 1.0
class InstallSubmodules(Command):
"""A custom command to install and build submodules."""
description = 'Install and build submodules'
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
self.announce('Installing main package dependencies', level=3)
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-r', 'requirements.txt'])
# Define the submodules and their setup commands
submodules = {
'hloc': {
'path': 'code/0-calibration/hloc',
'commands': [
['pip', 'install', '-e', '.'],
]
},
'multiviewcalib': {
'path': 'code/0-calibration/multiview_calib',
'commands': [
['pip', 'install', '-e', '.'],
]
},
}
# Run the setup commands for each submodule
for name, details in submodules.items():
submodule_path = details['path']
for command in details['commands']:
self.run_command_in_submodule(submodule_path, command)
def run_command_in_submodule(self, submodule_path, command):
"""Run a command inside a submodule's directory."""
original_dir = os.getcwd()
os.chdir(submodule_path)
try:
self.announce(f'Running command: {" ".join(command)} in {submodule_path}', level=3)
subprocess.check_call(command)
finally:
os.chdir(original_dir)
# Read the long description from the README file
root = Path(__file__).parent
with open(root / 'README.md', 'r', encoding='utf-8') as f:
long_description = f.read()
# Read the dependencies from the requirements.txt file
with open(root / 'requirements.txt', 'r', encoding='utf-8') as f:
dependencies = f.read().splitlines()
setup(
name='MARMOT',
version=__version__,
packages=find_packages(),
python_requires='>=3.6',
install_requires=dependencies,
author='Martin Engilbere, Wilke Grosche',
description='Multiview Tracking Library',
long_description=long_description,
long_description_content_type='text/markdown',
url='https://github.com/cvlab-epfl/MARMOT',
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
],
cmdclass={
'install_submodules': InstallSubmodules,
},
)