Skip to content

Commit

Permalink
ugly hack
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasHug committed Jul 17, 2024
1 parent 8e323d1 commit 562630f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
5 changes: 2 additions & 3 deletions packaging/pre_build_script.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/bin/bash

conda install libwebp -y
conda uninstall libjpeg-turbo -y

if [[ "$(uname)" == Darwin ]]; then
# Uninstall Conflicting jpeg brew formulae
jpeg_packages=$(brew list | grep jpeg)
Expand Down Expand Up @@ -33,6 +30,8 @@ else
conda install -yq ffmpeg=4.2 libjpeg-turbo -c pytorch-nightly
fi

conda install libwebp -y

# Install native CentOS libJPEG, freetype and GnuTLS
yum install -y libjpeg-turbo-devel freetype gnutls

Expand Down
15 changes: 10 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ def find_library(header):
searching_for = f"Searching for {header}"

for folder in TORCHVISION_INCLUDE:
if "jpeg" in header:
continue
if (Path(folder) / header).exists():
print(f"{searching_for} in {Path(folder) / header}. Found in TORCHVISION_INCLUDE.")
return True, None, None
Expand All @@ -241,6 +243,8 @@ def find_library(header):
# Try conda-related prefixes. If BUILD_PREFIX is set it means conda-build is
# being run. If CONDA_PREFIX is set then we're in a conda environment.
for prefix_env_var in ("BUILD_PREFIX", "CONDA_PREFIX"):
if "jpeg" in header:
continue
if (prefix := os.environ.get(prefix_env_var)) is not None:
prefix = Path(prefix)
if sys.platform == "win32":
Expand All @@ -253,11 +257,12 @@ def find_library(header):
print(f"{searching_for}. Didn't find in {prefix_env_var}.")

if sys.platform == "linux":
prefixes = ("/usr/include", "/usr/local/include")
if any((Path(prefix) / header).exists() for prefix in prefixes):
print(f"{searching_for}. Found in {prefixes}.")
return True, None, None
print(f"{searching_for}. Didn't find in {prefixes}.")
for prefix in ("/usr/include", "/usr/local/include"):
prefix = Path(prefix)
if (prefix / header).exists():
print(f"{searching_for}. Found in {prefix}.")
return True, None, None
print(f"{searching_for}. Didn't find in {prefix}")

return False, None, None

Expand Down

0 comments on commit 562630f

Please sign in to comment.