Skip to content

Commit 5a0d079

Browse files
ngimelsoumith
authored andcommitted
make vision depend on pillow-simd if already installed (#522)
* make vision depend on pillow-simd if already installed * actually make pillow-simd optional
1 parent da67a1e commit 5a0d079

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

setup.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import shutil
66
import sys
77
from setuptools import setup, find_packages
8+
from pkg_resources import get_distribution, DistributionNotFound
89

910

1011
def read(*names, **kwargs):
@@ -15,6 +16,13 @@ def read(*names, **kwargs):
1516
return fp.read()
1617

1718

19+
def get_dist(pkgname):
20+
try:
21+
return get_distribution(pkgname)
22+
except DistributionNotFound:
23+
return None
24+
25+
1826
def find_version(*file_paths):
1927
version_file = read(*file_paths)
2028
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
@@ -30,12 +38,15 @@ def find_version(*file_paths):
3038

3139
requirements = [
3240
'numpy',
33-
'pillow >= 4.1.1',
3441
'six',
3542
'torch',
3643
'tqdm'
3744
]
3845

46+
pillow_ver = ' >= 4.1.1'
47+
pillow_req = 'pillow-simd' if get_dist('pillow-simd') is not None else 'pillow'
48+
requirements.append(pillow_req + pillow_ver)
49+
3950
setup(
4051
# Metadata
4152
name='torchvision',

0 commit comments

Comments
 (0)