diff --git a/.gitignore b/.gitignore index e5e870f7..882fe254 100644 --- a/.gitignore +++ b/.gitignore @@ -29,4 +29,5 @@ __pycache__/ /DisplayCAL/lib64/RealDisplaySizeMM.cpython-311-darwin.so /DisplayCAL/lib64/RealDisplaySizeMM.cpython-312-darwin.so cacert.pem -*.code-workspace \ No newline at end of file +*.code-workspace +main.py \ No newline at end of file diff --git a/DisplayCAL/profile_loader.py b/DisplayCAL/profile_loader.py index deca0ef4..f5582037 100644 --- a/DisplayCAL/profile_loader.py +++ b/DisplayCAL/profile_loader.py @@ -118,7 +118,7 @@ def setup_profile_loader_task(exe, exedir, pydir): if sys.getwindowsversion() >= (6,): from DisplayCAL import taskscheduler - taskname = appname + " Profile Loader Launcher" + taskname = f"{appname} Profile Loader Launcher" try: ts = taskscheduler.TaskScheduler() diff --git a/DisplayCAL/setup.py b/DisplayCAL/setup.py index c469b199..721da9b7 100644 --- a/DisplayCAL/setup.py +++ b/DisplayCAL/setup.py @@ -199,7 +199,7 @@ def add_lib_excludes(key, excludebits): config["excludes"][key].extend([f"{name}.lib{exclude}", f"lib{exclude}"]) for exclude in ("32", "64"): - for pycompat in ("38", "39", "310", "311"): + for pycompat in ("38", "39", "310", "311", "312"): if key == "win32" and ( pycompat == str(sys.version_info[0]) + str(sys.version_info[1]) or exclude == excludebits[0] @@ -370,12 +370,24 @@ def create_app_symlinks(dist_dir, scripts): def get_data(tgt_dir, key, pkgname=None, subkey=None, excludes=None): - """Return configured data files.""" + """Return configured data files. + + Args: + tgt_dir (str): The target directory. + key (str): The config key. + pkgname (Union[None, str]): Name of the package. Default is None. + subkey (Union[None, str]): Name of the subkey. Default is None. + excludes (Union[None, List[str]]): List of files to exclude. Default is None. + + Returns: + List[str]: List of strings showing the paths of the data files. + """ files = config[key] src_dir = source_dir if pkgname: files = files[pkgname] - src_dir = os.path.join(src_dir, pkgname) + # modifying the src_dir is not working with py2app, so disabling it. + # src_dir = os.path.join(src_dir, pkgname) if subkey: if subkey in files: files = files[subkey] @@ -386,6 +398,9 @@ def get_data(tgt_dir, key, pkgname=None, subkey=None, excludes=None): if not [exclude for exclude in excludes or [] if fnmatch(pth, exclude)]: normalized_path = os.path.normpath(os.path.join(tgt_dir, os.path.dirname(pth))) safe_path = [relpath(p, src_dir) for p in safe_glob(os.path.join(src_dir, pth))] + if pkgname: + # try looking for the "{src_dir}/{pkgname}/{pth}" too + safe_path += [relpath(p, src_dir) for p in safe_glob(os.path.join(src_dir, pkgname, pth))] data.append((normalized_path, safe_path)) return data @@ -469,12 +484,6 @@ def setup(): if use_setuptools: if "--use-setuptools" in sys.argv[1:] and not os.path.exists("use-setuptools"): open("use-setuptools", "w").close() - # try: - # from ez_setup import use_setuptools as ez_use_setuptools - # - # ez_use_setuptools() - # except ImportError: - # pass try: import setuptools from setuptools import setup, Extension, find_packages @@ -1109,7 +1118,7 @@ def copy_package_data(self, package, target_dir): py2app_cls.copy_package_data = copy_package_data attrs["options"] = { "py2app": { - "argv_emulation": True, + "argv_emulation": False, "dist_dir": dist_dir, "excludes": config["excludes"]["all"] + config["excludes"]["darwin"], "iconfile": os.path.join(pydir, "theme", "icons", f"{name}.icns"), diff --git a/DisplayCAL/wexpect.py b/DisplayCAL/wexpect.py index 275e4196..80c80af1 100644 --- a/DisplayCAL/wexpect.py +++ b/DisplayCAL/wexpect.py @@ -2123,7 +2123,7 @@ def spawn(self, command, args=None, env=None): def startChild(self, args, env): si = GetStartupInfo() si.dwFlags = STARTF_USESHOWWINDOW - si.wShowWindow = SW_HIDE # SW_SHOW + si.wShowWindow = SW_HIDE # Determine the directory of wexpect.py or, if we are running 'frozen' # (eg. py2exe deployment), of the packed executable dirname = os.path.dirname( @@ -2984,20 +2984,18 @@ def log(e, suffix="", logdir=None): except Exception: pass try: - fout = open(logfile, "a") + with open(logfile, "a", encoding="utf-8") as fout: + ts = time.time() + fout.write( + "%s,%s %s\n" + % ( + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(ts)), + ("%3f" % (ts - int(ts)))[2:5], + e, + ) + ) except Exception: pass - else: - ts = time.time() - fout.write( - "%s,%s %s\n" - % ( - time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(ts)), - ("%3f" % (ts - int(ts)))[2:5], - e, - ) - ) - fout.close() def excepthook(etype, value, tb): diff --git a/DisplayCAL/worker.py b/DisplayCAL/worker.py index 141d8558..d8752acf 100644 --- a/DisplayCAL/worker.py +++ b/DisplayCAL/worker.py @@ -7086,8 +7086,6 @@ def exec_cmd( raise Error(lang.getstr("windows.version.unsupported")) try: - # print(f"cmdline: {cmdline}") - # print(f"kwargs : {kwargs}") self.subprocess = wexpect.spawn( cmdline[0], cmdline[1:], **kwargs ) @@ -13520,7 +13518,7 @@ def prepare_dispcal(self, calibrate=True, verify=False, dry_run=False): luminance = getcfg("calibration.luminance", False) self.log(f"{appname}: luminance: {luminance}") if luminance is not None: - args.append("-b{luminance}") + args.append(f"-b{luminance}") if getcfg("trc"): args.append("-" + getcfg("trc.type") + str(getcfg("trc"))) args.append("-f%s" % getcfg("calibration.black_output_offset")) diff --git a/README.md b/README.md index e96090ba..12655b57 100644 --- a/README.md +++ b/README.md @@ -263,7 +263,7 @@ Please install these from your package manager. brew install glib gtk+3 python@3.11 # Debian installs -apt-get install build-essential dbus libglib2.0-dev pkg-config libgtk-3-dev libxxf86vm-dev +apt-get install build-essential dbus libglib2.0-dev pkg-config libgtk-3-dev libxxf86vm-dev python3-dev # Fedora core installs dnf install gcc glibc-devel dbus pkgconf gtk3-devel libXxf86vm-devel python3-devel