Skip to content

Commit fa6af6d

Browse files
authored
Revert "PR: Add libpng and libjpeg-turbo requirement into conda recipe (#2301)" (#2375)
This reverts commit 766721b.
1 parent d24008c commit fa6af6d

19 files changed

+11
-563
lines changed

.circleci/config.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ jobs:
107107
- checkout
108108
- run:
109109
command: |
110-
sudo apt-get update -y
111-
sudo apt install -y libturbojpeg-dev
112110
pip install --user --progress-bar off numpy mypy
113111
pip install --user --progress-bar off --pre torch -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
114112
pip install --user --progress-bar off --editable .

.circleci/config.yml.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ jobs:
107107
- checkout
108108
- run:
109109
command: |
110-
sudo apt-get update -y
111-
sudo apt install -y libturbojpeg-dev
112110
pip install --user --progress-bar off numpy mypy
113111
pip install --user --progress-bar off --pre torch -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
114112
pip install --user --progress-bar off --editable .

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ jobs:
1313

1414
before_install:
1515
- sudo apt-get update
16-
- sudo apt-get install -y libpng-dev libturbojpeg-dev
1716
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
1817
- bash miniconda.sh -b -p $HOME/miniconda
1918
- export PATH="$HOME/miniconda/bin:$PATH"

CMakeLists.txt

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,22 @@ if(WITH_CUDA)
1111
endif()
1212

1313
find_package(Python3 COMPONENTS Development)
14-
1514
find_package(Torch REQUIRED)
16-
find_package(PNG REQUIRED)
17-
1815

1916
file(GLOB HEADERS torchvision/csrc/*.h)
20-
file(GLOB IMAGE_HEADERS torchvision/csrc/cpu/image/*.h)
21-
file(GLOB IMAGE_SOURCES torchvision/csrc/cpu/image/*.cpp)
22-
file(GLOB OPERATOR_SOURCES torchvision/csrc/cpu/*.h torchvision/csrc/cpu/*.cpp ${IMAGE_HEADERS} ${IMAGE_SOURCES} ${HEADERS} torchvision/csrc/*.cpp)
17+
file(GLOB OPERATOR_SOURCES torchvision/csrc/cpu/*.h torchvision/csrc/cpu/*.cpp torchvision/csrc/*.cpp)
2318
if(WITH_CUDA)
2419
file(GLOB OPERATOR_SOURCES ${OPERATOR_SOURCES} torchvision/csrc/cuda/*.h torchvision/csrc/cuda/*.cu)
2520
endif()
2621
file(GLOB MODELS_HEADERS torchvision/csrc/models/*.h)
2722
file(GLOB MODELS_SOURCES torchvision/csrc/models/*.h torchvision/csrc/models/*.cpp)
2823

29-
add_library(${PROJECT_NAME} SHARED ${MODELS_SOURCES} ${OPERATOR_SOURCES} ${IMAGE_SOURCES})
30-
target_link_libraries(${PROJECT_NAME} PRIVATE ${TORCH_LIBRARIES} ${PNG_LIBRARY} Python3::Python)
31-
# target_link_libraries(${PROJECT_NAME} PRIVATE ${PNG_LIBRARY} Python3::Python)
24+
add_library(${PROJECT_NAME} SHARED ${MODELS_SOURCES} ${OPERATOR_SOURCES})
25+
target_link_libraries(${PROJECT_NAME} PRIVATE ${TORCH_LIBRARIES} Python3::Python)
3226
set_target_properties(${PROJECT_NAME} PROPERTIES EXPORT_NAME TorchVision)
3327

3428
target_include_directories(${PROJECT_NAME} INTERFACE
35-
$<BUILD_INTERFACE:${HEADERS}:${PNG_INCLUDE_DIR}>
29+
$<BUILD_INTERFACE:${HEADERS}>
3630
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
3731

3832
include(GNUInstallDirs)
@@ -67,7 +61,7 @@ install(FILES
6761
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/cpu)
6862
if(WITH_CUDA)
6963
install(FILES
70-
torchvision/csrc/cuda/vision_cuda.h
64+
torchvision/csrc/cuda/vision_cuda.h
7165
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/cuda)
7266
endif()
7367
install(FILES ${MODELS_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/models)

README.rst

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,13 @@ Torchvision currently supports the following image backends:
7878

7979
* `accimage`_ - if installed can be activated by calling :code:`torchvision.set_image_backend('accimage')`
8080

81-
* `libpng`_ - can be installed via conda :code:`conda install libpng` or any of the package managers for debian-based and RHEL-based Linux distributions.
82-
83-
* `libturbojpeg`_ - blazing speed, fast JPEG image loading. Can be installed from conda-forge :code:`conda install libjpeg-turbo -c conda-forge`.
84-
85-
**Notes:** ``libpng`` and ``libturbojpeg`` must be available at compilation time in order to be available. Also, most linux distributions distinguish between
86-
``libturbojpeg`` and ``libjpeg-turbo``, where the former should be installed instead of the latter one.
87-
88-
.. _libpng : http://www.libpng.org/pub/png/libpng.html
89-
.. _libturbojpeg: https://github.com/libjpeg-turbo/libjpeg-turbo
9081
.. _Pillow : https://python-pillow.org/
9182
.. _Pillow-SIMD : https://github.com/uploadcare/pillow-simd
9283
.. _accimage: https://github.com/pytorch/accimage
9384

9485
C++ API
9586
=======
96-
TorchVision also offers a C++ API that contains C++ equivalent of python models.
87+
TorchVision also offers a C++ API that contains C++ equivalent of python models.
9788

9889
Installation From source:
9990

@@ -103,7 +94,7 @@ Installation From source:
10394
cd build
10495
# Add -DWITH_CUDA=on support for the CUDA if needed
10596
cmake ..
106-
make
97+
make
10798
make install
10899
109100
Once installed, the library can be accessed in cmake (after properly configuring ``CMAKE_PREFIX_PATH``) via the :code:`TorchVision::TorchVision` target:

packaging/build_wheel.sh

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,6 @@ setup_wheel_python
1010
pip_install numpy pyyaml future ninja
1111
setup_pip_pytorch_version
1212
python setup.py clean
13-
14-
# Copy binaries to be included in the wheel distribution
15-
if [[ "$(uname)" == Darwin || "$OSTYPE" == "msys" ]]; then
16-
python_exec="$(which python)"
17-
bin_path=$(dirname $python_exec)
18-
env_path=$(dirname $bin_path)
19-
if [[ "$(uname)" == Darwin ]]; then
20-
# Include LibPNG
21-
cp "$env_path/lib/libpng16.dylib" torchvision
22-
# Include TurboJPEG
23-
cp "$env_path/lib/libturbojpeg.dylib" torchvision
24-
else
25-
# Include libPNG
26-
cp "$bin_path/Library/lib/libpng.lib" torchvision
27-
# Include TurboJPEG
28-
cp "$bin_path/Library/lib/turbojpeg.lib" torchvision
29-
fi
30-
else
31-
# Include LibPNG
32-
cp "/usr/lib64/libpng.so" torchvision
33-
# Include TurboJPEG
34-
cp "/usr/lib64/libturbojpeg.so" torchvision
35-
fi
36-
3713
if [[ "$OSTYPE" == "msys" ]]; then
3814
IS_WHEEL=1 "$script_dir/windows/internal/vc_env_helper.bat" python setup.py bdist_wheel
3915
else

packaging/pkg_helpers.bash

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,7 @@ setup_wheel_python() {
170170
conda env remove -n "env$PYTHON_VERSION" || true
171171
conda create -yn "env$PYTHON_VERSION" python="$PYTHON_VERSION"
172172
conda activate "env$PYTHON_VERSION"
173-
# Install libPNG from Anaconda (defaults)
174-
conda install libpng -y
175-
# Install libJPEG-turbo from conda-forge
176-
conda install -y libjpeg-turbo -c conda-forge
177173
else
178-
# Install native CentOS libPNG, libJPEG-turbo
179-
yum install -y libpng-devel turbojpeg-devel
180174
case "$PYTHON_VERSION" in
181175
2.7)
182176
if [[ -n "$UNICODE_ABI" ]]; then

packaging/torchvision/conda_build_config.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
channel_sources:
2-
- defaults,conda-forge
3-
41
blas_impl:
52
- mkl # [x86_64]
63
c_compiler:

packaging/torchvision/meta.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ source:
88
requirements:
99
build:
1010
- {{ compiler('c') }} # [win]
11-
- libpng
12-
- libjpeg-turbo
1311

1412
host:
1513
- python
@@ -20,10 +18,6 @@ requirements:
2018

2119
run:
2220
- python
23-
- libpng
24-
- libjpeg-turbo
25-
# Pillow introduces unwanted conflicts with libjpeg-turbo, as it depends on jpeg
26-
# The fix depends on https://github.com/conda-forge/conda-forge.github.io/issues/673
2721
- pillow >=4.1.1
2822
- numpy >=1.11
2923
{{ environ.get('CONDA_PYTORCH_CONSTRAINT') }}

setup.py

Lines changed: 3 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import re
44
import sys
55
from setuptools import setup, find_packages
6-
from pkg_resources import parse_version, get_distribution, DistributionNotFound
6+
from pkg_resources import get_distribution, DistributionNotFound
77
import subprocess
88
import distutils.command.clean
99
import distutils.spawn
@@ -76,76 +76,7 @@ def write_version_file():
7676
requirements.append(pillow_req + pillow_ver)
7777

7878

79-
def find_library(name, vision_include):
80-
this_dir = os.path.dirname(os.path.abspath(__file__))
81-
build_prefix = os.environ.get('BUILD_PREFIX', None)
82-
is_conda_build = build_prefix is not None
83-
84-
library_found = False
85-
conda_installed = False
86-
lib_folder = None
87-
include_folder = None
88-
library_header = '{0}.h'.format(name)
89-
90-
print('Running build on conda-build: {0}'.format(is_conda_build))
91-
if is_conda_build:
92-
# Add conda headers/libraries
93-
if os.name == 'nt':
94-
build_prefix = os.path.join(build_prefix, 'Library')
95-
include_folder = os.path.join(build_prefix, 'include')
96-
lib_folder = os.path.join(build_prefix, 'lib')
97-
library_header_path = os.path.join(
98-
include_folder, library_header)
99-
library_found = os.path.isfile(library_header_path)
100-
conda_installed = library_found
101-
else:
102-
# Check if using Anaconda to produce wheels
103-
conda = distutils.spawn.find_executable('conda')
104-
is_conda = conda is not None
105-
print('Running build on conda: {0}'.format(is_conda))
106-
if is_conda:
107-
python_executable = sys.executable
108-
py_folder = os.path.dirname(python_executable)
109-
if os.name == 'nt':
110-
env_path = os.path.join(py_folder, 'Library')
111-
else:
112-
env_path = os.path.dirname(py_folder)
113-
lib_folder = os.path.join(env_path, 'lib')
114-
include_folder = os.path.join(env_path, 'include')
115-
library_header_path = os.path.join(
116-
include_folder, library_header)
117-
library_found = os.path.isfile(library_header_path)
118-
conda_installed = library_found
119-
120-
# Try to locate turbojpeg in Linux standard paths
121-
if not library_found:
122-
if sys.platform == 'linux':
123-
library_found = os.path.exists('/usr/include/{0}'.format(
124-
library_header))
125-
library_found = library_found or os.path.exists(
126-
'/usr/local/include/{0}'.format(library_header))
127-
else:
128-
# Lookup in TORCHVISION_INCLUDE or in the package file
129-
package_path = [os.path.join(this_dir, 'torchvision')]
130-
for folder in vision_include + package_path:
131-
candidate_path = os.path.join(folder, library_header)
132-
library_found = os.path.exists(candidate_path)
133-
if library_found:
134-
break
135-
136-
return library_found, conda_installed, include_folder, lib_folder
137-
138-
13979
def get_extensions():
140-
vision_include = os.environ.get('TORCHVISION_INCLUDE', None)
141-
vision_library = os.environ.get('TORCHVISION_LIBRARY', None)
142-
vision_include = (vision_include.split(os.pathsep)
143-
if vision_include is not None else [])
144-
vision_library = (vision_library.split(os.pathsep)
145-
if vision_library is not None else [])
146-
include_dirs = vision_include
147-
library_dirs = vision_library
148-
14980
this_dir = os.path.dirname(os.path.abspath(__file__))
15081
extensions_dir = os.path.join(this_dir, 'torchvision', 'csrc')
15182

@@ -218,14 +149,13 @@ def get_extensions():
218149

219150
sources = [os.path.join(extensions_dir, s) for s in sources]
220151

221-
include_dirs += [extensions_dir]
152+
include_dirs = [extensions_dir]
222153

223154
ext_modules = [
224155
extension(
225156
'torchvision._C',
226157
sources,
227158
include_dirs=include_dirs,
228-
library_dirs=library_dirs,
229159
define_macros=define_macros,
230160
extra_compile_args=extra_compile_args,
231161
)
@@ -241,65 +171,6 @@ def get_extensions():
241171
)
242172
)
243173

244-
# Image reading extension
245-
image_macros = []
246-
image_include = [extensions_dir]
247-
image_library = []
248-
image_link_flags = []
249-
250-
# Locating libPNG
251-
libpng = distutils.spawn.find_executable('libpng-config')
252-
png_found = libpng is not None
253-
image_macros += [('PNG_FOUND', str(int(png_found)))]
254-
print('PNG found: {0}'.format(png_found))
255-
if png_found:
256-
png_version = subprocess.run([libpng, '--version'],
257-
stdout=subprocess.PIPE)
258-
png_version = png_version.stdout.strip().decode('utf-8')
259-
print('libpng version: {0}'.format(png_version))
260-
png_version = parse_version(png_version)
261-
if png_version >= parse_version("1.6.0"):
262-
print('Building torchvision with PNG image support')
263-
png_lib = subprocess.run([libpng, '--libdir'],
264-
stdout=subprocess.PIPE)
265-
png_include = subprocess.run([libpng, '--I_opts'],
266-
stdout=subprocess.PIPE)
267-
image_library += [png_lib.stdout.strip().decode('utf-8')]
268-
image_include += [png_include.stdout.strip().decode('utf-8')]
269-
image_link_flags.append('png' if os.name != 'nt' else 'libpng')
270-
else:
271-
print('libpng installed version is less than 1.6.0, '
272-
'disabling PNG support')
273-
png_found = False
274-
275-
# Locating libjpegturbo
276-
turbojpeg_info = find_library('turbojpeg', vision_include)
277-
(turbojpeg_found, conda_installed,
278-
turbo_include_folder, turbo_lib_folder) = turbojpeg_info
279-
280-
image_macros += [('JPEG_FOUND', str(int(turbojpeg_found)))]
281-
print('turboJPEG found: {0}'.format(turbojpeg_found))
282-
if turbojpeg_found:
283-
print('Building torchvision with JPEG image support')
284-
image_link_flags.append('turbojpeg')
285-
if conda_installed:
286-
image_library += [turbo_lib_folder]
287-
image_include += [turbo_include_folder]
288-
289-
image_path = os.path.join(extensions_dir, 'cpu', 'image')
290-
image_src = glob.glob(os.path.join(image_path, '*.cpp'))
291-
292-
if png_found or turbojpeg_found:
293-
ext_modules.append(extension(
294-
'torchvision.image',
295-
image_src,
296-
include_dirs=include_dirs + [image_path] + image_include,
297-
library_dirs=library_dirs + image_library,
298-
define_macros=image_macros,
299-
libraries=image_link_flags,
300-
extra_compile_args=extra_compile_args
301-
))
302-
303174
ffmpeg_exe = distutils.spawn.find_executable('ffmpeg')
304175
has_ffmpeg = ffmpeg_exe is not None
305176

@@ -372,9 +243,7 @@ def run(self):
372243

373244
# Package info
374245
packages=find_packages(exclude=('test',)),
375-
package_data={
376-
package_name: ['*.lib', '*.dylib', '*.so']
377-
},
246+
378247
zip_safe=False,
379248
install_requires=requirements,
380249
extras_require={

0 commit comments

Comments
 (0)