Skip to content

Commit 5f33b38

Browse files
sethmlarsonhugovk
andauthored
Use sys.exit(), remove unnecessary global for CPYTHON_ROOT_DIR
Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent 41395d0 commit 5f33b38

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Tools/build/generate_sbom.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import glob
77
import pathlib
88
import subprocess
9+
import sys
910
import typing
1011
from urllib.request import urlopen
1112

@@ -113,7 +114,7 @@ def discover_pip_sbom_package(sbom_data: dict[str, typing.Any]) -> None:
113114
automatable to discover the metadata we need like the version and checksums
114115
so let's do that on behalf of our friends at the PyPA.
115116
"""
116-
global PACKAGE_TO_FILES, CPYTHON_ROOT_DIR
117+
global PACKAGE_TO_FILES
117118

118119
ensurepip_bundled_dir = CPYTHON_ROOT_DIR / "Lib/ensurepip/_bundled"
119120
pip_wheels = []
@@ -124,7 +125,7 @@ def discover_pip_sbom_package(sbom_data: dict[str, typing.Any]) -> None:
124125
pip_wheels.append(wheel_filename)
125126
if len(pip_wheels) != 1:
126127
print("Zero or multiple pip wheels detected in 'Lib/ensurepip/_bundled'")
127-
exit(1)
128+
sys.exit(1)
128129
pip_wheel_filename = pip_wheels[0]
129130

130131
# Add the wheel filename to the list of files so the SBOM file
@@ -160,7 +161,7 @@ def discover_pip_sbom_package(sbom_data: dict[str, typing.Any]) -> None:
160161

161162
except (OSError, ValueError) as e:
162163
print(f"Couldn't fetch pip's metadata from PyPI: {e}")
163-
exit(1)
164+
sys.exit(1)
164165

165166
# Remove pip from the existing SBOM packages if it's there
166167
# and then overwrite its entry with our own generated one.

0 commit comments

Comments
 (0)