Skip to content

Commit

Permalink
Small update
Browse files Browse the repository at this point in the history
  • Loading branch information
KazukiPrzyborowski committed Oct 22, 2024
1 parent 8d10a27 commit 4fa6985
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 17 deletions.
46 changes: 32 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,38 @@ def pillow_installed():
extras_requires_dict = {'drawing_barcodes': extras_requires}

pygenbuildinfo = True
verinfofilename = os.path.realpath(
"."+os.path.sep+"upcean"+os.path.sep+"versioninfo.py")
verinfofile = open(verinfofilename, "r")
verinfodata = verinfofile.read()
verinfofile.close()
setuppy_verinfo_esc = re.escape("__version_info__ = (")+"(.*)"+re.escape(");")
setuppy_verinfo = re.findall(setuppy_verinfo_esc, verinfodata)[0]
setuppy_verinfo_exp = [vergetspt.strip().replace("\"", "")
for vergetspt in setuppy_verinfo.split(',')]
setuppy_dateinfo_esc = re.escape(
"__version_date_info__ = (")+"(.*)"+re.escape(");")
setuppy_dateinfo = re.findall(setuppy_dateinfo_esc, verinfodata)[0]
setuppy_dateinfo_exp = [vergetspt.strip().replace("\"", "")
for vergetspt in setuppy_dateinfo.split(',')]
# Open and read the version info file in a Python 2/3 compatible way
verinfofilename = os.path.realpath("." + os.path.sep + "upcean" + os.path.sep + "versioninfo.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])
Expand Down
6 changes: 3 additions & 3 deletions upcean/versioninfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Copyright 2011-2023 Game Maker 2k - https://github.com/GameMaker2k
Copyright 2011-2023 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
$FileInfo: versioninfo.py - Last Update: 9/6/2023 Ver. 2.10.5 RC 1 - Author: cooldude2k $
$FileInfo: versioninfo.py - Last Update: 10/22/2024 Ver. 2.10.6 RC 1 - Author: cooldude2k $
'''

from __future__ import absolute_import, division, print_function, unicode_literals, generators, with_statement, nested_scopes
Expand Down Expand Up @@ -67,7 +67,7 @@
__status__ = "Production"
__project__ = "PyUPC-EAN"
__project_url__ = "https://pypi.python.org/pypi/PyUPC-EAN"
__version_info__ = (2, 10, 5, "RC 1", 1)
__version_info__ = (2, 10, 6, "RC 1", 1)
__build_time__ = {"timestamp": None, "year": None, "month": None,
"day": None, "hour": None, "minute": None, "second": None}
__build_time_utc__ = {"timestamp": None, "year": None, "month": None,
Expand Down Expand Up @@ -105,7 +105,7 @@ def version_info():
return {"major": __version_info__[0], "minor": __version_info__[1], "build": __version_info__[2], "release": None}


__version_date_info__ = (2023, 9, 6, "RC 1", 1)
__version_date_info__ = (2024, 10, 22, "RC 1", 1)


def version_date():
Expand Down

0 comments on commit 4fa6985

Please sign in to comment.