Skip to content

Commit 1041e79

Browse files
authored
More debugging info to setup.py (#8535)
1 parent 3663024 commit 1041e79

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

setup.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ def get_macros_and_flags():
139139

140140

141141
def make_C_extension():
142+
print("Building _C extension")
142143

143144
sources = (
144145
list(CSRS_DIR.glob("*.cpp"))
@@ -221,18 +222,17 @@ def find_libpng():
221222
return True, include_dir, library_dir, library
222223

223224

224-
def find_libjpeg():
225+
def find_library(header):
225226
# returns (found, include dir, library dir)
226227
# if include dir or library dir is None, it means that the library is in
227228
# standard paths and don't need to be added to compiler / linker search
228229
# paths
229230

230-
library_header = "jpeglib.h"
231-
searching_for = f"Searching for {library_header}"
231+
searching_for = f"Searching for {header}"
232232

233233
for folder in TORCHVISION_INCLUDE:
234-
if (Path(folder) / library_header).exists():
235-
print(f"{searching_for}. Found in TORCHVISION_INCLUDE.")
234+
if (Path(folder) / header).exists():
235+
print(f"{searching_for} in {Path(folder) / header}. Found in TORCHVISION_INCLUDE.")
236236
return True, None, None
237237
print(f"{searching_for}. Didn't find in TORCHVISION_INCLUDE.")
238238

@@ -245,22 +245,23 @@ def find_libjpeg():
245245
prefix = prefix / "Library"
246246
include_dir = prefix / "include"
247247
library_dir = prefix / "lib"
248-
if (include_dir / library_header).exists():
248+
if (include_dir / header).exists():
249249
print(f"{searching_for}. Found in {prefix_env_var}.")
250250
return True, str(include_dir), str(library_dir)
251251
print(f"{searching_for}. Didn't find in {prefix_env_var}.")
252252

253253
if sys.platform == "linux":
254-
prefixes = ("/usr/include", "/usr/local/include")
255-
if any((Path(prefix) / library_header).exists() for prefix in prefixes):
256-
print(f"{searching_for}. Found in {prefixes}.")
257-
return True, None, None
258-
print(f"{searching_for}. Didn't find in {prefixes}.")
254+
for prefix in (Path("/usr/include"), Path("/usr/local/include")):
255+
if (prefix / header).exists():
256+
print(f"{searching_for}. Found in {prefix}.")
257+
return True, None, None
258+
print(f"{searching_for}. Didn't find in {prefix}")
259259

260260
return False, None, None
261261

262262

263263
def make_image_extension():
264+
print("Building image extension")
264265

265266
include_dirs = TORCHVISION_INCLUDE.copy()
266267
library_dirs = TORCHVISION_LIBRARY.copy()
@@ -294,7 +295,7 @@ def make_image_extension():
294295
warnings.warn("Building torchvision without PNG support")
295296

296297
if USE_JPEG:
297-
jpeg_found, jpeg_include_dir, jpeg_library_dir = find_libjpeg()
298+
jpeg_found, jpeg_include_dir, jpeg_library_dir = find_library(header="jpeglib.h")
298299
if jpeg_found:
299300
print("Building torchvision with JPEG support")
300301
print(f"{jpeg_include_dir = }")
@@ -331,6 +332,8 @@ def make_image_extension():
331332

332333

333334
def make_video_decoders_extensions():
335+
print("Building video decoder extensions")
336+
334337
# Locating ffmpeg
335338
ffmpeg_exe = shutil.which("ffmpeg")
336339
has_ffmpeg = ffmpeg_exe is not None

0 commit comments

Comments
 (0)