Skip to content

Commit

Permalink
[#370] Introduced several fixes in DisplayCAL.setup mainly related …
Browse files Browse the repository at this point in the history
…to the usage of `sys.version` where it is replaced with `sys.version_info` as for Python 3.10+ this returns the wrong value.
  • Loading branch information
eoyilmaz committed Sep 26, 2024
1 parent eceef6b commit 3ac139e
Showing 1 changed file with 37 additions and 35 deletions.
72 changes: 37 additions & 35 deletions DisplayCAL/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
the wrapper script in the root directory of the source tar.gz/zip
"""
import functools
import codecs
import ctypes.util
from configparser import ConfigParser
from distutils.command.install import install
import distutils.core
from distutils.util import change_root, get_platform
from fnmatch import fnmatch
import codecs
import ctypes.util
import distutils.core
import functools
import os
import platform
import re
Expand All @@ -38,7 +38,7 @@
from time import strftime


# # Borrowed from setuptools
# Borrowed from setuptools
def _find_all_simple(path):
"""
Find all files under 'path'
Expand Down Expand Up @@ -70,21 +70,21 @@ def findall(dir=os.curdir):

from DisplayCAL.defaultpaths import autostart, autostart_home
from DisplayCAL.meta import (
appstream_id,
author,
author_ascii,
author_email,
description,
longdesc,
DOMAIN,
development_home_page,
DOMAIN,
longdesc,
name,
py_maxversion,
py_minversion,
script2pywname,
version,
version_tuple,
wx_minversion,
author_email,
script2pywname,
appstream_id,
)
from DisplayCAL.util_list import intlist
from DisplayCAL.util_os import getenvu, relpath, safe_glob
Expand Down Expand Up @@ -190,7 +190,7 @@ def findall(dir=os.curdir):
"xrc/*.xrc",
]
},
"xtra_package_data": {name: {"win32": ["theme/icons/%s-uninstall.ico" % name]}},
"xtra_package_data": {name: {"win32": [f"theme/icons/{name}-uninstall.ico"]}},
}


Expand All @@ -207,8 +207,8 @@ def add_lib_excludes(key, excludebits):
continue
config["excludes"][key].extend(
[
name + ".lib%s.python%s" % (exclude, pycompat),
name + ".lib%s.python%s.RealDisplaySizeMM" % (exclude, pycompat),
f"{name}.lib{exclude}.python{pycompat}",
f"{name}.lib{exclude}.python{pycompat}.RealDisplaySizeMM",
]
)

Expand Down Expand Up @@ -236,7 +236,7 @@ def add_lib_excludes(key, excludebits):
"CFBundleShortVersionString": version,
"CFBundleSignature": "????",
"CFBundleVersion": ".".join(map(str, version_tuple)),
"NSHumanReadableCopyright": %s %s" % (strftime("%Y"), author),
"NSHumanReadableCopyright": f{strftime('%Y')} {author}",
"LSMinimumSystemVersion": "10.6.0",
}

Expand Down Expand Up @@ -319,8 +319,8 @@ def create_app_symlinks(dist_dir, scripts):
continue
if subentry == name + ".icns":
shutil.copy(
os.path.join(pydir, "theme", "icons", "%s.icns" % script),
os.path.join(toolcontents, entry, "%s.icns" % script),
os.path.join(pydir, "theme", "icons", f"{script}.icns"),
os.path.join(toolcontents, entry, f"{script}.icns"),
)
continue
if subentry == script:
Expand All @@ -346,11 +346,11 @@ def create_app_symlinks(dist_dir, scripts):
)
# CFBundleIdentifier
infoxml = infoxml.replace(
".%s</string>" % name, ".%s</string>" % script
f".{name}</string>", f".{script}</string>"
)
# CFBundleIconFile
infoxml = infoxml.replace(
"%s.icns</string>" % name, "%s.icns</string>" % script
f"{name}.icns</string>", f"{script}.icns</string>"
)
# CFBundleExecutable
infoxml = re.sub(
Expand Down Expand Up @@ -411,9 +411,8 @@ def sortbyname(a, b):
script = os.path.basename(script)
if script == appname.lower() + "-apply-profiles-launcher":
continue
desktopfile = os.path.join(pydir, "..", "misc", script + ".desktop")
desktopfile = os.path.join(pydir, "..", "misc", f"{script}.desktop")
if os.path.isfile(desktopfile):
print("desktopfile: %s" % desktopfile)
cfg = ConfigParser()
cfg.read(desktopfile)
script = cfg.get("Desktop Entry", "Exec").split()[0]
Expand Down Expand Up @@ -976,7 +975,9 @@ def findall(
if not setuptools or sys.platform != "win32":
# wxPython windows installer doesn't add egg-info entry, so
# a dependency check from pkg_resources would always fail
requires.append("wxPython (>= %s)" % ".".join(str(n) for n in wx_minversion))
requires.append(
"wxPython (>= {})".format(".".join(str(n) for n in wx_minversion))
)
if sys.platform == "win32":
requires.append("pywin32 (>= 213.0)")

Expand Down Expand Up @@ -1014,6 +1015,7 @@ def findall(
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Multimedia :: Graphics",
],
"data_files": data_files,
Expand Down Expand Up @@ -1091,7 +1093,7 @@ def findall(
pydir,
"..",
"dist",
f"py2app.{get_platform()}-py{sys.version[:3]}",
f"py2app.{get_platform()}-py{sys.version_info[0]}.{sys.version_info[1]}",
f"{name}-{version}",
)
from py2app.build_app import py2app as py2app_cls
Expand Down Expand Up @@ -1133,7 +1135,7 @@ def copy_package_data(self, package, target_dir):
"misc",
name
+ (
".exe.%s.VC90.manifest" % arch
f".exe.{arch}.VC90.manifest"
if hasattr(sys, "version_info") and sys.version_info[:2] >= (3, 8)
else ".exe.manifest"
),
Expand All @@ -1143,8 +1145,8 @@ def copy_package_data(self, package, target_dir):
if not os.path.isdir(tmp_scripts_dir):
os.makedirs(tmp_scripts_dir)
apply_profiles_launcher = (
appname.lower() + "-apply-profiles-launcher",
appname + " Profile Loader Launcher",
f"{appname.lower()}-apply-profiles-launcher",
f"{appname} Profile Loader Launcher",
)
for script, desc in scripts + [apply_profiles_launcher]:
shutil.copy(
Expand All @@ -1167,7 +1169,7 @@ def copy_package_data(self, package, target_dir):
)
],
"other_resources": [(24, 1, manifest_xml)],
"copyright": %s %s" % (strftime("%Y"), author),
"copyright": f{strftime('%Y')} {author}",
"description": desc,
}
)
Expand Down Expand Up @@ -1198,7 +1200,7 @@ def copy_package_data(self, package, target_dir):
)
],
"other_resources": [(24, 1, manifest_xml)],
"copyright": %s %s" % (strftime("%Y"), author),
"copyright": f{strftime('%Y')} {author}",
"description": apply_profiles_launcher[1],
}
)
Expand Down Expand Up @@ -1235,7 +1237,7 @@ def copy_package_data(self, package, target_dir):
)
],
"other_resources": [(24, 1, manifest_xml)],
"copyright": %s %s" % (strftime("%Y"), author),
"copyright": f{strftime('%Y')} {author}",
"description": desc,
}
)
Expand All @@ -1262,7 +1264,7 @@ def copy_package_data(self, package, target_dir):
)
],
"other_resources": [(24, 1, manifest_xml)],
"copyright": %s %s" % (strftime("%Y"), author),
"copyright": f{strftime('%Y')} {author}",
"description": "Convert eeColor 65^3 to madVR 256^3 3D LUT "
"(video levels in, video levels out)",
}
Expand All @@ -1273,7 +1275,7 @@ def copy_package_data(self, package, target_dir):
pydir,
"..",
"dist",
f"py2exe.{get_platform()}-py{sys.version[:3]}",
f"py2exe.{get_platform()}-py{sys.version_info[0]}.{sys.version_info[1]}",
f"{name}-{version}",
)
attrs["options"] = {
Expand Down Expand Up @@ -1422,8 +1424,8 @@ def copy_package_data(self, package, target_dir):
# setuptools
paths += (
safe_glob(path)
+ safe_glob(f"{path}-{version}-py{sys.version[:3]}*.egg")
+ safe_glob(f"{path}-{version}-py{sys.version[:3]}*.egg-info")
+ safe_glob(f"{path}-{version}-py{sys.version_info[0]}.{sys.version_info[1]}*.egg")
+ safe_glob(f"{path}-{version}-py{sys.version_info[0]}.{sys.version_info[1]}*.egg-info")
)

if os.path.isabs(data) and data not in paths:
Expand Down Expand Up @@ -1634,7 +1636,7 @@ def copy_package_data(self, package, target_dir):
pydir,
"..",
"dist",
"bbfreeze.{}-py{}".format(get_platform(), sys.version[:3]),
f"bbfreeze.{get_platform()}-py{sys.version_info[0]}.{sys.version_info[1]}",
)
sys.argv.insert(i + 1, f"--dist-dir={dist_dir}")
if "egg_info" not in sys.argv[1:i]:
Expand Down Expand Up @@ -1668,10 +1670,10 @@ def copy_package_data(self, package, target_dir):
if do_py2exe:
shutil.copy(
os.path.join(
dist_dir, "python%s.dll" % (sys.version[0] + sys.version[2])
dist_dir, f"python{sys.version_info[0]}{sys.version_info[1]}.dll"
),
os.path.join(
dist_dir, "lib", "python%s.dll" % (sys.version[0] + sys.version[2])
dist_dir, "lib", f"python{sys.version_info[0]}{sys.version_info[1]}.dll"
),
)

Expand Down

0 comments on commit 3ac139e

Please sign in to comment.