Update pycatfile.py
[PyCatFile.git] / setup.py
blob4bd77f18e6f0eed34db93bad092974407a92a1be
1 #!/usr/bin/env python
3 '''
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the Revised BSD License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 Revised BSD License for more details.
12 Copyright 2016-2024 Cool Dude 2k - http://idb.berlios.de/
13 Copyright 2016-2024 Game Maker 2k - http://intdb.sourceforge.net/
14 Copyright 2016-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
16 $FileInfo: setup.py - Last Update: 10/22/2024 Ver. 0.14.0 RC 1 - Author: cooldude2k $
17 '''
19 import os
20 import re
21 import sys
22 import pkg_resources
23 from setuptools import setup
25 # Open and read the version info file in a Python 2/3 compatible way
26 verinfofilename = os.path.realpath("."+os.path.sep+os.path.sep+"pycatfile.py")
28 # Use `with` to ensure the file is properly closed after reading
29 # In Python 2, open defaults to text mode; in Python 3, it’s better to specify encoding
30 open_kwargs = {'encoding': 'utf-8'} if sys.version_info[0] >= 3 else {}
31 with open(verinfofilename, "r", **open_kwargs) as verinfofile:
32 verinfodata = verinfofile.read()
34 # Define the regex pattern for extracting version info
35 # We ensure the pattern works correctly in both Python 2 and 3 by escaping the strings properly
36 version_pattern = "__version_info__ = \(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*['\"]([\w\s]+)['\"]\s*,\s*(\d+)\s*\)"
37 setuppy_verinfo = re.findall(version_pattern, verinfodata)[0]
39 # If version info is found, process it; handle the case where no match is found
40 if setuppy_verinfo:
41 setuppy_verinfo_exp = setuppy_verinfo
42 else:
43 print("Version info not found.")
44 setuppy_verinfo_exp = None # Handle missing version info gracefully
46 # Define the regex pattern for extracting version date info
47 date_pattern = "__version_date_info__ = \(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*['\"]([\w\s]+)['\"]\s*,\s*(\d+)\s*\)"
48 setuppy_dateinfo = re.findall(date_pattern, verinfodata)[0]
50 # If date info is found, process it; handle the case where no match is found
51 if setuppy_dateinfo:
52 setuppy_dateinfo_exp = setuppy_dateinfo
53 else:
54 print("Date info not found.")
55 setuppy_dateinfo_exp = None # Handle missing date info gracefully
57 pymodule = {}
58 pymodule['version'] = str(setuppy_verinfo_exp[0])+"." + \
59 str(setuppy_verinfo_exp[1])+"."+str(setuppy_verinfo_exp[2])
60 pymodule['versionrc'] = int(setuppy_verinfo_exp[4])
61 pymodule['versionlist'] = (int(setuppy_verinfo_exp[0]), int(setuppy_verinfo_exp[1]), int(
62 setuppy_verinfo_exp[2]), str(setuppy_verinfo_exp[3]), int(setuppy_verinfo_exp[4]))
63 pymodule['verdate'] = str(setuppy_dateinfo_exp[0])+"." + \
64 str(setuppy_dateinfo_exp[1])+"."+str(setuppy_dateinfo_exp[2])
65 pymodule['verdaterc'] = int(setuppy_dateinfo_exp[4])
66 pymodule['verdatelist'] = (int(setuppy_dateinfo_exp[0]), int(setuppy_dateinfo_exp[1]), int(
67 setuppy_dateinfo_exp[2]), str(setuppy_dateinfo_exp[3]), int(setuppy_dateinfo_exp[4]))
68 pymodule['name'] = 'PyCatFile'
69 pymodule['author'] = 'Kazuki Przyborowski'
70 pymodule['authoremail'] = 'kazuki.przyborowski@gmail.com'
71 pymodule['maintainer'] = 'Kazuki Przyborowski'
72 pymodule['maintaineremail'] = 'kazuki.przyborowski@gmail.com'
73 pymodule['description'] = 'A tar like file format name catfile after unix cat command (concatenate files) .'
74 pymodule['license'] = 'Revised BSD License'
75 pymodule['keywords'] = 'catfile pycatfile python python-catfile'
76 pymodule['url'] = 'https://github.com/GameMaker2k/PyCatFile'
77 pymodule['downloadurl'] = 'https://github.com/GameMaker2k/PyCatFile/archive/master.tar.gz'
78 pymodule[
79 'longdescription'] = 'A tar like file format name catfile after unix cat command (concatenate files) .'
80 pymodule['platforms'] = 'OS Independent'
81 pymodule['zipsafe'] = True
82 pymodule['pymodules'] = ['pycatfile']
83 pymodule['scripts'] = ['catfile.py', 'neocatfile.py']
84 pymodule['classifiers'] = [
85 'Development Status :: 5 - Production/Stable',
86 'Intended Audience :: Developers',
87 'Intended Audience :: Other Audience',
88 'License :: OSI Approved',
89 'License :: OSI Approved :: BSD License',
90 'Natural Language :: English',
91 'Operating System :: MacOS',
92 'Operating System :: MacOS :: MacOS X',
93 'Operating System :: Microsoft',
94 'Operating System :: Microsoft :: Windows',
95 'Operating System :: OS/2',
96 'Operating System :: OS Independent',
97 'Operating System :: POSIX',
98 'Operating System :: Unix',
99 'Programming Language :: Python',
100 'Topic :: Utilities',
101 'Topic :: Software Development',
102 'Topic :: Software Development :: Libraries',
103 'Topic :: Software Development :: Libraries :: Python Modules'
105 if(len(sys.argv) > 1 and (sys.argv[1] == "versioninfo" or sys.argv[1] == "getversioninfo")):
106 import json
107 pymodule_data = json.dumps(pymodule)
108 print(pymodule_data)
109 sys.exit()
110 if(len(sys.argv) > 1 and (sys.argv[1] == "sourceinfo" or sys.argv[1] == "getsourceinfo")):
111 srcinfofilename = os.path.realpath("."+os.path.sep+pkg_resources.to_filename(
112 pymodule['name'])+".egg-info"+os.path.sep+"SOURCES.txt")
113 srcinfofile = open(srcinfofilename, "r")
114 srcinfodata = srcinfofile.read()
115 srcinfofile.close()
116 srcinfolist = srcinfodata.split('\n')
117 srcfilelist = ""
118 srcpdir = os.path.basename(os.path.dirname(os.path.realpath(__file__)))
119 for ifile in srcinfolist:
120 srcfilelist = "."+os.path.sep+srcpdir+os.path.sep+ifile+" "+srcfilelist
121 print(srcfilelist)
122 sys.exit()
123 if(len(sys.argv) > 1 and sys.argv[1] == "cleansourceinfo"):
124 os.system("rm -rfv \""+os.path.realpath("."+os.path.sep+"dist\""))
125 os.system("rm -rfv \""+os.path.realpath("."+os.path.sep +
126 pkg_resources.to_filename(pymodule['name'])+".egg-info\""))
127 sys.exit()
129 setup(
130 name=pymodule['name'],
131 version=pymodule['version'],
132 author=pymodule['author'],
133 author_email=pymodule['authoremail'],
134 maintainer=pymodule['maintainer'],
135 maintainer_email=pymodule['maintaineremail'],
136 description=pymodule['description'],
137 license=pymodule['license'],
138 keywords=pymodule['keywords'],
139 url=pymodule['url'],
140 download_url=pymodule['downloadurl'],
141 long_description=pymodule['longdescription'],
142 platforms=pymodule['platforms'],
143 zip_safe=pymodule['zipsafe'],
144 py_modules=pymodule['pymodules'],
145 scripts=pymodule['scripts'],
146 classifiers=pymodule['classifiers']