forked from receyuki/stable-diffusion-prompt-reader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
125 lines (108 loc) · 3.61 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
__author__ = "receyuki"
__filename__ = "setup.py"
__copyright__ = "Copyright 2023"
__email__ = "[email protected]"
"""
Create executables file for macOS and Windows
Usage:
macOS:
python setup.py py2app
windows:
python setup.py
"""
import platform
import toml
from pathlib import Path
from packaging import version
# from sd_prompt_reader.__version__ import VERSION
def get_version():
path = Path(__file__).resolve().parents[0] / "pyproject.toml"
pyproject = toml.loads(open(str(path)).read())
return version.parse(pyproject["tool"]["poetry"]["version"])
VERSION = get_version().base_version
version_file = Path(__file__).resolve().parents[0] / "sd_prompt_reader/__version__.py"
with open(version_file, "w") as file:
file.write('VERSION = "' + str(get_version()) + '"\n')
if platform.system() == "Windows":
import pyinstaller_versionfile
pyinstaller_versionfile.create_versionfile(
output_file="file_version_info.txt",
version=get_version().base_version,
file_description="SD Prompt Reader",
internal_name="SD Prompt Reader",
legal_copyright="Copyright © 2023 receyuki All rights reserved.",
original_filename="SD Prompt Reader.exe",
product_name="SD Prompt Reader",
translations=[1033, 1200],
)
import PyInstaller.__main__
PyInstaller.__main__.run(["--clean", "win.spec"])
elif platform.system() == "Darwin":
from pathlib import Path
from setuptools import setup
import tkinter as tk
import shutil
import os
APP = ["main.py"]
DATA_FILES = []
CFBundleDocumentTypes = [
dict(
CFBundleTypeExtensions=["png", "jpg", "jpeg", "webp"],
CFBundleTypeName="Image File",
CFBundleTypeRole="Viewer",
),
]
OPTIONS = {
"iconfile": "sd_prompt_reader/resources/icon.icns",
"plist": {
"CFBundleName": "SD Prompt Reader",
"CFBundleDisplayName": "SD Prompt Reader",
"CFBundleVersion": str(get_version()),
"CFBundleShortVersionString": get_version().base_version,
"CFBundleIdentifier": "com.receyuki.sd-prompt-reader",
"NSHumanReadableCopyright": "Copyright © 2023 receyuki All rights reserved.",
"CFBundleDocumentTypes": CFBundleDocumentTypes,
},
"includes": [
"pyperclip",
"PIL",
"tkinter",
"tkinterdnd2",
"os",
"customtkinter",
"plyer",
"pyobjus",
"plyer.platforms.macosx.notification",
"tcl8",
"tcl8.6",
"charset_normalizer.md__mypyc",
"PIL.WebPImagePlugin",
"sd_prompt_reader",
],
"packages": ["sd_prompt_reader.resources"],
}
setup(
name="SD Prompt Reader",
app=APP,
data_files=DATA_FILES,
options={"py2app": OPTIONS},
setup_requires=["py2app"],
)
root = tk.Tk()
root.overrideredirect(True)
root.withdraw()
tcl_dir = Path(root.tk.exprstring("$tcl_library"))
tk_dir = Path(root.tk.exprstring("$tk_library"))
root.destroy()
os.makedirs("./dist/SD Prompt Reader.app/Contents/lib", exist_ok=True)
print(f"Copying TK from: {tk_dir}")
shutil.copytree(
tk_dir, f"./dist/SD Prompt Reader.app/Contents/lib/{tk_dir.parts[-1]}"
)
print(f"Copying TCL from: {tcl_dir}")
shutil.copytree(
tcl_dir, f"./dist/SD Prompt Reader.app/Contents/lib/{tcl_dir.parts[-1]}"
)
shutil.copy(
"__error__.sh", "./dist/SD Prompt Reader.app/Contents/Resources/__error__.sh"
)