| 1 |
# -*- coding: utf-8 -*- |
| 2 |
""" |
| 3 |
DisplayCAL setup.py script |
| 4 |
|
| 5 |
Can be used with setuptools or pure distutils (the latter can be forced |
| 6 |
with the --use-distutils option, otherwise it will try to use setuptools |
| 7 |
by default). |
| 8 |
|
| 9 |
Also supported in addition to standard distutils/setuptools commands, |
| 10 |
are the bdist_bbfreeze, py2app and py2exe commands (if the appropriate |
| 11 |
packages are installed), which makes this file your all-around building/ |
| 12 |
bundling powerhouse for DisplayCAL. In the case of py2exe, special care |
| 13 |
is taken of Python 2.6+ and the Microsoft.VC90.CRT assembly dependency, |
| 14 |
so if building an executable on Windows with Python 2.6+ you should |
| 15 |
preferably use py2exe. Please note that bdist_bbfreeze and py2app |
| 16 |
*require* setuptools. |
| 17 |
|
| 18 |
IMPORTANT NOTE: |
| 19 |
If called from within the installed package, should only be used to |
| 20 |
uninstall (setup.py uninstall --record=INSTALLED_FILES), otherwise use |
| 21 |
the wrapper script in the root directory of the source tar.gz/zip |
| 22 |
|
| 23 |
""" |
| 24 |
import codecs |
| 25 |
import ctypes.util |
| 26 |
from configparser import ConfigParser |
| 27 |
from distutils.command.install import install |
| 28 |
import distutils.core |
| 29 |
from distutils.util import change_root, get_platform |
| 30 |
from fnmatch import fnmatch |
| 31 |
import functools |
| 32 |
import os |
| 33 |
import platform |
| 34 |
import re |
| 35 |
import shutil |
| 36 |
import subprocess as sp |
| 37 |
import sys |
| 38 |
from time import strftime |
| 39 |
|
| 40 |
|
| 41 |
# Borrowed from setuptools |
| 42 |
def _find_all_simple(path): |
| 43 |
""" |
| 44 |
Find all files under 'path' |
| 45 |
""" |
| 46 |
results = ( |
| 47 |
os.path.join(base, file) |
| 48 |
for base, dirs, files in os.walk(path, followlinks=True) |
| 49 |
for file in files |
| 50 |
) |
| 51 |
return filter(os.path.isfile, results) |
| 52 |
|
| 53 |
|
| 54 |
def findall(dir=os.curdir): |
| 55 |
""" |
| 56 |
Find all files under 'dir' and return the list of full filenames. |
| 57 |
Unless dir is '.', return full filenames with dir prepended. |
| 58 |
""" |
| 59 |
files = _find_all_simple(dir) |
| 60 |
if dir == os.curdir: |
| 61 |
make_rel = functools.partial(os.path.relpath, start=dir) |
| 62 |
files = map(make_rel, files) |
| 63 |
return list(files) |
| 64 |
|
| 65 |
|
| 66 |
import distutils.filelist |
| 67 |
|
| 68 |
distutils.filelist.findall = findall # Fix findall bug in distutils |
| 69 |
|
| 70 |
|
| 71 |
from DisplayCAL.defaultpaths import autostart, autostart_home |
| 72 |
from DisplayCAL.meta import ( |
| 73 |
appstream_id, |
| 74 |
author, |
| 75 |
author_ascii, |
| 76 |
author_email, |
| 77 |
description, |
| 78 |
development_home_page, |
| 79 |
DOMAIN, |
| 80 |
longdesc, |
| 81 |
name, |
| 82 |
py_maxversion, |
| 83 |
py_minversion, |
| 84 |
script2pywname, |
| 85 |
version, |
| 86 |
version_tuple, |
| 87 |
wx_minversion, |
| 88 |
) |
| 89 |
from DisplayCAL.util_list import intlist |
| 90 |
from DisplayCAL.util_os import getenvu, relpath, safe_glob |
| 91 |
from DisplayCAL.util_str import safe_str |
| 92 |
|
| 93 |
appname = name |
| 94 |
|
| 95 |
bits = platform.architecture()[0][:2] |
| 96 |
pypath = os.path.abspath(__file__) |
| 97 |
pydir = os.path.dirname(pypath) |
| 98 |
source_dir = os.path.dirname(pydir) |
| 99 |
|
| 100 |
|
| 101 |
if sys.platform in ("darwin", "win32"): |
| 102 |
# Adjust PATH so ctypes.util.find_library can find SDL2 DLLs (if present) |
| 103 |
pth = getenvu("PATH") |
| 104 |
libpth = os.path.join(pydir, "lib") |
| 105 |
if not pth.startswith(libpth + os.pathsep): |
| 106 |
pth = libpth + os.pathsep + pth |
| 107 |
os.environ["PATH"] = safe_str(pth) |
| 108 |
|
| 109 |
config = { |
| 110 |
"data": ["tests/*.icc"], |
| 111 |
"doc": [ |
| 112 |
"CHANGES.html", |
| 113 |
"LICENSE.txt", |
| 114 |
"README.html", |
| 115 |
"README-fr.html", |
| 116 |
"screenshots/*.png", |
| 117 |
"theme/*.png", |
| 118 |
"theme/*.css", |
| 119 |
"theme/*.js", |
| 120 |
"theme/*.svg", |
| 121 |
"theme/icons/favicon.ico", |
| 122 |
"theme/slimbox2/*.css", |
| 123 |
"theme/slimbox2/*.js", |
| 124 |
], |
| 125 |
# Excludes for .app/.exe builds |
| 126 |
# numpy.lib.utils imports pydoc, which imports Tkinter, but |
| 127 |
# numpy.lib.utils is not even used by DisplayCAL, so omit all |
| 128 |
# Tk stuff |
| 129 |
# Use pyglet with OpenAL as audio backend. We only need |
| 130 |
# pyglet, pyglet.app and pyglet.media |
| 131 |
"excludes": { |
| 132 |
"all": [ |
| 133 |
"Tkconstants", |
| 134 |
"Tkinter", |
| 135 |
"pygame", |
| 136 |
"pyglet.canvas", |
| 137 |
"pyglet.extlibs", |
| 138 |
"pyglet.font", |
| 139 |
"pyglet.gl", |
| 140 |
"pyglet.graphics", |
| 141 |
"pyglet.image", |
| 142 |
"pyglet.input", |
| 143 |
"pyglet.text", |
| 144 |
"pyglet.window", |
| 145 |
"pyo", |
| 146 |
"setuptools", |
| 147 |
"tcl", |
| 148 |
"test", |
| 149 |
"yaml", |
| 150 |
], |
| 151 |
"darwin": ["gdbm"], |
| 152 |
"win32": ["gi", "win32com.client.genpy"], |
| 153 |
}, |
| 154 |
"package_data": { |
| 155 |
name: [ |
| 156 |
"beep.wav", |
| 157 |
"camera_shutter.wav", |
| 158 |
"ColorLookupTable.fx", |
| 159 |
"lang/*.yaml", |
| 160 |
"linear.cal", |
| 161 |
"pnp.ids", |
| 162 |
"presets/*.icc", |
| 163 |
"quirk.json", |
| 164 |
"ref/*.cie", |
| 165 |
"ref/*.gam", |
| 166 |
"ref/*.icm", |
| 167 |
"ref/*.ti1", |
| 168 |
"report/*.css", |
| 169 |
"report/*.html", |
| 170 |
"report/*.js", |
| 171 |
"test.cal", |
| 172 |
"theme/*.png", |
| 173 |
"theme/*.wav", |
| 174 |
"theme/icons/10x10/*.png", |
| 175 |
"theme/icons/16x16/*.png", |
| 176 |
"theme/icons/32x32/*.png", |
| 177 |
"theme/icons/48x48/*.png", |
| 178 |
"theme/icons/72x72/*.png", |
| 179 |
"theme/icons/128x128/*.png", |
| 180 |
"theme/icons/256x256/*.png", |
| 181 |
"theme/icons/512x512/*.png", |
| 182 |
"theme/jet_anim/*.png", |
| 183 |
"theme/patch_anim/*.png", |
| 184 |
"theme/splash_anim/*.png", |
| 185 |
"theme/shutter_anim/*.png", |
| 186 |
"ti1/*.ti1", |
| 187 |
"x3d-viewer/*.css", |
| 188 |
"x3d-viewer/*.html", |
| 189 |
"x3d-viewer/*.js", |
| 190 |
"xrc/*.xrc", |
| 191 |
] |
| 192 |
}, |
| 193 |
"xtra_package_data": {name: {"win32": [f"theme/icons/{name}-uninstall.ico"]}}, |
| 194 |
} |
| 195 |
|
| 196 |
|
| 197 |
msiversion = ".".join( |
| 198 |
( |
| 199 |
str(version_tuple[0]), |
| 200 |
str(version_tuple[1]), |
| 201 |
str(version_tuple[2]), |
| 202 |
) |
| 203 |
) |
| 204 |
|
| 205 |
plist_dict = { |
| 206 |
"CFBundleDevelopmentRegion": "English", |
| 207 |
"CFBundleExecutable": name, |
| 208 |
"CFBundleGetInfoString": version, |
| 209 |
"CFBundleIdentifier": ".".join(reversed(DOMAIN.split("."))) + "." + name, |
| 210 |
"CFBundleInfoDictionaryVersion": "6.0", |
| 211 |
"CFBundleLongVersionString": version, |
| 212 |
"CFBundleName": name, |
| 213 |
"CFBundlePackageType": "APPL", |
| 214 |
"CFBundleShortVersionString": version, |
| 215 |
"CFBundleSignature": "????", |
| 216 |
"CFBundleVersion": ".".join(map(str, version_tuple)), |
| 217 |
"NSHumanReadableCopyright": f"© {strftime('%Y')} {author}", |
| 218 |
"LSMinimumSystemVersion": "10.6.0", |
| 219 |
} |
| 220 |
|
| 221 |
|
| 222 |
class Target: |
| 223 |
def __init__(self, **kwargs): |
| 224 |
self.__dict__.update(kwargs) |
| 225 |
|
| 226 |
|
| 227 |
def create_app_symlinks(dist_dir, scripts): |
| 228 |
maincontents_rel = os.path.join(f"{name}.app", "Contents") |
| 229 |
# Create ref, tests, ReadMe and license symlinks in directory |
| 230 |
# containing the app bundle |
| 231 |
for src, tgt in [ |
| 232 |
("ref", "Reference"), |
| 233 |
("tests", "Tests"), |
| 234 |
("CHANGES.html", "CHANGES.html"), |
| 235 |
("README.html", "README.html"), |
| 236 |
("README-fr.html", "README-fr.html"), |
| 237 |
("LICENSE.txt", "LICENSE.txt"), |
| 238 |
]: |
| 239 |
tgt = os.path.join(dist_dir, tgt) |
| 240 |
if os.path.islink(tgt): |
| 241 |
os.unlink(tgt) |
| 242 |
os.symlink(os.path.join(maincontents_rel, "Resources", src), tgt) |
| 243 |
# Create standalone tools app bundles by symlinking to the main bundle |
| 244 |
scripts = [(script2pywname(script), desc) for script, desc in scripts] |
| 245 |
toolscripts = [ |
| 246 |
script for script in [script for script, desc in scripts] if script != name |
| 247 |
] |
| 248 |
for script, desc in scripts: |
| 249 |
if script in ( |
| 250 |
name, |
| 251 |
f"{name}-apply-profiles", |
| 252 |
f"{name}-eeColor-to-madVR-converter", |
| 253 |
) or script.endswith("-console"): |
| 254 |
continue |
| 255 |
toolname = desc.replace(name, "").strip() |
| 256 |
toolapp = os.path.join(dist_dir, f"{toolname}.app") |
| 257 |
if os.path.isdir(toolapp): |
| 258 |
if ( |
| 259 |
input( |
| 260 |
f'WARNING: The output directory "{toolapp}" and ALL ITS ' |
| 261 |
"CONTENTS will be REMOVED! Continue? (y/n)" |
| 262 |
).lower() |
| 263 |
== "y" |
| 264 |
): |
| 265 |
print("Removing dir", toolapp) |
| 266 |
shutil.rmtree(toolapp) |
| 267 |
else: |
| 268 |
raise SystemExit("User aborted") |
| 269 |
toolscript = os.path.join(dist_dir, maincontents_rel, "MacOS", script) |
| 270 |
has_tool_script = os.path.exists(toolscript) |
| 271 |
if not has_tool_script: |
| 272 |
# Don't symlink, apps won't be able to run in parallel! |
| 273 |
shutil.copy( |
| 274 |
os.path.join(dist_dir, maincontents_rel, "MacOS", appname), toolscript |
| 275 |
) |
| 276 |
toolcontents = os.path.join(toolapp, "Contents") |
| 277 |
os.makedirs(toolcontents) |
| 278 |
subdirs = ["Frameworks", "Resources"] |
| 279 |
if has_tool_script: |
| 280 |
# PyInstaller |
| 281 |
subdirs.append("MacOS") |
| 282 |
for entry in os.listdir(os.path.join(dist_dir, maincontents_rel)): |
| 283 |
if entry in subdirs: |
| 284 |
os.makedirs(os.path.join(toolcontents, entry)) |
| 285 |
for subentry in os.listdir( |
| 286 |
os.path.join(dist_dir, maincontents_rel, entry) |
| 287 |
): |
| 288 |
src = os.path.join(dist_dir, maincontents_rel, entry, subentry) |
| 289 |
tgt = os.path.join(toolcontents, entry, subentry) |
| 290 |
if subentry == "main.py": |
| 291 |
# py2app |
| 292 |
with open(src, "r") as main_in: |
| 293 |
py = main_in.read() |
| 294 |
py = py.replace("main()", "main(%r)" % script[len(name) + 1 :]) |
| 295 |
with open(tgt, "wb") as main_out: |
| 296 |
main_out.write(py.encode()) |
| 297 |
continue |
| 298 |
if subentry == name + ".icns": |
| 299 |
shutil.copy( |
| 300 |
os.path.join(pydir, "theme", "icons", f"{script}.icns"), |
| 301 |
os.path.join(toolcontents, entry, f"{script}.icns"), |
| 302 |
) |
| 303 |
continue |
| 304 |
if subentry == script: |
| 305 |
# PyInstaller |
| 306 |
os.rename(src, tgt) |
| 307 |
elif subentry not in toolscripts: |
| 308 |
os.symlink( |
| 309 |
os.path.join( |
| 310 |
"..", "..", "..", maincontents_rel, entry, subentry |
| 311 |
), |
| 312 |
tgt, |
| 313 |
) |
| 314 |
elif entry == "Info.plist": |
| 315 |
with codecs.open( |
| 316 |
os.path.join(dist_dir, maincontents_rel, entry), "r", "UTF-8" |
| 317 |
) as info_in: |
| 318 |
infoxml = info_in.read() |
| 319 |
# CFBundleName / CFBundleDisplayName |
| 320 |
infoxml = re.sub( |
| 321 |
r"(Name</key>\s*<string>)%s" % name, |
| 322 |
lambda match: match.group(1) + toolname, |
| 323 |
infoxml, |
| 324 |
) |
| 325 |
# CFBundleIdentifier |
| 326 |
infoxml = infoxml.replace(f".{name}</string>", f".{script}</string>") |
| 327 |
# CFBundleIconFile |
| 328 |
infoxml = infoxml.replace( |
| 329 |
f"{name}.icns</string>", f"{script}.icns</string>" |
| 330 |
) |
| 331 |
# CFBundleExecutable |
| 332 |
infoxml = re.sub( |
| 333 |
r"(Executable</key>\s*<string>)%s" % name, |
| 334 |
lambda match: match.group(1) + script, |
| 335 |
infoxml, |
| 336 |
) |
| 337 |
with codecs.open( |
| 338 |
os.path.join(toolcontents, entry), "w", "UTF-8" |
| 339 |
) as info_out: |
| 340 |
info_out.write(infoxml) |
| 341 |
else: |
| 342 |
os.symlink( |
| 343 |
os.path.join("..", "..", maincontents_rel, entry), |
| 344 |
os.path.join(toolcontents, entry), |
| 345 |
) |
| 346 |
|
| 347 |
|
| 348 |
def get_data(tgt_dir, key, pkgname=None, subkey=None, excludes=None): |
| 349 |
"""Return configured data files. |
| 350 |
|
| 351 |
Args: |
| 352 |
tgt_dir (str): The target directory. |
| 353 |
key (str): The config key. |
| 354 |
pkgname (Union[None, str]): Name of the package. Default is None. |
| 355 |
subkey (Union[None, str]): Name of the subkey. Default is None. |
| 356 |
excludes (Union[None, List[str]]): List of files to exclude. Default is None. |
| 357 |
|
| 358 |
Returns: |
| 359 |
List[str]: List of strings showing the paths of the data files. |
| 360 |
""" |
| 361 |
files = config[key] |
| 362 |
src_dir = source_dir |
| 363 |
if pkgname: |
| 364 |
files = files[pkgname] |
| 365 |
# modifying the src_dir is not working with py2app, so disabling it. |
| 366 |
# src_dir = os.path.join(src_dir, pkgname) |
| 367 |
if subkey: |
| 368 |
if subkey in files: |
| 369 |
files = files[subkey] |
| 370 |
else: |
| 371 |
files = [] |
| 372 |
data = [] |
| 373 |
for pth in files: |
| 374 |
if not [exclude for exclude in excludes or [] if fnmatch(pth, exclude)]: |
| 375 |
normalized_path = os.path.normpath( |
| 376 |
os.path.join(tgt_dir, os.path.dirname(pth)) |
| 377 |
) |
| 378 |
safe_path = [ |
| 379 |
relpath(p, src_dir) for p in safe_glob(os.path.join(src_dir, pth)) |
| 380 |
] |
| 381 |
if pkgname: |
| 382 |
# try looking for the "{src_dir}/{pkgname}/{pth}" too |
| 383 |
safe_path += [ |
| 384 |
relpath(p, src_dir) |
| 385 |
for p in safe_glob(os.path.join(src_dir, pkgname, pth)) |
| 386 |
] |
| 387 |
data.append((normalized_path, safe_path)) |
| 388 |
return data |
| 389 |
|
| 390 |
|
| 391 |
def get_scripts(excludes=None): |
| 392 |
# It is required that each script has an accompanying .desktop file |
| 393 |
scripts_with_desc = [] |
| 394 |
scripts = safe_glob(os.path.join(pydir, "..", "scripts", appname.lower() + "*")) |
| 395 |
|
| 396 |
def sortbyname(a, b): |
| 397 |
a, b = [os.path.splitext(v)[0] for v in (a, b)] |
| 398 |
if a > b: |
| 399 |
return 1 |
| 400 |
elif a < b: |
| 401 |
return -1 |
| 402 |
else: |
| 403 |
return 0 |
| 404 |
|
| 405 |
import functools |
| 406 |
|
| 407 |
scripts = sorted(scripts, key=functools.cmp_to_key(sortbyname)) |
| 408 |
for script in scripts: |
| 409 |
script = os.path.basename(script) |
| 410 |
if script == appname.lower() + "-apply-profiles-launcher": |
| 411 |
continue |
| 412 |
desktopfile = os.path.join(pydir, "..", "misc", f"{script}.desktop") |
| 413 |
if os.path.isfile(desktopfile): |
| 414 |
cfg = ConfigParser() |
| 415 |
cfg.read(desktopfile) |
| 416 |
script = cfg.get("Desktop Entry", "Exec").split()[0] |
| 417 |
desc = cfg.get("Desktop Entry", "Name") |
| 418 |
else: |
| 419 |
desc = "" |
| 420 |
if not [exclude for exclude in excludes or [] if fnmatch(script, exclude)]: |
| 421 |
scripts_with_desc.append((script, desc)) |
| 422 |
return scripts_with_desc |
| 423 |
|
| 424 |
|
| 425 |
def setup(): |
| 426 |
print("***", os.path.abspath(sys.argv[0]), " ".join(sys.argv[1:])) |
| 427 |
|
| 428 |
bdist_bbfreeze = "bdist_bbfreeze" in sys.argv[1:] |
| 429 |
bdist_dumb = "bdist_dumb" in sys.argv[1:] |
| 430 |
bdist_win = "bdist_msi" in sys.argv[1:] or "bdist_wininst" in sys.argv[1:] |
| 431 |
debug = 0 |
| 432 |
do_full_install = False |
| 433 |
do_install = False |
| 434 |
do_py2app = "py2app" in sys.argv[1:] |
| 435 |
do_py2exe = "py2exe" in sys.argv[1:] |
| 436 |
do_uninstall = "uninstall" in sys.argv[1:] |
| 437 |
doc_layout = "deb" if os.path.exists("/etc/debian_version") else "" |
| 438 |
dry_run = "-n" in sys.argv[1:] or "--dry-run" in sys.argv[1:] |
| 439 |
help = False |
| 440 |
install_data = None # data files install path (only if given) |
| 441 |
is_rpm_build = "bdist_rpm" in sys.argv[1:] or os.path.abspath(sys.argv[0]).endswith( |
| 442 |
os.path.join( |
| 443 |
os.path.sep, |
| 444 |
"rpm", |
| 445 |
"BUILD", |
| 446 |
f"{name}-{version}", |
| 447 |
os.path.basename(os.path.abspath(sys.argv[0])), |
| 448 |
) |
| 449 |
) |
| 450 |
prefix = "" |
| 451 |
recordfile_name = None # record installed files to this file |
| 452 |
sdist = "sdist" in sys.argv[1:] |
| 453 |
setuptools = None |
| 454 |
skip_postinstall = "--skip-postinstall" in sys.argv[1:] |
| 455 |
use_distutils = not bdist_bbfreeze and not do_py2app |
| 456 |
use_setuptools = ( |
| 457 |
not use_distutils |
| 458 |
or "--use-setuptools" in sys.argv[1:] |
| 459 |
or (os.path.exists("use-setuptools") and "--use-distutils" not in sys.argv[1:]) |
| 460 |
) |
| 461 |
use_sdl = "--use-sdl" in sys.argv[1:] |
| 462 |
|
| 463 |
sys.path.insert(1, os.path.join(os.path.dirname(pydir), "util")) |
| 464 |
|
| 465 |
current_findall = distutils.filelist.findall |
| 466 |
|
| 467 |
if use_setuptools: |
| 468 |
if "--use-setuptools" in sys.argv[1:] and not os.path.exists("use-setuptools"): |
| 469 |
open("use-setuptools", "w").close() |
| 470 |
try: |
| 471 |
import setuptools |
| 472 |
from setuptools import setup, Extension, find_packages |
| 473 |
|
| 474 |
setuptools = True |
| 475 |
print("using setuptools") |
| 476 |
current_findall = find_packages |
| 477 |
except ImportError: |
| 478 |
pass |
| 479 |
else: |
| 480 |
if os.path.exists("use-setuptools"): |
| 481 |
os.remove("use-setuptools") |
| 482 |
|
| 483 |
if distutils.filelist.findall is current_findall: |
| 484 |
# Fix traversing unneeded dirs which can take a long time (minutes) |
| 485 |
def findall( |
| 486 |
dir=os.curdir, |
| 487 |
original=distutils.filelist.findall, |
| 488 |
listdir=os.listdir, |
| 489 |
basename=os.path.basename, |
| 490 |
): |
| 491 |
os.listdir = lambda path: [ |
| 492 |
entry |
| 493 |
for entry in listdir(path) |
| 494 |
if entry not in ("build", "dist") and not entry.startswith(".") |
| 495 |
] |
| 496 |
try: |
| 497 |
return original(dir) |
| 498 |
finally: |
| 499 |
os.listdir = listdir |
| 500 |
|
| 501 |
distutils.filelist.findall = findall |
| 502 |
|
| 503 |
if not setuptools: |
| 504 |
from distutils.core import setup, Extension |
| 505 |
|
| 506 |
print("using distutils") |
| 507 |
|
| 508 |
if do_py2exe: |
| 509 |
setup_do_py2exe() |
| 510 |
|
| 511 |
if do_uninstall: |
| 512 |
i = sys.argv.index("uninstall") |
| 513 |
sys.argv = sys.argv[:i] + ["install"] + sys.argv[i + 1 :] |
| 514 |
install.create_home_path = lambda self: None |
| 515 |
|
| 516 |
if ( |
| 517 |
skip_instrument_conf_files := "--skip-instrument-configuration-files" |
| 518 |
in sys.argv[1:] |
| 519 |
): |
| 520 |
i = sys.argv.index("--skip-instrument-configuration-files") |
| 521 |
sys.argv = sys.argv[:i] + sys.argv[i + 1 :] |
| 522 |
|
| 523 |
if not is_rpm_build: |
| 524 |
skip_instrument_conf_files = True |
| 525 |
|
| 526 |
if skip_postinstall: |
| 527 |
i = sys.argv.index("--skip-postinstall") |
| 528 |
sys.argv = sys.argv[:i] + sys.argv[i + 1 :] |
| 529 |
|
| 530 |
if "--use-distutils" in sys.argv[1:]: |
| 531 |
i = sys.argv.index("--use-distutils") |
| 532 |
sys.argv = sys.argv[:i] + sys.argv[i + 1 :] |
| 533 |
|
| 534 |
if "--use-setuptools" in sys.argv[1:]: |
| 535 |
i = sys.argv.index("--use-setuptools") |
| 536 |
sys.argv = sys.argv[:i] + sys.argv[i + 1 :] |
| 537 |
|
| 538 |
argv = list(sys.argv[1:]) |
| 539 |
for i, arg in enumerate(reversed(argv)): |
| 540 |
n = len(sys.argv) - i - 1 |
| 541 |
if arg in ( |
| 542 |
"install", |
| 543 |
"install_lib", |
| 544 |
"install_headers", |
| 545 |
"install_scripts", |
| 546 |
"install_data", |
| 547 |
): |
| 548 |
if arg == "install": |
| 549 |
do_full_install = True |
| 550 |
do_install = True |
| 551 |
elif arg == "-d" and len(sys.argv[1:]) > i: |
| 552 |
dist_dir = sys.argv[i + 2] |
| 553 |
else: |
| 554 |
arg = arg.split("=") |
| 555 |
if arg[0] == "--debug": |
| 556 |
debug = 1 if len(arg) == 1 else int(arg[1]) |
| 557 |
sys.argv = sys.argv[:n] + sys.argv[n + 1 :] |
| 558 |
elif len(arg) == 2: |
| 559 |
if arg[0] == "--dist-dir": |
| 560 |
dist_dir = arg[1] |
| 561 |
elif arg[0] == "--doc-layout": |
| 562 |
doc_layout = arg[1] |
| 563 |
sys.argv = sys.argv[:n] + sys.argv[n + 1 :] |
| 564 |
elif arg[0] == "--install-data": |
| 565 |
install_data = arg[1] |
| 566 |
elif arg[0] == "--prefix": |
| 567 |
prefix = arg[1] |
| 568 |
elif arg[0] == "--record": |
| 569 |
recordfile_name = arg[1] |
| 570 |
elif arg[0] == "-h" or arg[0].startswith("--help"): |
| 571 |
help = True |
| 572 |
|
| 573 |
if not recordfile_name and (do_full_install or do_uninstall): |
| 574 |
recordfile_name = "INSTALLED_FILES" |
| 575 |
# if not do_uninstall: |
| 576 |
# sys.argv.append("--record=" + "INSTALLED_FILES") |
| 577 |
|
| 578 |
if sys.platform in ("darwin", "win32") or "bdist_egg" in sys.argv[1:]: |
| 579 |
doc = data = "." if do_py2app or do_py2exe or bdist_bbfreeze else name |
| 580 |
else: |
| 581 |
# Linux/Unix |
| 582 |
data = name |
| 583 |
if doc_layout.startswith("deb"): |
| 584 |
doc = os.path.join("doc", name.lower()) |
| 585 |
elif "suse" in doc_layout: |
| 586 |
doc = os.path.join("doc", "packages", name) |
| 587 |
else: |
| 588 |
doc = os.path.join("doc", f"{name}-{version}") |
| 589 |
|
| 590 |
if not install_data: |
| 591 |
data = os.path.join("share", data) |
| 592 |
doc = os.path.join("share", doc) |
| 593 |
if is_rpm_build: |
| 594 |
doc = os.path.join(os.path.sep, "usr", doc) |
| 595 |
|
| 596 |
# Use CA file from certifi project |
| 597 |
if do_py2app or do_py2exe: |
| 598 |
import certifi |
| 599 |
|
| 600 |
cacert = certifi.where() |
| 601 |
if cacert: |
| 602 |
shutil.copyfile(cacert, os.path.join(pydir, "cacert.pem")) |
| 603 |
config["package_data"][name].append("cacert.pem") |
| 604 |
else: |
| 605 |
print("WARNING: cacert.pem from certifi project not found!") |
| 606 |
|
| 607 |
# on Mac OS X and Windows, we want data files in the package dir |
| 608 |
# (package_data will be ignored when using py2exe) |
| 609 |
package_data = { |
| 610 |
name: ( |
| 611 |
config["package_data"][name] |
| 612 |
if sys.platform in ("darwin", "win32") and not do_py2app and not do_py2exe |
| 613 |
else [] |
| 614 |
) |
| 615 |
} |
| 616 |
if sdist and sys.platform in ("darwin", "win32"): |
| 617 |
package_data[name].extend( |
| 618 |
["theme/icons/22x22/*.png", "theme/icons/24x24/*.png"] |
| 619 |
) |
| 620 |
if sys.platform == "win32" and not do_py2exe: |
| 621 |
package_data[name].append("theme/icons/*.ico") |
| 622 |
# Scripts |
| 623 |
if sys.platform == "darwin": |
| 624 |
scripts = get_scripts(excludes=[appname.lower() + "-apply-profiles"]) |
| 625 |
else: |
| 626 |
scripts = get_scripts() |
| 627 |
# Doc files |
| 628 |
data_files = [] |
| 629 |
if not is_rpm_build or doc_layout.startswith("deb"): |
| 630 |
data_files += get_data(doc, "doc", excludes=["LICENSE.txt"]) |
| 631 |
if data_files: |
| 632 |
data_files.append((doc, [os.path.join(pydir, "..", "dist", "copyright")])) |
| 633 |
data_files.append( |
| 634 |
( |
| 635 |
os.path.join(os.path.dirname(data), "doc-base"), |
| 636 |
[os.path.join(pydir, "..", "misc", appname.lower() + "-readme")], |
| 637 |
) |
| 638 |
) |
| 639 |
data_files.append( |
| 640 |
(doc, [relpath(os.path.join(pydir, "..", "LICENSE.txt"), source_dir)]) |
| 641 |
) |
| 642 |
|
| 643 |
# metainfo / appdata.xml |
| 644 |
data_files.append( |
| 645 |
( |
| 646 |
os.path.join(os.path.dirname(data), "metainfo"), |
| 647 |
[ |
| 648 |
relpath( |
| 649 |
os.path.normpath( |
| 650 |
os.path.join(pydir, "..", "dist", f"{appstream_id}.appdata.xml") |
| 651 |
), |
| 652 |
source_dir, |
| 653 |
) |
| 654 |
], |
| 655 |
) |
| 656 |
) |
| 657 |
|
| 658 |
if sys.platform not in ("darwin", "win32") or do_py2app or do_py2exe: |
| 659 |
# Linux/Unix or py2app/py2exe |
| 660 |
data_files += get_data(data, "package_data", name, excludes=["theme/icons/*"]) |
| 661 |
data_files += get_data(data, "data") |
| 662 |
data_files += get_data(data, "xtra_package_data", name, sys.platform) |
| 663 |
if sys.platform == "win32": |
| 664 |
# Add python and pythonw |
| 665 |
data_files.extend( |
| 666 |
[ |
| 667 |
( |
| 668 |
os.path.join(data, "lib"), |
| 669 |
[ |
| 670 |
sys.executable, |
| 671 |
os.path.join( |
| 672 |
os.path.dirname(sys.executable), "pythonw.exe" |
| 673 |
), |
| 674 |
], |
| 675 |
) |
| 676 |
] |
| 677 |
) |
| 678 |
if use_sdl: |
| 679 |
# SDL DLLs for audio module |
| 680 |
sdl2 = ctypes.util.find_library("SDL2") |
| 681 |
sdl2_mixer = ctypes.util.find_library("SDL2_mixer") |
| 682 |
if sdl2: |
| 683 |
sdl2_libs = [sdl2] |
| 684 |
if sdl2_mixer: |
| 685 |
sdl2_libs.append(sdl2_mixer) |
| 686 |
data_files.append((os.path.join(data, "lib"), sdl2_libs)) |
| 687 |
config["excludes"]["all"].append("pyglet") |
| 688 |
else: |
| 689 |
print("WARNING: SDL2_mixer not found!") |
| 690 |
else: |
| 691 |
print("WARNING: SDL2 not found!") |
| 692 |
if "pyglet" not in config["excludes"]["all"]: |
| 693 |
# OpenAL DLLs for pyglet |
| 694 |
openal32 = ctypes.util.find_library("OpenAL32.dll") |
| 695 |
wrap_oal = ctypes.util.find_library("wrap_oal.dll") |
| 696 |
if openal32: |
| 697 |
oal = [openal32] |
| 698 |
if wrap_oal: |
| 699 |
oal.append(wrap_oal) |
| 700 |
else: |
| 701 |
print("WARNING: wrap_oal.dll not found!") |
| 702 |
data_files.append((data, oal)) |
| 703 |
else: |
| 704 |
print("WARNING: OpenAL32.dll not found!") |
| 705 |
elif sys.platform != "darwin": |
| 706 |
# Linux |
| 707 |
data_files.append( |
| 708 |
( |
| 709 |
os.path.join(os.path.dirname(data), "applications"), |
| 710 |
[os.path.join(pydir, "..", "misc", f"{name.lower()}.desktop")] |
| 711 |
+ safe_glob( |
| 712 |
os.path.join(pydir, "..", "misc", f"{name.lower()}-*.desktop") |
| 713 |
), |
| 714 |
) |
| 715 |
) |
| 716 |
data_files.append( |
| 717 |
( |
| 718 |
( |
| 719 |
autostart |
| 720 |
if os.geteuid() == 0 or prefix.startswith("/") |
| 721 |
else autostart_home |
| 722 |
), |
| 723 |
[ |
| 724 |
os.path.join( |
| 725 |
pydir, |
| 726 |
"..", |
| 727 |
"misc", |
| 728 |
f"z-{name.lower()}-apply-profiles.desktop", |
| 729 |
) |
| 730 |
], |
| 731 |
) |
| 732 |
) |
| 733 |
data_files.append( |
| 734 |
( |
| 735 |
os.path.join(os.path.dirname(data), "man", "man1"), |
| 736 |
safe_glob(os.path.join(pydir, "..", "man", "*.1")), |
| 737 |
) |
| 738 |
) |
| 739 |
if not skip_instrument_conf_files: |
| 740 |
# device configuration / permission stuff |
| 741 |
if is_rpm_build: |
| 742 |
# RPM postinstall script will install these to the correct |
| 743 |
# locations. This allows us compatibility with Argyll |
| 744 |
# packages which may also contain same udev rules / hotplug |
| 745 |
# scripts, thus avoiding file conflicts |
| 746 |
data_files.append( |
| 747 |
( |
| 748 |
os.path.join(data, "usb"), |
| 749 |
[os.path.join(pydir, "..", "misc", "45-Argyll.rules")], |
| 750 |
) |
| 751 |
) |
| 752 |
data_files.append( |
| 753 |
( |
| 754 |
os.path.join(data, "usb"), |
| 755 |
[os.path.join(pydir, "..", "misc", "55-Argyll.rules")], |
| 756 |
) |
| 757 |
) |
| 758 |
data_files.append( |
| 759 |
( |
| 760 |
os.path.join(data, "usb"), |
| 761 |
[os.path.join(pydir, "..", "misc", "Argyll")], |
| 762 |
) |
| 763 |
) |
| 764 |
data_files.append( |
| 765 |
( |
| 766 |
os.path.join(data, "usb"), |
| 767 |
[os.path.join(pydir, "..", "misc", "Argyll.usermap")], |
| 768 |
) |
| 769 |
) |
| 770 |
else: |
| 771 |
devconf_files = [] |
| 772 |
if os.path.isdir("/etc/udev/rules.d"): |
| 773 |
if safe_glob("/dev/bus/usb/*/*"): |
| 774 |
# USB and serial instruments using udev, where udev |
| 775 |
# already creates /dev/bus/usb/00X/00X devices |
| 776 |
devconf_files.append( |
| 777 |
( |
| 778 |
"/etc/udev/rules.d", |
| 779 |
[ |
| 780 |
os.path.join( |
| 781 |
pydir, "..", "misc", "55-Argyll.rules" |
| 782 |
) |
| 783 |
], |
| 784 |
) |
| 785 |
) |
| 786 |
else: |
| 787 |
# USB using udev, where there are NOT /dev/bus/usb/00X/00X |
| 788 |
# devices |
| 789 |
devconf_files.append( |
| 790 |
( |
| 791 |
"/etc/udev/rules.d", |
| 792 |
[ |
| 793 |
os.path.join( |
| 794 |
pydir, "..", "misc", "45-Argyll.rules" |
| 795 |
) |
| 796 |
], |
| 797 |
) |
| 798 |
) |
| 799 |
else: |
| 800 |
if os.path.isdir("/etc/hotplug"): |
| 801 |
# USB using hotplug and Serial using udev |
| 802 |
# (older versions of Linux) |
| 803 |
devconf_files.append( |
| 804 |
( |
| 805 |
"/etc/hotplug/usb", |
| 806 |
[ |
| 807 |
os.path.join(pydir, "..", "misc", fname) |
| 808 |
for fname in ["Argyll", "Argyll.usermap"] |
| 809 |
], |
| 810 |
) |
| 811 |
) |
| 812 |
for entry in devconf_files: |
| 813 |
for fname in entry[1]: |
| 814 |
if os.path.isfile(fname): |
| 815 |
data_files.extend([(entry[0], [fname])]) |
| 816 |
for dname in ( |
| 817 |
"10x10", |
| 818 |
"16x16", |
| 819 |
"22x22", |
| 820 |
"24x24", |
| 821 |
"32x32", |
| 822 |
"48x48", |
| 823 |
"72x72", |
| 824 |
"128x128", |
| 825 |
"256x256", |
| 826 |
"512x512", |
| 827 |
): |
| 828 |
# Get all the icons needed, depending on platform |
| 829 |
# Only the icon sizes 10, 16, 32, 72, 256 and 512 include icons |
| 830 |
# that are used exclusively for UI elements. |
| 831 |
# These should be installed in an app-specific location, e.g. |
| 832 |
# under Linux $XDG_DATA_DIRS/DisplayCAL/theme/icons/ |
| 833 |
# The app icon sizes 16, 32, 48 and 256 (128 under Mac OS X), |
| 834 |
# which are used for taskbar icons and the like, as well as the |
| 835 |
# other sizes can be installed in a generic location, e.g. |
| 836 |
# under Linux $XDG_DATA_DIRS/icons/hicolor/<size>/apps/ |
| 837 |
# Generally, icon filenames starting with the lowercase app name |
| 838 |
# should be installed in the generic location. |
| 839 |
icons = [] |
| 840 |
desktopicons = [] |
| 841 |
if sys.platform == "darwin": |
| 842 |
largest_iconbundle_icon_size = "128x128" |
| 843 |
else: |
| 844 |
largest_iconbundle_icon_size = "256x256" |
| 845 |
for iconpath in safe_glob( |
| 846 |
os.path.join(pydir, "theme", "icons", dname, "*.png") |
| 847 |
): |
| 848 |
if not os.path.basename(iconpath).startswith(name.lower()) or ( |
| 849 |
sys.platform in ("darwin", "win32") |
| 850 |
and dname |
| 851 |
in ("16x16", "32x32", "48x48", largest_iconbundle_icon_size) |
| 852 |
): |
| 853 |
# In addition to UI element icons, we also need all the app |
| 854 |
# icons we use in get_icon_bundle under macOS/Windows, |
| 855 |
# otherwise they wouldn't be included (under Linux, these |
| 856 |
# are included for installation to the system-wide icon |
| 857 |
# theme location instead) |
| 858 |
icons.append(iconpath) |
| 859 |
elif sys.platform not in ("darwin", "win32"): |
| 860 |
desktopicons.append(iconpath) |
| 861 |
if icons: |
| 862 |
data_files.append((os.path.join(data, "theme", "icons", dname), icons)) |
| 863 |
if desktopicons: |
| 864 |
data_files.append( |
| 865 |
( |
| 866 |
os.path.join( |
| 867 |
os.path.dirname(data), "icons", "hicolor", dname, "apps" |
| 868 |
), |
| 869 |
desktopicons, |
| 870 |
) |
| 871 |
) |
| 872 |
if do_py2app: |
| 873 |
data_files.append( |
| 874 |
( |
| 875 |
os.path.join(data, "scripts"), |
| 876 |
[ |
| 877 |
os.path.join( |
| 878 |
pydir, |
| 879 |
"..", |
| 880 |
"scripts", |
| 881 |
f"{name.lower()}-eecolor-to-madvr-converter", |
| 882 |
) |
| 883 |
], |
| 884 |
) |
| 885 |
) |
| 886 |
|
| 887 |
sources = [] |
| 888 |
if sys.platform == "win32": |
| 889 |
macros = [("NT", None)] |
| 890 |
libraries = ["user32", "gdi32"] |
| 891 |
link_args = None |
| 892 |
elif sys.platform == "darwin": |
| 893 |
macros = [("__APPLE__", None), ("UNIX", None)] |
| 894 |
libraries = None |
| 895 |
# XXX: Not sure which macOS version exactly removed the need |
| 896 |
# to specify -framework |
| 897 |
if intlist(platform.mac_ver()[0].split(".")) >= [10, 7]: |
| 898 |
link_args = None |
| 899 |
else: |
| 900 |
link_args = [ |
| 901 |
"-framework Carbon", |
| 902 |
"-framework CoreFoundation", |
| 903 |
"-framework Python", |
| 904 |
"-framework IOKit", |
| 905 |
] |
| 906 |
|
| 907 |
else: |
| 908 |
macros = [("UNIX", None)] |
| 909 |
libraries = ["X11", "Xinerama", "Xrandr", "Xxf86vm"] |
| 910 |
link_args = None |
| 911 |
|
| 912 |
ext_modules = [] |
| 913 |
|
| 914 |
requires = [] |
| 915 |
if not setuptools or sys.platform != "win32": |
| 916 |
# wxPython windows installer doesn't add egg-info entry, so |
| 917 |
# a dependency check from pkg_resources would always fail |
| 918 |
requires.append( |
| 919 |
"wxPython (>= {})".format(".".join(str(n) for n in wx_minversion)) |
| 920 |
) |
| 921 |
if sys.platform == "win32": |
| 922 |
requires.append("pywin32 (>= 213.0)") |
| 923 |
|
| 924 |
packages = [name, f"{name}.lib", f"{name}.lib.agw"] |
| 925 |
|
| 926 |
attrs = { |
| 927 |
"author": author_ascii, |
| 928 |
"author_email": author_email, |
| 929 |
"classifiers": [ |
| 930 |
"Development Status :: 5 - Production/Stable", |
| 931 |
"Environment :: MacOS X", |
| 932 |
"Environment :: Win32 (MS Windows)", |
| 933 |
"Environment :: X11 Applications", |
| 934 |
"Intended Audience :: End Users/Desktop", |
| 935 |
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", |
| 936 |
"Operating System :: OS Independent", |
| 937 |
"Programming Language :: Python :: 3.8", |
| 938 |
"Programming Language :: Python :: 3.9", |
| 939 |
"Programming Language :: Python :: 3.10", |
| 940 |
"Programming Language :: Python :: 3.11", |
| 941 |
"Programming Language :: Python :: 3.12", |
| 942 |
"Programming Language :: Python :: 3.13", |
| 943 |
"Topic :: Multimedia :: Graphics", |
| 944 |
], |
| 945 |
"data_files": data_files, |
| 946 |
"description": description, |
| 947 |
"download_url": f"{development_home_page}/releases/download/{version}/{name}-{version}.tar.gz", |
| 948 |
"ext_modules": ext_modules, |
| 949 |
"license": "GPL v3", |
| 950 |
"long_description": longdesc, |
| 951 |
"long_description_content_type": "text/x-rst", |
| 952 |
"name": name, |
| 953 |
"packages": packages, |
| 954 |
"package_data": package_data, |
| 955 |
"package_dir": {name: name}, |
| 956 |
"platforms": [ |
| 957 |
"Python >= {} <= {}".format( |
| 958 |
".".join(str(n) for n in py_minversion), |
| 959 |
".".join(str(n) for n in py_maxversion), |
| 960 |
), |
| 961 |
"Linux/Unix with X11", |
| 962 |
"Mac OS X >= 10.4", |
| 963 |
"Windows 2000 and newer", |
| 964 |
], |
| 965 |
"requires": requires, |
| 966 |
"provides": [name], |
| 967 |
"scripts": [], |
| 968 |
"url": f"https://{DOMAIN}/", |
| 969 |
"version": msiversion if "bdist_msi" in sys.argv[1:] else version, |
| 970 |
} |
| 971 |
|
| 972 |
if setuptools: |
| 973 |
attrs["entry_points"] = { |
| 974 |
"gui_scripts": [ |
| 975 |
"{} = {}.main:main{}".format( |
| 976 |
script, |
| 977 |
name, |
| 978 |
( |
| 979 |
"" |
| 980 |
if script == name.lower() |
| 981 |
else script[len(name) :].lower().replace("-", "_") |
| 982 |
), |
| 983 |
) |
| 984 |
for script, desc in scripts |
| 985 |
] |
| 986 |
} |
| 987 |
attrs["exclude_package_data"] = {name: []} |
| 988 |
attrs["include_package_data"] = ( |
| 989 |
sys.platform in ("darwin", "win32") and not do_py2app |
| 990 |
) |
| 991 |
install_requires = [req.replace("(", "").replace(")", "") for req in requires] |
| 992 |
attrs["install_requires"] = install_requires |
| 993 |
attrs["zip_safe"] = False |
| 994 |
else: |
| 995 |
attrs["scripts"].extend( |
| 996 |
os.path.join("scripts", script) |
| 997 |
for script, desc in [ |
| 998 |
script_desc |
| 999 |
for script_desc in scripts |
| 1000 |
if script_desc[0] != f"{name.lower()}-apply-profiles" |
| 1001 |
or sys.platform != "darwin" |
| 1002 |
] |
| 1003 |
) |
| 1004 |
|
| 1005 |
if bdist_bbfreeze: |
| 1006 |
attrs["setup_requires"] = ["bbfreeze"] |
| 1007 |
|
| 1008 |
if "bdist_wininst" in sys.argv[1:]: |
| 1009 |
attrs["scripts"].append(os.path.join("util", f"{name}_postinstall.py")) |
| 1010 |
|
| 1011 |
if do_py2app: |
| 1012 |
mainpy = os.path.join(source_dir, "main.py") |
| 1013 |
if not os.path.exists(mainpy): |
| 1014 |
shutil.copy(os.path.join(source_dir, "scripts", name.lower()), mainpy) |
| 1015 |
attrs["app"] = [mainpy] |
| 1016 |
dist_dir = os.path.join( |
| 1017 |
pydir, |
| 1018 |
"..", |
| 1019 |
"dist", |
| 1020 |
f"py2app.{get_platform()}-py{sys.version_info[0]}.{sys.version_info[1]}", |
| 1021 |
f"{name}-{version}", |
| 1022 |
) |
| 1023 |
from py2app.build_app import py2app as py2app_cls |
| 1024 |
|
| 1025 |
py2app_cls._copy_package_data = py2app_cls.copy_package_data |
| 1026 |
|
| 1027 |
def copy_package_data(self, package, target_dir): |
| 1028 |
# Skip package data which is already included as data files |
| 1029 |
if package.identifier.split(".")[0] != name: |
| 1030 |
self._copy_package_data(package, target_dir) |
| 1031 |
|
| 1032 |
py2app_cls.copy_package_data = copy_package_data |
| 1033 |
attrs["options"] = { |
| 1034 |
"py2app": { |
| 1035 |
"argv_emulation": False, |
| 1036 |
"dist_dir": dist_dir, |
| 1037 |
"excludes": config["excludes"]["all"] + config["excludes"]["darwin"], |
| 1038 |
"iconfile": os.path.join(pydir, "theme", "icons", f"{name}.icns"), |
| 1039 |
"optimize": 0, |
| 1040 |
"plist": plist_dict, |
| 1041 |
} |
| 1042 |
} |
| 1043 |
if use_sdl: |
| 1044 |
attrs["options"]["py2app"]["frameworks"] = ["SDL2", "SDL2_mixer"] |
| 1045 |
attrs["setup_requires"] = ["py2app"] |
| 1046 |
|
| 1047 |
if do_py2exe: |
| 1048 |
import wx |
| 1049 |
from winmanifest_util import getmanifestxml |
| 1050 |
|
| 1051 |
if platform.architecture()[0] == "64bit": |
| 1052 |
arch = "amd64" |
| 1053 |
else: |
| 1054 |
arch = "x86" |
| 1055 |
manifest_xml = getmanifestxml( |
| 1056 |
os.path.join( |
| 1057 |
pydir, |
| 1058 |
"..", |
| 1059 |
"misc", |
| 1060 |
name |
| 1061 |
+ ( |
| 1062 |
f".exe.{arch}.VC90.manifest" |
| 1063 |
if hasattr(sys, "version_info") and sys.version_info[:2] >= (3, 8) |
| 1064 |
else ".exe.manifest" |
| 1065 |
), |
| 1066 |
) |
| 1067 |
) |
| 1068 |
tmp_scripts_dir = os.path.join(source_dir, "build", "temp.scripts") |
| 1069 |
if not os.path.isdir(tmp_scripts_dir): |
| 1070 |
os.makedirs(tmp_scripts_dir) |
| 1071 |
apply_profiles_launcher = ( |
| 1072 |
f"{appname.lower()}-apply-profiles-launcher", |
| 1073 |
f"{appname} Profile Loader Launcher", |
| 1074 |
) |
| 1075 |
for script, desc in scripts + [apply_profiles_launcher]: |
| 1076 |
shutil.copy( |
| 1077 |
os.path.join(source_dir, "scripts", script), |
| 1078 |
os.path.join(tmp_scripts_dir, script2pywname(script)), |
| 1079 |
) |
| 1080 |
attrs["windows"] = [ |
| 1081 |
Target( |
| 1082 |
**{ |
| 1083 |
"script": os.path.join(tmp_scripts_dir, script2pywname(script)), |
| 1084 |
"icon_resources": [ |
| 1085 |
( |
| 1086 |
1, |
| 1087 |
os.path.join( |
| 1088 |
pydir, |
| 1089 |
"theme", |
| 1090 |
"icons", |
| 1091 |
os.path.splitext(os.path.basename(script))[0] + ".ico", |
| 1092 |
), |
| 1093 |
) |
| 1094 |
], |
| 1095 |
"other_resources": [(24, 1, manifest_xml)], |
| 1096 |
"copyright": f"© {strftime('%Y')} {author}", |
| 1097 |
"description": desc, |
| 1098 |
} |
| 1099 |
) |
| 1100 |
for script, desc in [ |
| 1101 |
script_desc1 |
| 1102 |
for script_desc1 in scripts |
| 1103 |
if script_desc1[0] != appname.lower() + "-eecolor-to-madvr-converter" |
| 1104 |
and not script_desc1[0].endswith("-console") |
| 1105 |
] |
| 1106 |
] |
| 1107 |
|
| 1108 |
# Add profile loader launcher |
| 1109 |
attrs["windows"].append( |
| 1110 |
Target( |
| 1111 |
**{ |
| 1112 |
"script": os.path.join( |
| 1113 |
tmp_scripts_dir, script2pywname(apply_profiles_launcher[0]) |
| 1114 |
), |
| 1115 |
"icon_resources": [ |
| 1116 |
( |
| 1117 |
1, |
| 1118 |
os.path.join( |
| 1119 |
pydir, |
| 1120 |
"theme", |
| 1121 |
"icons", |
| 1122 |
appname + "-apply-profiles" + ".ico", |
| 1123 |
), |
| 1124 |
) |
| 1125 |
], |
| 1126 |
"other_resources": [(24, 1, manifest_xml)], |
| 1127 |
"copyright": f"© {strftime('%Y')} {author}", |
| 1128 |
"description": apply_profiles_launcher[1], |
| 1129 |
} |
| 1130 |
) |
| 1131 |
) |
| 1132 |
|
| 1133 |
# Programs that can run with and without GUI |
| 1134 |
console_scripts = [f"{name}-VRML-to-X3D-converter"] # No "-console" suffix! |
| 1135 |
for console_script in console_scripts: |
| 1136 |
console_script_path = os.path.join( |
| 1137 |
tmp_scripts_dir, console_script + "-console" |
| 1138 |
) |
| 1139 |
if not os.path.isfile(console_script_path): |
| 1140 |
shutil.copy( |
| 1141 |
os.path.join( |
| 1142 |
source_dir, "scripts", console_script.lower() + "-console" |
| 1143 |
), |
| 1144 |
console_script_path, |
| 1145 |
) |
| 1146 |
attrs["console"] = [ |
| 1147 |
Target( |
| 1148 |
**{ |
| 1149 |
"script": os.path.join( |
| 1150 |
tmp_scripts_dir, script2pywname(script) + "-console" |
| 1151 |
), |
| 1152 |
"icon_resources": [ |
| 1153 |
( |
| 1154 |
1, |
| 1155 |
os.path.join( |
| 1156 |
pydir, |
| 1157 |
"theme", |
| 1158 |
"icons", |
| 1159 |
os.path.splitext(os.path.basename(script))[0] + ".ico", |
| 1160 |
), |
| 1161 |
) |
| 1162 |
], |
| 1163 |
"other_resources": [(24, 1, manifest_xml)], |
| 1164 |
"copyright": f"© {strftime('%Y')} {author}", |
| 1165 |
"description": desc, |
| 1166 |
} |
| 1167 |
) |
| 1168 |
for script, desc in [ |
| 1169 |
script_desc2 |
| 1170 |
for script_desc2 in scripts |
| 1171 |
if script2pywname(script_desc2[0]) in console_scripts |
| 1172 |
] |
| 1173 |
] |
| 1174 |
|
| 1175 |
# Programs without GUI |
| 1176 |
attrs["console"].append( |
| 1177 |
Target( |
| 1178 |
**{ |
| 1179 |
"script": os.path.join( |
| 1180 |
tmp_scripts_dir, appname + "-eeColor-to-madVR-converter" |
| 1181 |
), |
| 1182 |
"icon_resources": [ |
| 1183 |
( |
| 1184 |
1, |
| 1185 |
os.path.join( |
| 1186 |
pydir, "theme", "icons", appname + "-3DLUT-maker.ico" |
| 1187 |
), |
| 1188 |
) |
| 1189 |
], |
| 1190 |
"other_resources": [(24, 1, manifest_xml)], |
| 1191 |
"copyright": f"© {strftime('%Y')} {author}", |
| 1192 |
"description": "Convert eeColor 65^3 to madVR 256^3 3D LUT " |
| 1193 |
"(video levels in, video levels out)", |
| 1194 |
} |
| 1195 |
) |
| 1196 |
) |
| 1197 |
|
| 1198 |
dist_dir = os.path.join( |
| 1199 |
pydir, |
| 1200 |
"..", |
| 1201 |
"dist", |
| 1202 |
f"py2exe.{get_platform()}-py{sys.version_info[0]}.{sys.version_info[1]}", |
| 1203 |
f"{name}-{version}", |
| 1204 |
) |
| 1205 |
attrs["options"] = { |
| 1206 |
"py2exe": { |
| 1207 |
"dist_dir": dist_dir, |
| 1208 |
"dll_excludes": [ |
| 1209 |
"iertutil.dll", |
| 1210 |
"MPR.dll", |
| 1211 |
"msvcm90.dll", |
| 1212 |
"msvcp90.dll", |
| 1213 |
"msvcr90.dll", |
| 1214 |
"mswsock.dll", |
| 1215 |
"urlmon.dll", |
| 1216 |
"w9xpopen.exe", |
| 1217 |
"gdiplus.dll", |
| 1218 |
"mfc90.dll", |
| 1219 |
], |
| 1220 |
"excludes": config["excludes"]["all"] + config["excludes"]["win32"], |
| 1221 |
"bundle_files": 3 if wx.VERSION >= (2, 8, 10, 1) else 1, |
| 1222 |
"compressed": 1, |
| 1223 |
"optimize": 0, # 0 = don’t optimize (generate .pyc) |
| 1224 |
# 1 = normal optimization (like python -O) |
| 1225 |
# 2 = extra optimization (like python -OO) |
| 1226 |
} |
| 1227 |
} |
| 1228 |
if debug: |
| 1229 |
attrs["options"]["py2exe"].update( |
| 1230 |
{"bundle_files": 3, "compressed": 0, "optimize": 0, "skip_archive": 1} |
| 1231 |
) |
| 1232 |
if setuptools: |
| 1233 |
attrs["setup_requires"] = ["py2exe"] |
| 1234 |
attrs["zipfile"] = os.path.join("lib", "library.zip") |
| 1235 |
|
| 1236 |
if (do_uninstall or do_install or bdist_win or bdist_dumb) and not help: |
| 1237 |
distutils.core._setup_stop_after = "commandline" |
| 1238 |
dist = setup(**attrs) |
| 1239 |
distutils.core._setup_stop_after = None |
| 1240 |
cmd = install(dist).get_finalized_command("install") |
| 1241 |
if debug > 0: |
| 1242 |
for attrname in [ |
| 1243 |
"base", |
| 1244 |
"data", |
| 1245 |
"headers", |
| 1246 |
"lib", |
| 1247 |
"libbase", |
| 1248 |
"platbase", |
| 1249 |
"platlib", |
| 1250 |
"prefix", |
| 1251 |
"purelib", |
| 1252 |
"root", |
| 1253 |
"scripts", |
| 1254 |
"userbase", |
| 1255 |
]: |
| 1256 |
if attrname not in ["prefix", "root"]: |
| 1257 |
attrname = "install_" + attrname |
| 1258 |
if hasattr(cmd, attrname): |
| 1259 |
print(attrname, getattr(cmd, attrname)) |
| 1260 |
if debug > 1: |
| 1261 |
try: |
| 1262 |
from ppdir import ppdir |
| 1263 |
except ImportError: |
| 1264 |
pass |
| 1265 |
else: |
| 1266 |
ppdir(cmd, types=[dict, list, str, tuple, type, str]) |
| 1267 |
if not install_data: |
| 1268 |
if sys.platform in ("darwin", "win32"): |
| 1269 |
# on Mac OS X and Windows, we want data files in the package dir |
| 1270 |
data_basedir = cmd.install_lib |
| 1271 |
else: |
| 1272 |
data_basedir = cmd.install_data |
| 1273 |
else: |
| 1274 |
data_basedir = install_data |
| 1275 |
|
| 1276 |
data = change_root(data_basedir, data) |
| 1277 |
doc = change_root(data_basedir, doc) |
| 1278 |
# determine in which cases we want to make data file paths relative to |
| 1279 |
# site-packages (on Mac and Windows) and when we want to make them |
| 1280 |
# absolute (Linux) |
| 1281 |
linux = sys.platform not in ("darwin", "win32") and ( |
| 1282 |
not cmd.root and setuptools |
| 1283 |
) |
| 1284 |
dar_win = ( |
| 1285 |
sys.platform in ("darwin", "win32") and (cmd.root or not setuptools) |
| 1286 |
) or bdist_win |
| 1287 |
if ( |
| 1288 |
not do_uninstall |
| 1289 |
and not install_data |
| 1290 |
and (linux or dar_win) |
| 1291 |
and attrs["data_files"] |
| 1292 |
): |
| 1293 |
if data_basedir.startswith(cmd.install_data + os.path.sep): |
| 1294 |
data_basedir = relpath(data_basedir, cmd.install_data) |
| 1295 |
for i, f in enumerate(attrs["data_files"]): |
| 1296 |
if isinstance(f, str): |
| 1297 |
attrs["data_files"][i] = change_root(data_basedir, f) |
| 1298 |
else: |
| 1299 |
attrs["data_files"][i] = (change_root(data_basedir, f[0]), f[1]) |
| 1300 |
|
| 1301 |
if do_uninstall and not help: |
| 1302 |
# Quick and dirty uninstall |
| 1303 |
if dry_run: |
| 1304 |
print("dry run - nothing will be removed") |
| 1305 |
else: |
| 1306 |
from DisplayCAL.postinstall import postuninstall |
| 1307 |
|
| 1308 |
# Yeah, yeah - its actually pre-uninstall |
| 1309 |
if cmd.root: |
| 1310 |
postuninstall(prefix=change_root(cmd.root, cmd.prefix)) |
| 1311 |
else: |
| 1312 |
postuninstall(prefix=cmd.prefix) |
| 1313 |
|
| 1314 |
removed = [] |
| 1315 |
visited = [] |
| 1316 |
|
| 1317 |
if os.path.exists(recordfile_name): |
| 1318 |
paths = [ |
| 1319 |
( |
| 1320 |
change_root(cmd.root, line.rstrip("\n")) |
| 1321 |
if cmd.root |
| 1322 |
else line.rstrip("\n") |
| 1323 |
) |
| 1324 |
for line in open(recordfile_name, "r") |
| 1325 |
] |
| 1326 |
else: |
| 1327 |
paths = [] |
| 1328 |
|
| 1329 |
if not paths: |
| 1330 |
# If the installed files have not been recorded, use some fallback |
| 1331 |
# logic to find them |
| 1332 |
paths = safe_glob(os.path.join(cmd.install_scripts, name)) |
| 1333 |
if sys.platform == "win32": |
| 1334 |
if setuptools: |
| 1335 |
paths += safe_glob(os.path.join(cmd.install_scripts, f"{name}.exe")) |
| 1336 |
paths += safe_glob( |
| 1337 |
os.path.join(cmd.install_scripts, f"{name}-script.py") |
| 1338 |
) |
| 1339 |
else: |
| 1340 |
paths += safe_glob(os.path.join(cmd.install_scripts, f"{name}.cmd")) |
| 1341 |
paths += safe_glob( |
| 1342 |
os.path.join(cmd.install_scripts, f"{name}_postinstall.py") |
| 1343 |
) |
| 1344 |
for attrname in ["data", "headers", "lib", "libbase", "platlib", "purelib"]: |
| 1345 |
path = os.path.join(getattr(cmd, f"install_{attrname}"), name) |
| 1346 |
if path not in paths: |
| 1347 |
# Using sys.version in this way is consistent with |
| 1348 |
# setuptools |
| 1349 |
paths += ( |
| 1350 |
safe_glob(path) |
| 1351 |
+ safe_glob( |
| 1352 |
f"{path}-{version}-py{sys.version_info[0]}.{sys.version_info[1]}*.egg" |
| 1353 |
) |
| 1354 |
+ safe_glob( |
| 1355 |
f"{path}-{version}-py{sys.version_info[0]}.{sys.version_info[1]}*.egg-info" |
| 1356 |
) |
| 1357 |
) |
| 1358 |
|
| 1359 |
if os.path.isabs(data) and data not in paths: |
| 1360 |
for fname in [ |
| 1361 |
"lang", |
| 1362 |
"presets", |
| 1363 |
"ref", |
| 1364 |
"report", |
| 1365 |
"screenshots", |
| 1366 |
"tests", |
| 1367 |
"theme", |
| 1368 |
"ti1", |
| 1369 |
"x3d-viewer", |
| 1370 |
"CHANGES.html", |
| 1371 |
"LICENSE.txt", |
| 1372 |
"README.html", |
| 1373 |
"README-fr.html", |
| 1374 |
"beep.wav", |
| 1375 |
"cacert.pem", |
| 1376 |
"camera_shutter.wav", |
| 1377 |
"ColorLookupTable.fx", |
| 1378 |
f"{name.lower()}.desktop", |
| 1379 |
f"{name.lower()}-3dlut-maker.desktop", |
| 1380 |
f"{name.lower()}-curve-viewer.desktop", |
| 1381 |
f"{name.lower()}-profile-info.desktop", |
| 1382 |
f"{name.lower()}-scripting-client.desktop", |
| 1383 |
f"{name.lower()}-synthprofile.desktop", |
| 1384 |
f"{name.lower()}-testchart-editor.desktop", |
| 1385 |
"pnp.ids", |
| 1386 |
"quirk.json", |
| 1387 |
"linear.cal", |
| 1388 |
"test.cal", |
| 1389 |
]: |
| 1390 |
path = os.path.join(data, fname) |
| 1391 |
if path not in paths: |
| 1392 |
paths += safe_glob(path) |
| 1393 |
if os.path.isabs(doc) and doc not in paths: |
| 1394 |
for fname in [ |
| 1395 |
"screenshots", |
| 1396 |
"theme", |
| 1397 |
"CHANGES.html", |
| 1398 |
"LICENSE.txt", |
| 1399 |
"README.html", |
| 1400 |
"README-fr.html", |
| 1401 |
]: |
| 1402 |
path = os.path.join(doc, fname) |
| 1403 |
if path not in paths: |
| 1404 |
paths += safe_glob(path) |
| 1405 |
if sys.platform == "win32": |
| 1406 |
from DisplayCAL.postinstall import get_special_folder_path |
| 1407 |
|
| 1408 |
startmenu_programs_common = get_special_folder_path( |
| 1409 |
"CSIDL_COMMON_PROGRAMS" |
| 1410 |
) |
| 1411 |
startmenu_programs = get_special_folder_path("CSIDL_PROGRAMS") |
| 1412 |
for path in (startmenu_programs_common, startmenu_programs): |
| 1413 |
if path: |
| 1414 |
for filename in ( |
| 1415 |
name, |
| 1416 |
"CHANGES", |
| 1417 |
"LICENSE", |
| 1418 |
"README", |
| 1419 |
"Uninstall", |
| 1420 |
): |
| 1421 |
paths += safe_glob( |
| 1422 |
os.path.join(path, name, f"{filename}.lnk") |
| 1423 |
) |
| 1424 |
|
| 1425 |
for path in paths: |
| 1426 |
if os.path.exists(path): |
| 1427 |
if path in visited: |
| 1428 |
continue |
| 1429 |
else: |
| 1430 |
visited.append(path) |
| 1431 |
if dry_run: |
| 1432 |
print(path) |
| 1433 |
continue |
| 1434 |
try: |
| 1435 |
if os.path.isfile(path): |
| 1436 |
os.remove(path) |
| 1437 |
elif os.path.isdir(path): |
| 1438 |
os.rmdir(path) |
| 1439 |
except Exception as exception: |
| 1440 |
print("could'nt remove", path) |
| 1441 |
print(" ", exception) |
| 1442 |
else: |
| 1443 |
print("removed", path) |
| 1444 |
removed.append(path) |
| 1445 |
while path != os.path.dirname(path): |
| 1446 |
# remove parent directories if empty |
| 1447 |
# could also use os.removedirs(path) but we want some status |
| 1448 |
# info |
| 1449 |
path = os.path.dirname(path) |
| 1450 |
if os.path.isdir(path): |
| 1451 |
if len(os.listdir(path)) == 0: |
| 1452 |
if path in visited: |
| 1453 |
continue |
| 1454 |
else: |
| 1455 |
visited.append(path) |
| 1456 |
if dry_run: |
| 1457 |
print(path) |
| 1458 |
continue |
| 1459 |
try: |
| 1460 |
os.rmdir(path) |
| 1461 |
except Exception as exception: |
| 1462 |
print("could'nt remove", path) |
| 1463 |
print(" ", exception) |
| 1464 |
else: |
| 1465 |
print("removed", path) |
| 1466 |
removed.append(path) |
| 1467 |
else: |
| 1468 |
break |
| 1469 |
|
| 1470 |
if not removed: |
| 1471 |
print(len(visited), "entries found") |
| 1472 |
else: |
| 1473 |
print(len(removed), "entries removed") |
| 1474 |
|
| 1475 |
else: |
| 1476 |
# To have a working sdist and bdist_rpm when using distutils, |
| 1477 |
# we go to the length of generating MANIFEST.in from scratch everytime, |
| 1478 |
# using the information available from setup. |
| 1479 |
manifest_in = ["# This file will be re-generated by setup.py - do not edit"] |
| 1480 |
manifest_in.extend( |
| 1481 |
[ |
| 1482 |
"include LICENSE.txt", |
| 1483 |
"include MANIFEST", |
| 1484 |
"include MANIFEST.in", |
| 1485 |
"include README.html", |
| 1486 |
"include README-fr.html", |
| 1487 |
"include CHANGES.html", |
| 1488 |
f"include {name}*.pyw", |
| 1489 |
f"include {name}-*.pyw", |
| 1490 |
f"include {name}-*.py", |
| 1491 |
"include use-distutils", |
| 1492 |
] |
| 1493 |
) |
| 1494 |
manifest_in.append("include " + os.path.basename(sys.argv[0])) |
| 1495 |
manifest_in.append( |
| 1496 |
"include " + os.path.splitext(os.path.basename(sys.argv[0]))[0] + ".cfg" |
| 1497 |
) |
| 1498 |
for _datadir, datafiles in attrs.get("data_files", []): |
| 1499 |
for datafile in datafiles: |
| 1500 |
manifest_in.append( |
| 1501 |
"include {}".format( |
| 1502 |
relpath(os.path.sep.join(datafile.split("/")), source_dir) |
| 1503 |
or datafile |
| 1504 |
) |
| 1505 |
) |
| 1506 |
for extmod in attrs.get("ext_modules", []): |
| 1507 |
manifest_in.extend( |
| 1508 |
"include " + os.path.sep.join(src.split("/")) for src in extmod.sources |
| 1509 |
) |
| 1510 |
for pkg in attrs.get("packages", []): |
| 1511 |
pkg = os.path.join(*pkg.split(".")) |
| 1512 |
pkgdir = os.path.sep.join( |
| 1513 |
attrs.get("package_dir", {}).get(pkg, pkg).split("/") |
| 1514 |
) |
| 1515 |
manifest_in.append("include " + os.path.join(pkgdir, "*.py")) |
| 1516 |
# manifest_in.append("include " + os.path.join(pkgdir, "*.pyd")) |
| 1517 |
# manifest_in.append("include " + os.path.join(pkgdir, "*.so")) |
| 1518 |
for obj in attrs.get("package_data", {}).get(pkg, []): |
| 1519 |
manifest_in.append( |
| 1520 |
"include " + os.path.sep.join([pkgdir] + obj.split("/")) |
| 1521 |
) |
| 1522 |
for pymod in attrs.get("py_modules", []): |
| 1523 |
manifest_in.append("include {}".format(os.path.join(*pymod.split(".")))) |
| 1524 |
manifest_in.append( |
| 1525 |
"include {}".format(os.path.join(name, "theme", "theme-info.txt")) |
| 1526 |
) |
| 1527 |
manifest_in.append( |
| 1528 |
"recursive-include {} {} {}".format( |
| 1529 |
os.path.join(name, "theme", "icons"), "*.icns", "*.ico" |
| 1530 |
) |
| 1531 |
) |
| 1532 |
manifest_in.append("include {}".format(os.path.join("man", "*.1"))) |
| 1533 |
manifest_in.append("recursive-include misc *") |
| 1534 |
if skip_instrument_conf_files: |
| 1535 |
manifest_in.extend( |
| 1536 |
[ |
| 1537 |
"exclude misc/Argyll", |
| 1538 |
"exclude misc/*.rules", |
| 1539 |
"exclude misc/*.usermap", |
| 1540 |
] |
| 1541 |
) |
| 1542 |
manifest_in.append("include {}".format(os.path.join("screenshots", "*.png"))) |
| 1543 |
manifest_in.append("include {}".format(os.path.join("scripts", "*"))) |
| 1544 |
manifest_in.append("include {}".format(os.path.join("tests", "*"))) |
| 1545 |
manifest_in.append("recursive-include theme *") |
| 1546 |
manifest_in.append("recursive-include util *.cmd *.py *.sh") |
| 1547 |
if sys.platform == "win32" and not setuptools: |
| 1548 |
# Only needed under Windows |
| 1549 |
manifest_in.append("global-exclude .svn/*") |
| 1550 |
manifest_in.append("global-exclude *~") |
| 1551 |
manifest_in.append("global-exclude *.backup") |
| 1552 |
manifest_in.append("global-exclude *.bak") |
| 1553 |
if not dry_run: |
| 1554 |
manifest = open("MANIFEST.in", "w") |
| 1555 |
manifest.write("\n".join(manifest_in)) |
| 1556 |
manifest.close() |
| 1557 |
if os.path.exists("MANIFEST"): |
| 1558 |
os.remove("MANIFEST") |
| 1559 |
|
| 1560 |
if bdist_bbfreeze: |
| 1561 |
i = sys.argv.index("bdist_bbfreeze") |
| 1562 |
if "-d" not in sys.argv[i + 1 :] and "--dist-dir" not in sys.argv[i + 1 :]: |
| 1563 |
dist_dir = os.path.join( |
| 1564 |
pydir, |
| 1565 |
"..", |
| 1566 |
"dist", |
| 1567 |
f"bbfreeze.{get_platform()}-py{sys.version_info[0]}.{sys.version_info[1]}", |
| 1568 |
) |
| 1569 |
sys.argv.insert(i + 1, f"--dist-dir={dist_dir}") |
| 1570 |
if "egg_info" not in sys.argv[1:i]: |
| 1571 |
sys.argv.insert(i, "egg_info") |
| 1572 |
|
| 1573 |
if do_py2app or do_py2exe: |
| 1574 |
sys.path.insert(1, pydir) |
| 1575 |
i = sys.argv.index("py2app" if do_py2app else "py2exe") |
| 1576 |
if "build_ext" not in sys.argv[1:i]: |
| 1577 |
sys.argv.insert(i, "build_ext") |
| 1578 |
|
| 1579 |
setup(**attrs) |
| 1580 |
|
| 1581 |
if dry_run or help: |
| 1582 |
return |
| 1583 |
|
| 1584 |
import wx |
| 1585 |
|
| 1586 |
if wx.VERSION >= (4,): |
| 1587 |
# Fix wxPython 4 dylibs being included in wrong location |
| 1588 |
wx_dylibs = os.path.join(lib_dynload_dir, "wx") |
| 1589 |
for entry in os.listdir(frameworks_dir): |
| 1590 |
if entry.startswith("libwx"): |
| 1591 |
dylib = os.path.join(frameworks_dir, entry) |
| 1592 |
lib_dylib = os.path.join(wx_dylibs, entry) |
| 1593 |
print("Moving", dylib, "->", lib_dylib) |
| 1594 |
shutil.move(dylib, lib_dylib) |
| 1595 |
|
| 1596 |
create_app_symlinks(dist_dir, scripts) |
| 1597 |
|
| 1598 |
if do_py2exe: |
| 1599 |
shutil.copy( |
| 1600 |
os.path.join( |
| 1601 |
dist_dir, f"python{sys.version_info[0]}{sys.version_info[1]}.dll" |
| 1602 |
), |
| 1603 |
os.path.join( |
| 1604 |
dist_dir, |
| 1605 |
"lib", |
| 1606 |
f"python{sys.version_info[0]}{sys.version_info[1]}.dll", |
| 1607 |
), |
| 1608 |
) |
| 1609 |
|
| 1610 |
if ( |
| 1611 |
(bdist_bbfreeze and sys.platform == "win32") or do_py2exe |
| 1612 |
) and sys.version_info[:2] >= (2, 6): |
| 1613 |
from vc90crt import name as vc90crt_name, vc90crt_copy_files |
| 1614 |
|
| 1615 |
if do_py2exe: |
| 1616 |
vc90crt_copy_files(dist_dir) |
| 1617 |
vc90crt_copy_files(os.path.join(dist_dir, "lib")) |
| 1618 |
else: |
| 1619 |
vc90crt_copy_files(os.path.join(dist_dir, name + "-" + version)) |
| 1620 |
|
| 1621 |
if do_full_install and not is_rpm_build and not skip_postinstall: |
| 1622 |
from DisplayCAL.postinstall import postinstall |
| 1623 |
|
| 1624 |
if sys.platform == "win32": |
| 1625 |
path = os.path.join(cmd.install_lib, name) |
| 1626 |
# Using sys.version in this way is consistent with setuptools |
| 1627 |
for path in safe_glob(path) + safe_glob( |
| 1628 |
os.path.join( |
| 1629 |
f"{path}-{version}-py{sys.version[:3]}*.egg", |
| 1630 |
name, |
| 1631 |
) |
| 1632 |
): |
| 1633 |
if cmd.root: |
| 1634 |
postinstall(prefix=change_root(cmd.root, path)) |
| 1635 |
else: |
| 1636 |
postinstall(prefix=path) |
| 1637 |
|
| 1638 |
elif cmd.root: |
| 1639 |
postinstall(prefix=change_root(cmd.root, cmd.prefix)) |
| 1640 |
else: |
| 1641 |
postinstall(prefix=cmd.prefix) |
| 1642 |
|
| 1643 |
|
| 1644 |
def setup_do_py2exe(): |
| 1645 |
import py2exe |
| 1646 |
|
| 1647 |
# ModuleFinder can't handle runtime changes to __path__, but win32com |
| 1648 |
# uses them |
| 1649 |
try: |
| 1650 |
# if this doesn't work, try import modulefinder |
| 1651 |
import py2exe.mf as modulefinder |
| 1652 |
import win32com |
| 1653 |
|
| 1654 |
for p in win32com.__path__[1:]: |
| 1655 |
modulefinder.AddPackagePath("win32com", p) |
| 1656 |
for extra in ["win32com.shell"]: |
| 1657 |
__import__(extra) |
| 1658 |
m = sys.modules[extra] |
| 1659 |
for p in m.__path__[1:]: |
| 1660 |
modulefinder.AddPackagePath(extra, p) |
| 1661 |
except ImportError: |
| 1662 |
# no build path setup, no worries. |
| 1663 |
pass |
| 1664 |
origIsSystemDLL = py2exe.build_exe.isSystemDLL |
| 1665 |
systemroot = os.getenv("SystemRoot").lower() |
| 1666 |
|
| 1667 |
def isSystemDLL(pathname): |
| 1668 |
if ( |
| 1669 |
os.path.basename(pathname).lower() in ("gdiplus.dll", "mfc90.dll") |
| 1670 |
or os.path.basename(pathname).lower().startswith("python") |
| 1671 |
or os.path.basename(pathname).lower().startswith("pywintypes") |
| 1672 |
): |
| 1673 |
return 0 |
| 1674 |
return pathname.lower().startswith(systemroot + "\\") |
| 1675 |
|
| 1676 |
py2exe.build_exe.isSystemDLL = isSystemDLL |
| 1677 |
|
| 1678 |
|
| 1679 |
if __name__ == "__main__": |
| 1680 |
setup() |