Skip to content

Commit 89bc44f

Browse files
0phofffacebook-github-bot
authored andcommitted
Add pillow-simd as requirement if it is installed (#368)
Summary: As discussed in #367, this PR allows visdom to work with Pillow-simd if the end user has it installed. What this PR does, is that upon installation it checks if pillow-simd is installed and adds it to the requirements if it is. Otherwise, regular pillow is added. Pillow-simd is a drop-in replacement that uses the same namespace, so no further changes are required. __Disclaimer:__ I did not figure this one out on my own, but saw this solution in [pytorch/vision](pytorch/vision#522). This solution might have some problems I am not aware of, as I am no guru when working with setuptools. One thing I do know, is that this will cause a problem when creating pip wheels, so that should be taken into consideration. _(I dont think that this is a concern for this project)_ Closes #368 Differential Revision: D8314365 Pulled By: JackUrb fbshipit-source-id: 9cc52eee5ad129263136a7d6c6cfa86e288e89eb
1 parent ba3e444 commit 89bc44f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

setup.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
import os
22
from setuptools import setup
3+
from pkg_resources import get_distribution, DistributionNotFound
4+
5+
6+
def get_dist(pkgname):
7+
try:
8+
return get_distribution(pkgname)
9+
except DistributionNotFound:
10+
return None
11+
312

413
here = os.path.abspath(os.path.dirname(__file__))
514

@@ -11,14 +20,15 @@
1120
requirements = [
1221
'numpy>=1.8',
1322
'scipy',
14-
'pillow',
1523
'requests',
1624
'tornado',
1725
'pyzmq',
1826
'six',
1927
'torchfile',
2028
'websocket-client',
2129
]
30+
pillow_req = 'pillow-simd' if get_dist('pillow-simd') is not None else 'pillow'
31+
requirements.append(pillow_req)
2232

2333
setup(
2434
# Metadata

0 commit comments

Comments
 (0)