generated from franceme/hugg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·149 lines (136 loc) · 3.79 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
#!/usr/bin/env python3
# region Imports
import pathlib, zipfile
from fileinput import FileInput as finput
import os
import sys
from setuptools import find_packages, setup
from pathlib import Path
import glob
from glob import glob as re
try:
from pylint.reporters.json_reporter import JSONReporter
except:
pass
try:
from src.information import VERSION, REQ
except:
pass
try:
from information import VERSION, REQ
except:
pass
# endregion
# region Basic Information
here = os.path.abspath(os.path.dirname(__file__))
py_version = sys.version_info[:2]
NAME = "mystring"
AUTHOR = 'Miles Frantz'
EMAIL = 'frantzme@vt.edu'
DESCRIPTION = 'My short description for my project.'
GH_NAME = "franceme"
URL = f"https://github.com/{GH_NAME}/{NAME}"
long_description = pathlib.Path(f"{here}/README.md").read_text(encoding='utf-8')
REQUIRES_PYTHON = '>=3.8.0'
RELEASE = "?"
entry_point = f"src.{NAME}"
VERSION = "0.2.252"
def zip_program(outputName:str = f"{NAME}.zip"):
#http://blog.ablepear.com/2012/10/bundling-python-files-into-stand-alone.html
if os.path.exists(outputName):
os.system(f"rm {outputName}")
zipf = zipfile.ZipFile(outputName, 'w', zipfile.ZIP_DEFLATED)
success = 0
try:
zipf.write("setup.py")
zipf.write("README.md")
zipf.write("__main__.py")
for root, dirs, files in os.walk('src/'):
for file in [x for x in files if not x.endswith('.pyc')]:
ending_path = os.path.relpath(os.path.join(root, file), os.path.join('src/', '..'))
zipf.write(
os.path.join(root, file),
ending_path
)
print(f"Successful: {outputName}")
except Exception as e:
print(f"Failing the exception check: {e}")
success = 1
zipf.close()
return(success)
def grab_version(update_patch:bool=False,update_minor:bool=False,update_major:bool=False):
update = any([update_patch,update_minor,update_major])
with finput(__file__,inplace=True) as foil:
for line in foil:
if line.startswith("VERSION = "):
output = line.strip().replace('VERSION = ','').replace('"','').split('.')
major,minor,patch = int(output[0]),int(output[1]),int(output[2])
if update_patch:
patch += 1
if update_minor:
minor += 1
if update_major:
major += 1
if update:
print(f"VERSION = \"{major}.{minor}.{patch}\"")
else:
print(line,end='')
else:
print(line, end='')
return
# endregion
# region CMD Line Usage
def selfArg(string):
return __name__ == "__main__" and len(
sys.argv) > 1 and sys.argv[0].endswith('/setup.py') and str(
sys.argv[1]).upper() == str(string).upper()
if selfArg('install'):
sys.exit(os.system('python3 -m pip install -e .'))
elif selfArg('upload'):
grab_version(True)
sys.exit(os.system(f"{sys.executable} setup.py sdist && {sys.executable} -m twine upload --skip-existing dist/*"))
elif selfArg('zip'):
sys.exit(zip_program())
# endregion
# region Setup
grading_deps = ["pybryt", "ephfile"]
frame_deps = ["pandas", "seaborn", "ephfile", "pydbhub", "openpyxl", "pyplotlib[all]"]
package_deps = ["requests"]
gh_deps = ["requests", "pause"]
gh_url_deps = ["waybackpy"] + gh_deps
setup(
name=NAME,
version=VERSION,
description=DESCRIPTION,
long_description=long_description,
long_description_content_type='text/markdown',
author=AUTHOR,
author_email=EMAIL,
command_options={
},
python_requires=REQUIRES_PYTHON,
url=URL,
packages=find_packages(
exclude=["tests", "*.tests", "*.tests.*", "tests.*"]),
entry_points={
},
install_requires=[
"python-dateutil",
"pandasql",
],
extras_require={
"grading":grading_deps,
"frames":frame_deps,
"gh":gh_deps,
"gh_url":gh_url_deps,
"pkg":package_deps,
"all":grading_deps + frame_deps + gh_url_deps + gh_deps + package_deps
},
include_package_data=True,
classifiers=[
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.8',
],
)
# endregion