forked from JoshuaPrzyborowski/PyTempCalc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
162 lines (148 loc) · 7.04 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
#!/usr/bin/env python
'''
This program is free software; you can redistribute it and/or modify
it under the terms of the Revised BSD License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Revised BSD License for more details.
Copyright 2016-2019 Game Maker 2k - https://github.com/GameMaker2k
Copyright 2016-2019 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
$FileInfo: setup.py - Last Update: 1/29/2019 Ver. 0.4.0 RC 1 - Author: cooldude2k $
'''
import re
import os
import sys
import time
import datetime
import platform
import pkg_resources
from setuptools import setup, find_packages
install_requires = []
pygenbuildinfo = True
# Open and read the version info file in a Python 2/3 compatible way
verinfofilename = os.path.realpath("."+os.path.sep+"pytempcalc.py")
# Use `with` to ensure the file is properly closed after reading
# In Python 2, open defaults to text mode; in Python 3, it’s better to specify encoding
open_kwargs = {'encoding': 'utf-8'} if sys.version_info[0] >= 3 else {}
with open(verinfofilename, "r", **open_kwargs) as verinfofile:
verinfodata = verinfofile.read()
# Define the regex pattern for extracting version info
# We ensure the pattern works correctly in both Python 2 and 3 by escaping the strings properly
version_pattern = "__version_info__ = \(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*['\"]([\w\s]+)['\"]\s*,\s*(\d+)\s*\)"
setuppy_verinfo = re.findall(version_pattern, verinfodata)[0]
# If version info is found, process it; handle the case where no match is found
if setuppy_verinfo:
setuppy_verinfo_exp = setuppy_verinfo
else:
print("Version info not found.")
setuppy_verinfo_exp = None # Handle missing version info gracefully
# Define the regex pattern for extracting version date info
date_pattern = "__version_date_info__ = \(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*['\"]([\w\s]+)['\"]\s*,\s*(\d+)\s*\)"
setuppy_dateinfo = re.findall(date_pattern, verinfodata)[0]
# If date info is found, process it; handle the case where no match is found
if setuppy_dateinfo:
setuppy_dateinfo_exp = setuppy_dateinfo
else:
print("Date info not found.")
setuppy_dateinfo_exp = None # Handle missing date info gracefully
pymodule = {}
pymodule['version'] = str(setuppy_verinfo_exp[0])+"." + \
str(setuppy_verinfo_exp[1])+"."+str(setuppy_verinfo_exp[2])
pymodule['versionrc'] = int(setuppy_verinfo_exp[4])
pymodule['versionlist'] = (int(setuppy_verinfo_exp[0]), int(setuppy_verinfo_exp[1]), int(
setuppy_verinfo_exp[2]), str(setuppy_verinfo_exp[3]), int(setuppy_verinfo_exp[4]))
pymodule['verdate'] = str(setuppy_dateinfo_exp[0])+"." + \
str(setuppy_dateinfo_exp[1])+"."+str(setuppy_dateinfo_exp[2])
pymodule['verdaterc'] = int(setuppy_dateinfo_exp[4])
pymodule['verdatelist'] = (int(setuppy_dateinfo_exp[0]), int(setuppy_dateinfo_exp[1]), int(
setuppy_dateinfo_exp[2]), str(setuppy_dateinfo_exp[3]), int(setuppy_dateinfo_exp[4]))
pymodule['name'] = 'PyTempCalc'
pymodule['author'] = 'Joshua Przyborowski'
pymodule['authoremail'] = 'joshua.przyborowski@gmail.com'
pymodule['maintainer'] = 'Joshua Przyborowski'
pymodule['maintaineremail'] = 'joshua.przyborowski@gmail.com'
pymodule['description'] = 'A barcode library/module for python.'
pymodule['license'] = 'Revised BSD License'
pymodule['keywords'] = 'barcode barcodegenerator barcodes codabar msi code11 code-11 code39 code-39 code93 code-93 ean ean13 ean-13 ean2 ean-2 ean5 ean-5 ean8 ean-8 itf itf14 itf-14 stf upc upca upc-a upce upc-e'
pymodule['url'] = 'https://github.com/GameMaker2k/PyDice'
pymodule['downloadurl'] = 'https://github.com/JoshuaPrzyborowski/PyDice/archive/master.tar.gz'
pymodule['packages'] = find_packages()
pymodule['packagedata'] = {'.': ['*.xml']}
pymodule['includepackagedata'] = True
pymodule['installrequires'] = [install_requires]
pymodule['longdescription'] = 'PyDice is a barcode library/module for Python. It supports the barcode formats upc-e, upc-a, ean-13, ean-8, ean-2, ean-5, itf14, codabar, code11, code39, code93, and msi.'
pymodule['platforms'] = 'OS Independent'
pymodule['zipsafe'] = False
pymodule['pymodules'] = ['upcean']
pymodule['classifiers'] = [
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Customer Service',
'Intended Audience :: Developers',
'Intended Audience :: Other Audience',
'License :: OSI Approved',
'License :: OSI Approved :: BSD License',
'Natural Language :: English',
'Operating System :: MacOS',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft',
'Operating System :: Microsoft :: Windows',
'Operating System :: OS/2',
'Operating System :: OS Independent',
'Operating System :: POSIX',
'Operating System :: Unix',
'Programming Language :: Python',
'Topic :: Multimedia :: Graphics',
'Topic :: Office/Business',
'Topic :: Office/Business :: Financial',
'Topic :: Office/Business :: Financial :: Point-Of-Sale',
'Topic :: Utilities',
'Topic :: Software Development',
'Topic :: Software Development :: Libraries',
'Topic :: Software Development :: Libraries :: Python Modules'
]
if(len(sys.argv) > 1 and (sys.argv[1] == "versioninfo" or sys.argv[1] == "getversioninfo")):
import json
pymodule_data = json.dumps(pymodule)
print(pymodule_data)
sys.exit()
if(len(sys.argv) > 1 and (sys.argv[1] == "sourceinfo" or sys.argv[1] == "getsourceinfo")):
srcinfofilename = os.path.realpath("."+os.path.sep+pkg_resources.to_filename(
pymodule['name'])+".egg-info"+os.path.sep+"SOURCES.txt")
srcinfofile = open(srcinfofilename, "r")
srcinfodata = srcinfofile.read()
srcinfofile.close()
srcinfolist = srcinfodata.split('\n')
srcfilelist = ""
srcpdir = os.path.basename(os.path.dirname(os.path.realpath(__file__)))
for ifile in srcinfolist:
srcfilelist = "."+os.path.sep+srcpdir+os.path.sep+ifile+" "+srcfilelist
print(srcfilelist)
sys.exit()
if(len(sys.argv) > 1 and sys.argv[1] == "cleansourceinfo"):
os.system("rm -rfv \""+os.path.realpath("."+os.path.sep+"dist\""))
os.system("rm -rfv \""+os.path.realpath("."+os.path.sep +
pkg_resources.to_filename(pymodule['name'])+".egg-info\""))
sys.exit()
setup(
name=pymodule['name'],
version=pymodule['version'],
author=pymodule['author'],
author_email=pymodule['authoremail'],
maintainer=pymodule['maintainer'],
maintainer_email=pymodule['maintaineremail'],
description=pymodule['description'],
license=pymodule['license'],
keywords=pymodule['keywords'],
url=pymodule['url'],
download_url=pymodule['downloadurl'],
packages=pymodule['packages'],
package_data=pymodule['packagedata'],
include_package_data=pymodule['includepackagedata'],
install_requires=pymodule['installrequires'],
long_description=pymodule['longdescription'],
platforms=pymodule['platforms'],
zip_safe=pymodule['zipsafe'],
py_modules=pymodule['pymodules'],
classifiers=pymodule['classifiers']
)