8000 Merge pull request #1402 from stonebig/master · LeeXyan/winpython@8841693 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8841693

Browse files
authored
Merge pull request winpython#1402 from stonebig/master
remove NSIS python code
2 parents a065889 + f9f86c0 commit 8841693

File tree

1 file changed

+1
-114
lines changed

make.py

Lines changed: 1 addition & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,6 @@ def get_drives():
4141
return drives
4242

4343

44-
def get_nsis_exe():
45-
"""Return NSIS executable"""
46-
localdir = str(Path(sys.prefix).parent.parent)
47-
for drive in get_drives():
48-
for dirname in (
49-
r"C:\Program Files",
50-
r"C:\Program Files (x86)",
51-
drive + r"PortableApps\NSISPortableANSI",
52-
drive + r"PortableApps\NSISPortable",
53-
str(Path(localdir) / "NSISPortableANSI"),
54-
str(Path(localdir) / "NSISPortable"),
55-
):
56-
for subdirname in (".", "App"):
57-
exe = str(Path(dirname) / subdirname / "NSIS" / "makensis.exe")
58-
if Path(exe).is_file():
59-
return exe
60-
else:
61-
raise RuntimeError("NSIS is not installed on this computer.")
62-
63-
6444
def get_7zip_exe():
6545
"""Return 7zip executable"""
6646
localdir = str(Path(sys.prefix).parent.parent)
@@ -78,27 +58,6 @@ def get_7zip_exe():
7858
raise RuntimeError("7ZIP is not installed on this computer.")
7959

8060

81-
def replace_in_nsis_file(fname, data):
82-
"""Replace text in line starting with *start*, from this position:
83-
data is a list of (start, text) tuples"""
84-
fd = open(fname, "U")
85-
lines = fd.readlines()
86-
fd.close()
87-
for idx, line in enumerate(lines):
88-
for start, text in data:
89-
if start not in (
90-
"Icon",
91-
"OutFile",
92-
) and not start.startswith("!"):
93-
start = "!define " + start
94-
if line.startswith(start + " "):
95-
lines[idx] = line[: len(start) + 1] + f'"{text}"' + "\n"
96-
fd = open(fname, "w")
97-
fd.writelines(lines)
98-
print("iss for ", fname, "is", lines)
99-
fd.close()
100-
101-
10261
def replace_in_7zip_file(fname, data):
10362
"""Replace text in line starting with *start*, from this position:
10463
data is a list of (start, text) tuples"""
@@ -120,35 +79,6 @@ def replace_in_7zip_file(fname, data):
12079
fd.close()
12180

12281

123-
def build_nsis(srcname, dstname, data):
124-
"""Build NSIS script"""
125-
NSIS_EXE = get_nsis_exe() # NSIS Compiler
126-
portable_dir = str(Path(__file__).resolve().parent / "portable")
127-
shutil.copy(str(Path(portable_dir) / srcname), dstname)
128-
data = [
129-
(
130-
"!addincludedir",
131-
str(Path(portable_dir) / "include"),
132-
)
133-
] + list(data)
134-
replace_in_nsis_file(dstname, data)
135-
try:
136-
retcode = subprocess.call(
137-
f'"{NSIS_EXE}" -V2 "{dstname}"',
138-
shell=True,
139-
stdout=sys.stderr,
140-
)
141-
if retcode < 0:
142-
print(
143-
"Child was terminated by signal",
144-
-retcode,
145-
file=sys.stderr,
146-
)
147-
except OSError as e:
148-
print("Execution failed:", e, file=sys.stderr)
149-
os.remove(dstname)
150-
151-
15282
def build_shimmy_launcher(launcher_name, command, icon_path, mkshim_program='mkshim400.py', workdir=''):
15383
"""Build .exe launcher with mkshim_program and pywin32"""
15484

@@ -449,44 +379,6 @@ def create_launcher_shimmy(
449379
true_command = command.replace(r"$SYSDIR\cmd.exe","cmd.exe")+ " " + args
450380
build_shimmy_launcher(iconlauncherfullname, true_command, icon_fname, mkshim_program=mkshim_program, workdir=workdir)
451381

452-
def create_launcher(
453-
self,
454-
name,
455-
icon,
456-
command=None,
457-
args=None,
458-
workdir=r"$EXEDIR\scripts",
459-
launcher="launcher_basic.nsi",
460-
):
461-
"""Create exe launcher with NSIS"""
462-
assert name.endswith(".exe")
463-
portable_dir = str(Path(__file__).resolve().parent / "portable")
464-
icon_fname = str(Path(portable_dir) / "icons" / icon)
465-
assert Path(icon_fname).is_file()
466-
467-
# Customizing NSIS script
468-
if command is None:
469-
if args is not None and ".pyw" in args:
470-
command = "${WINPYDIR}\pythonw.exe"
471-
else:
472-
command = "${WINPYDIR}\python.exe"
473-
if args is None:
474-
args = ""
475-
if workdir is None:
476-
workdir = ""
477-
fname = str(Path(self.winpydir) / (Path(name).stem + ".nsi"))
478-
479-
data = [
480-
("WINPYDIR", f"$EXEDIR\{self.python_name}"),
481-
("WINPYVER", self.winpyver),
482-
("COMMAND", command),
483-
("PARAMETERS", args),
484-
("WORKDIR", workdir),
485-
("Icon", icon_fname),
486-
("OutFile", name),
487-
]
488-
489-
build_nsis(launcher, fname, data)
490382

491383
def create_python_batch(
492384
self,
@@ -1495,10 +1387,8 @@ def make(
14951387
# self._add_msvc_files() # replaced per msvc_runtime package
14961388
self._create_batch_scripts_initial()
14971389
self._create_batch_scripts()
1498-
# always create all launchers (as long as it is NSIS-based)
1390+
# always create all launchers (as long as it is not shimmy-based, to see for after)
14991391
self._create_launchers()
1500-
# pre-patch current pip (until default python has pip 8.0.3)
1501-
15021392
# PyPY must ensure pip
15031393
# "pypy3.exe -m ensurepip"
15041394
utils.python_execmodule("ensurepip", self.distribution.target)
@@ -1531,9 +1421,6 @@ def make(
15311421
print(f"piping {' '.join(actions)}")
15321422
self._print(f"piping {' '.join(actions)}")
15331423
self.distribution.do_pip_action(actions)
1534-
# actions=["install","-r", req, "--no-index",
1535-
# "--trusted-host=None"]+ links,
1536-
# install_options=None)
15371424
self._run_complement_batch_scripts()
15381425
self.distribution.patch_standard_packages()
15391426
if remove_existing and not self.simulation:

0 commit comments

Comments
 (0)
0