Skip to content

Commit

Permalink
drops mac support for now
Browse files Browse the repository at this point in the history
  • Loading branch information
r-zenine committed Mar 8, 2020
1 parent e736e78 commit b8c2efe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
14 changes: 2 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def get_extensions():
third_party_search_directories = []

runtime_library_dirs = None
if sys.platform.startswith('linux') or sys.platform.startswith('darwin'):
if sys.platform.startswith('linux'):
sources = sources + source_image_cpu
libraries.append('png')
third_party_search_directories.append(os.path.join(cwd, "third_party/libpng"))
Expand Down Expand Up @@ -222,7 +222,7 @@ def throw_of_failure(command):

def build_deps():
this_dir = os.path.dirname(os.path.abspath(__file__))
if sys.platform.startswith('linux') or sys.platform.startswith('darwin'):
if sys.platform.startswith('linux'):
cpu_count = multiprocessing.cpu_count()
os.chdir("third_party/zlib/")
throw_of_failure('cmake .')
Expand All @@ -232,8 +232,6 @@ def build_deps():
zlib_path = os.path.join(this_dir, "third_party/zlib")
if sys.platform.startswith("linux"):
libpng_cmake_options = "-DPNG_BUILD_ZLIB=ON -DPNG_STATIC=OFF -DZLIB_INCLUDE_DIR:PATH={zlib_path} -DZLIB_LIBRARY:FILEPATH={zlib_path}/libz.so".format(zlib_path=zlib_path)
if sys.platform.startswith("darwin"):
libpng_cmake_options = "-DPNG_BUILD_ZLIB=ON -DPNG_STATIC=OFF -DZLIB_INCLUDE_DIR:PATH={zlib_path} -DZLIB_LIBRARY:FILEPATH={zlib_path}/libz.dylib".format(zlib_path=zlib_path)
os.chdir("third_party/libpng/")
os.system('cmake {} .'.format(libpng_cmake_options))
throw_of_failure("cmake --build . -- -j {}".format(cpu_count))
Expand All @@ -253,14 +251,6 @@ def build_ext_with_dependencies(self):
'third_party/libpng/libpng.so'])
]

if sys.platform.startswith('darwin'):
data_files = [
('torchvision/lib', [
'third_party/zlib/libz.dylib',
'third_party/libpng/libpng.dylib'])
]


setup(
# Metadata
name=package_name,
Expand Down
6 changes: 3 additions & 3 deletions test/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import torch
from PIL import Image
if sys.platform.startswith('linux') or sys.platform.startswith("darwin"):
if sys.platform.startswith('linux'):
from torchvision.io.image import read_png, decode_png
import numpy as np

Expand All @@ -21,14 +21,14 @@ def get_images(directory, img_ext):


class ImageTester(unittest.TestCase):
@unittest.skipUnless(sys.platform.startswith("linux") or sys.platform.startswith("darwin"), "Support only available on linux for now.")
@unittest.skipUnless(sys.platform.startswith("linux"), "Support only available on linux for now.")
def test_read_png(self):
for img_path in get_images(IMAGE_DIR, ".png"):
img_pil = torch.from_numpy(np.array(Image.open(img_path)))
img_lpng = read_png(img_path)
self.assertTrue(torch.equal(img_lpng, img_pil))

@unittest.skipUnless(sys.platform.startswith("linux") or sys.platform.startswith("darwin"), "Support only available on linux for now.")
@unittest.skipUnless(sys.platform.startswith("linux"), "Support only available on linux for now.")
def test_decode_png(self):
for img_path in get_images(IMAGE_DIR, ".png"):
img_pil = torch.from_numpy(np.array(Image.open(img_path)))
Expand Down

0 comments on commit b8c2efe

Please sign in to comment.