Skip to content

Commit

Permalink
chore: add some fail-safe checks (#2764)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelotduarte authored Jan 2, 2025
1 parent 3f7815f commit 3a655f5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
13 changes: 7 additions & 6 deletions cx_Freeze/hooks/_qthooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,12 +395,13 @@ def load_qt_qtwebenginecore(finder: ModuleFinder, module: Module) -> None:
if environment == "conda": # conda-forge Linux and macOS
prefix = Path(sys.prefix)
conda_meta = prefix / "conda-meta"
pkg = next(conda_meta.glob("nss-*.json"))
files = json.loads(pkg.read_text(encoding="utf_8"))["files"]
for file in files:
source = prefix / file
if source.match("lib*.so") or source.match("lib*.dylib"):
finder.include_files(source, f"lib/{source.name}")
pkg = next(conda_meta.glob("nss-*.json"), None)
if pkg is not None:
files = json.loads(pkg.read_text(encoding="utf_8"))["files"]
for file in files:
source = prefix / file
if source.match("lib*.so") or source.match("lib*.dylib"):
finder.include_files(source, f"lib/{source.name}")
else:
copy_qt_files(finder, name, "LibraryExecutablesPath", "libnss*.*")

Expand Down
5 changes: 2 additions & 3 deletions cx_Freeze/hooks/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,8 @@ def load_numpy__distributor_init(finder: ModuleFinder, module: Module) -> None:
blas_options = ["libopenblas", "mkl"]
packages += blas_options
for package in packages:
try:
pkg = next(conda_meta.glob(f"{package}-*.json"))
except StopIteration:
pkg = next(conda_meta.glob(f"{package}-*.json"), None)
if pkg is None:
continue
files = json.loads(pkg.read_text(encoding="utf_8"))["files"]
# copy mkl/blas files to lib (issue #2574)
Expand Down
7 changes: 2 additions & 5 deletions cx_Freeze/hooks/tkinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@ def load_tkinter(finder: ModuleFinder, module: Module) -> None:
and lib_dynload_tkinter
and lib_dynload_tkinter.exists()
):
try:
tcl_library = next(share.glob("tcl*.*"))
tk_library = next(share.glob("tk*.*"))
except StopIteration:
pass
tcl_library = next(share.glob("tcl*.*"), None)
tk_library = next(share.glob("tk*.*"), None)
if tcl_library is None:
# search for the tcl/tk libraries (Windows, MSYS2, conda-forge, etc)
try:
Expand Down
9 changes: 6 additions & 3 deletions tests/test_command_bdist_deb.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ def test_bdist_deb_simple(datafiles: Path) -> None:
pytest.fail(process.stderr)

pattern = f"{name}_{version}-?_*.deb"
file_created = next(dist_created.glob(pattern))
file_created = next(dist_created.glob(pattern), None)
assert file_created, pattern
assert file_created.is_file(), pattern


Expand Down Expand Up @@ -128,7 +129,8 @@ def test_bdist_deb_simple_pyproject(datafiles: Path) -> None:
pytest.fail(process.stderr)

pattern = f"{name}_{version}-?_*.deb"
file_created = next(dist_created.glob(pattern))
file_created = next(dist_created.glob(pattern), None)
assert file_created, pattern
assert file_created.is_file(), pattern


Expand Down Expand Up @@ -156,5 +158,6 @@ def test_bdist_deb(datafiles: Path) -> None:
pytest.fail(process.stderr)

pattern = f"{name.replace('_', '-')}_{version}-?_*.deb"
file_created = next(dist_created.glob(pattern))
file_created = next(dist_created.glob(pattern), None)
assert file_created, pattern
assert file_created.is_file(), pattern

0 comments on commit 3a655f5

Please sign in to comment.