Skip to content

Commit 0fd2f24

Browse files
committed
Turning subprocess commands into fake absolute path for Codefactor
Using /usr/bin/env prefix, codefactor is happy as it's now an absolute path yet it's still using the user's environment, allowing overrides, which we'd prefer. Also disables urlopen warning as we control the url protocol
1 parent f0bc5e7 commit 0fd2f24

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

setup.py

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ def libzim_fname(self):
118118
@property
119119
def is_musl(self) -> bool:
120120
"""whether running on a musl system (Alpine)"""
121-
ps = subprocess.run(["ldd", "--version"], capture_output=True, text=True)
121+
ps = subprocess.run(
122+
["/usr/bin/env", "ldd", "--version"], capture_output=True, text=True
123+
)
122124
try:
123125
return "musl libc" in ps.stdout.readlines()[0]
124126
except Exception:
@@ -171,7 +173,7 @@ def download_to_dest(self):
171173
dest.unlink()
172174
# create universal from all archs
173175
subprocess.run(
174-
["lipo"]
176+
["/usr/bin/env", "lipo"]
175177
+ [
176178
str(folder / "lib" / self.libzim_fname)
177179
for folder in folders.values()
@@ -203,7 +205,7 @@ def _download_and_extract(self, filename: str) -> pathlib.Path:
203205
# download a local copy if none present
204206
if not fpath.exists():
205207
print(f"> from {url}")
206-
with urllib.request.urlopen(url) as response, open(
208+
with urllib.request.urlopen(url) as response, open( # nosec
207209
fpath, "wb"
208210
) as fh: # nosec
209211
fh.write(response.read())
@@ -241,6 +243,7 @@ def _install_from(self, folder: pathlib.Path):
241243
print("> ensure libzim is notarized")
242244
spctl = subprocess.run(
243245
[
246+
"/usr/bin/env",
244247
"spctl",
245248
"-a",
246249
"-v",
@@ -363,6 +366,7 @@ def build_extension(self, ext):
363366

364367
subprocess.run(
365368
[
369+
"/usr/bin/env",
366370
"install_name_tool",
367371
"-change",
368372
config.libzim_fname,
@@ -387,6 +391,7 @@ def sign_extension_macos(self, ext):
387391
print("> signing the extension")
388392
subprocess.run(
389393
[
394+
"/usr/bin/env",
390395
"codesign",
391396
"--force",
392397
"--sign",
@@ -401,13 +406,22 @@ def sign_extension_macos(self, ext):
401406
print("> create ZIP package for notarization request")
402407
ext_zip = ext_fpath.with_name(f"{ext_fpath.name}.zip")
403408
subprocess.run(
404-
["ditto", "-c", "-k", "--keepParent", str(ext_fpath), str(ext_zip)]
409+
[
410+
"/usr/bin/env",
411+
"ditto",
412+
"-c",
413+
"-k",
414+
"--keepParent",
415+
str(ext_fpath),
416+
str(ext_zip),
417+
]
405418
)
406419

407420
print("> request notarization")
408421
# security unlock-keychain -p mysecretpassword $(pwd)/build.keychain
409422
subprocess.run(
410423
[
424+
"/usr/bin/env",
411425
"xcrun",
412426
"notarytool",
413427
"submit",
@@ -426,7 +440,15 @@ def sign_extension_macos(self, ext):
426440

427441
print("> displaying request status (should be rejected)")
428442
subprocess.run(
429-
["spctl", "--assess", "-vv", "--type", "install", str(ext_fpath)],
443+
[
444+
"/usr/bin/env",
445+
"spctl",
446+
"--assess",
447+
"-vv",
448+
"--type",
449+
"install",
450+
str(ext_fpath),
451+
],
430452
check=False,
431453
)
432454

0 commit comments

Comments
 (0)