forked from incognite-lab/myGym
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
147 lines (119 loc) · 4.12 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
import sys
from setuptools import setup
from setuptools.command.install import install as _install
from setuptools.command.develop import develop as _develop
from setuptools.command.build_py import build_py as _build_py
from setuptools import Command
from setuptools import find_packages
import re
from subprocess import run
packageName = "myGym"
print('hi')
with open('requirements.txt') as f:
requirements = [l.strip() for l in f]
# filter non-standard requirements
reqexp = re.compile(r"[^\w><=\.\s-]")
nonstandard = list(filter(reqexp.search, requirements))
requirements = list(filter(lambda w: not(reqexp.search(w)), requirements))
if nonstandard:
if sys.argv[1] != "clean":
print("Non-standard requirements found. These will have to installed manually. The non-standard requirements are:")
print(nonstandard)
with open("README.md", "r") as f:
long_description = f.read()
with open("LICENSE.txt", "r") as f:
license_text = f.read()
# versionRegex = re.compile("\d+[.]\d+[.]\d+[^\s]*")
# with open("CHANGELOG.md", "r") as f:
# for line in f:
# versionMatch = versionRegex.match(line)
# if versionMatch:
# version = versionMatch.group()
# break
def writeInitPy():
from setuptools_scm import get_version
version = get_version()
print(f"Building version {version}")
init_file = f"{packageName}/__init__.py"
fileText = [
'# This file was generated by the setup.py and will be rewritten at the next build\n',
f'__version__ = "{version}"\n',
f'__name__ = "{packageName}"'
]
with open(init_file, "w") as f:
f.writelines(fileText)
class BuildWrapper(_build_py):
def run(self):
writeInitPy()
_build_py.run(self)
class InstallWrapper(_install):
def run(self):
print(">>>>>>>>>>>>>>>>>>>>>>>>>>>")
writeInitPy()
_install.run(self)
print("<<<<<<<<<<<<<<<<<<<<<<<<<<<")
self.execute(self._post_install, (),
msg="Running post install task")
def _post_install(self):
print("no task post-install tasks")
class DevelopWrapper(_develop):
def run(self):
print(">>>>>>>>>>>>>>>>>>>>>>>>>>>")
writeInitPy()
_develop.run(self)
print("<<<<<<<<<<<<<<<<<<<<<<<<<<<")
self.execute(self._post_install, (),
msg="Running post install task")
def _post_install(self):
print("no task post-install tasks")
class EnvironmentMaker(Command):
description = "run a custom compile command"
user_options = [
("environment-name=", "e", "environment name")
]
def run(self):
if self.environment_name != "":
name = self.environment_name
else:
name = "crow_simulation"
inp = input(f"Select name for the conda environment (default: '{name}'): ")
if inp != "":
name = inp
import os
run(f"conda env create -f environment.yml -n {name}".split(" "))
def initialize_options(self):
self.environment_name = ""
def finalize_options(self):
pass
setup(
name=packageName,
# version=version,
setup_requires=["setuptools_scm"],
use_scm_version=True,
description='myGym',
long_description=long_description,
author='Incognite group CIIRC CVUT',
maintainer_email='[email protected]',
url='',
download_url='',
license=license_text,
install_requires=requirements,
include_package_data=True,
packages=find_packages(),
cmdclass={
'build_py': BuildWrapper,
'install': InstallWrapper,
'develop': DevelopWrapper,
'make_env': EnvironmentMaker
},
classifiers=[
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Development Status :: 3 - Alpha",
"Intended Audience :: Education",
"Intended Audience :: Information Technology",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Scientific/Engineering :: Human Machine Interfaces"
]
)