Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
53670211
Unverified
Commit
53670211
authored
May 09, 2024
by
Nicolas Hug
Committed by
GitHub
May 09, 2024
Browse files
Remove include Python.h (#8413)
parent
e4d2d1ad
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
3 additions
and
50 deletions
+3
-50
CMakeLists.txt
CMakeLists.txt
+0
-10
cmake/TorchVisionConfig.cmake.in
cmake/TorchVisionConfig.cmake.in
+0
-8
examples/cpp/README.rst
examples/cpp/README.rst
+0
-3
setup.py
setup.py
+0
-4
torchvision/csrc/io/image/image.cpp
torchvision/csrc/io/image/image.cpp
+1
-7
torchvision/csrc/io/video_reader/video_reader.cpp
torchvision/csrc/io/video_reader/video_reader.cpp
+1
-8
torchvision/csrc/vision.cpp
torchvision/csrc/vision.cpp
+1
-10
No files found.
CMakeLists.txt
View file @
53670211
...
@@ -7,7 +7,6 @@ option(WITH_CUDA "Enable CUDA support" OFF)
...
@@ -7,7 +7,6 @@ option(WITH_CUDA "Enable CUDA support" OFF)
option
(
WITH_MPS
"Enable MPS support"
OFF
)
option
(
WITH_MPS
"Enable MPS support"
OFF
)
option
(
WITH_PNG
"Enable features requiring LibPNG."
ON
)
option
(
WITH_PNG
"Enable features requiring LibPNG."
ON
)
option
(
WITH_JPEG
"Enable features requiring LibJPEG."
ON
)
option
(
WITH_JPEG
"Enable features requiring LibJPEG."
ON
)
option
(
USE_PYTHON
"Link to Python when building"
OFF
)
if
(
WITH_CUDA
)
if
(
WITH_CUDA
)
enable_language
(
CUDA
)
enable_language
(
CUDA
)
...
@@ -33,11 +32,6 @@ if (WITH_JPEG)
...
@@ -33,11 +32,6 @@ if (WITH_JPEG)
find_package
(
JPEG REQUIRED
)
find_package
(
JPEG REQUIRED
)
endif
()
endif
()
if
(
USE_PYTHON
)
add_definitions
(
-DUSE_PYTHON
)
find_package
(
Python3 REQUIRED COMPONENTS Development
)
endif
()
function
(
CUDA_CONVERT_FLAGS EXISTING_TARGET
)
function
(
CUDA_CONVERT_FLAGS EXISTING_TARGET
)
get_property
(
old_flags TARGET
${
EXISTING_TARGET
}
PROPERTY INTERFACE_COMPILE_OPTIONS
)
get_property
(
old_flags TARGET
${
EXISTING_TARGET
}
PROPERTY INTERFACE_COMPILE_OPTIONS
)
if
(
NOT
"
${
old_flags
}
"
STREQUAL
""
)
if
(
NOT
"
${
old_flags
}
"
STREQUAL
""
)
...
@@ -110,10 +104,6 @@ if (WITH_JPEG)
...
@@ -110,10 +104,6 @@ if (WITH_JPEG)
target_link_libraries
(
${
PROJECT_NAME
}
PRIVATE
${
JPEG_LIBRARIES
}
)
target_link_libraries
(
${
PROJECT_NAME
}
PRIVATE
${
JPEG_LIBRARIES
}
)
endif
()
endif
()
if
(
USE_PYTHON
)
target_link_libraries
(
${
PROJECT_NAME
}
PRIVATE Python3::Python
)
endif
()
set_target_properties
(
${
PROJECT_NAME
}
PROPERTIES
set_target_properties
(
${
PROJECT_NAME
}
PROPERTIES
EXPORT_NAME TorchVision
EXPORT_NAME TorchVision
INSTALL_RPATH
${
TORCH_INSTALL_PREFIX
}
/lib
)
INSTALL_RPATH
${
TORCH_INSTALL_PREFIX
}
/lib
)
...
...
cmake/TorchVisionConfig.cmake.in
View file @
53670211
...
@@ -46,13 +46,5 @@ if(@WITH_JPEG@)
...
@@ -46,13 +46,5 @@ if(@WITH_JPEG@)
target_compile_definitions(${PN}::${PN} INTERFACE JPEG_FOUND)
target_compile_definitions(${PN}::${PN} INTERFACE JPEG_FOUND)
endif()
endif()
if (@USE_PYTHON@)
if(NOT TARGET Python3::Python)
find_package(Python3 COMPONENTS Development)
endif()
target_link_libraries(torch INTERFACE Python3::Python)
target_compile_definitions(${PN}::${PN} INTERFACE USE_PYTHON)
endif()
endif()
endif()
endif()
endif()
examples/cpp/README.rst
View file @
53670211
...
@@ -81,9 +81,6 @@ cmake --install .
...
@@ -81,9 +81,6 @@ cmake --install .
You may want to pass `-DCMAKE_INSTALL_PREFIX=/path/to/libtorchvision` for
You may want to pass `-DCMAKE_INSTALL_PREFIX=/path/to/libtorchvision` for
cmake to copy/install the files to a specific location (e.g. `$CONDA_PREFIX`).
cmake to copy/install the files to a specific location (e.g. `$CONDA_PREFIX`).
On Windows, you may also need to pass `-DUSE_PYTHON`. Refer to the corresponding
`CMakeLists.txt` for additional options.
**DISCLAIMER**: the `libtorchvision` library includes the torchvision
**DISCLAIMER**: the `libtorchvision` library includes the torchvision
custom ops as well as most of the C++ torchvision APIs. Those APIs do not come
custom ops as well as most of the C++ torchvision APIs. Those APIs do not come
with any backward-compatibility guarantees and may change from one version to
with any backward-compatibility guarantees and may change from one version to
...
...
setup.py
View file @
53670211
...
@@ -209,7 +209,6 @@ def get_extensions():
...
@@ -209,7 +209,6 @@ def get_extensions():
if
sys
.
platform
==
"win32"
:
if
sys
.
platform
==
"win32"
:
define_macros
+=
[(
"torchvision_EXPORTS"
,
None
)]
define_macros
+=
[(
"torchvision_EXPORTS"
,
None
)]
define_macros
+=
[(
"USE_PYTHON"
,
None
)]
extra_compile_args
[
"cxx"
].
append
(
"/MP"
)
extra_compile_args
[
"cxx"
].
append
(
"/MP"
)
if
debug_mode
:
if
debug_mode
:
...
@@ -254,9 +253,6 @@ def get_extensions():
...
@@ -254,9 +253,6 @@ def get_extensions():
image_library
=
[]
image_library
=
[]
image_link_flags
=
[]
image_link_flags
=
[]
if
sys
.
platform
==
"win32"
:
image_macros
+=
[(
"USE_PYTHON"
,
None
)]
# Locating libPNG
# Locating libPNG
libpng
=
shutil
.
which
(
"libpng-config"
)
libpng
=
shutil
.
which
(
"libpng-config"
)
pngfix
=
shutil
.
which
(
"pngfix"
)
pngfix
=
shutil
.
which
(
"pngfix"
)
...
...
torchvision/csrc/io/image/image.cpp
View file @
53670211
#include "image.h"
#include "image.h"
#include <ATen/core/op_registration/op_registration.h>
#include <ATen/core/op_registration/op_registration.h>
#ifdef USE_PYTHON
#include <Python.h>
#endif
// If we are in a Windows environment, we need to define
// If we are in a Windows environment, we need to define
// initialization functions for the _custom_ops extension
// initialization functions for the _custom_ops extension
#ifdef USE_PYTHON
#ifdef _WIN32
#ifdef _WIN32
PyMODINIT_FUNC
PyInit_image
(
void
)
{
void
*
PyInit_image
(
void
)
{
// No need to do anything.
return
nullptr
;
return
nullptr
;
}
}
#endif
#endif
#endif // USE_PYTHON
namespace
vision
{
namespace
vision
{
namespace
image
{
namespace
image
{
...
...
torchvision/csrc/io/video_reader/video_reader.cpp
View file @
53670211
#include "video_reader.h"
#include "video_reader.h"
#ifdef USE_PYTHON
#include <Python.h>
#endif
#include "../decoder/memory_buffer.h"
#include "../decoder/memory_buffer.h"
#include "../decoder/sync_decoder.h"
#include "../decoder/sync_decoder.h"
#ifdef USE_PYTHON
// If we are in a Windows environment, we need to define
// If we are in a Windows environment, we need to define
// initialization functions for the _custom_ops extension
// initialization functions for the _custom_ops extension
#ifdef _WIN32
#ifdef _WIN32
PyMODINIT_FUNC
PyInit_video_reader
(
void
)
{
void
*
PyInit_video_reader
(
void
)
{
// No need to do anything.
return
nullptr
;
return
nullptr
;
}
}
#endif
#endif
#endif // USE_PYTHONs
using
namespace
ffmpeg
;
using
namespace
ffmpeg
;
...
...
torchvision/csrc/vision.cpp
View file @
53670211
#include "vision.h"
#include "vision.h"
#ifndef MOBILE
#ifdef USE_PYTHON
#include <Python.h>
#endif
#endif
#include <torch/library.h>
#include <torch/library.h>
#ifdef WITH_CUDA
#ifdef WITH_CUDA
...
@@ -16,14 +11,10 @@
...
@@ -16,14 +11,10 @@
// If we are in a Windows environment, we need to define
// If we are in a Windows environment, we need to define
// initialization functions for the _custom_ops extension.
// initialization functions for the _custom_ops extension.
// For PyMODINIT_FUNC to work, we need to include Python.h
#if !defined(MOBILE) && defined(_WIN32)
#if !defined(MOBILE) && defined(_WIN32)
#ifdef USE_PYTHON
void
*
PyInit__C
(
void
)
{
PyMODINIT_FUNC
PyInit__C
(
void
)
{
// No need to do anything.
return
nullptr
;
return
nullptr
;
}
}
#endif // USE_PYTHON
#endif // !defined(MOBILE) && defined(_WIN32)
#endif // !defined(MOBILE) && defined(_WIN32)
namespace
vision
{
namespace
vision
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment