python-torch{,vision}: Disabled

python-torch does not build against Python 3.11.

python-torchvision depends on python-torch.
This commit is contained in:
termux-pacman-bot
2022-10-30 08:42:27 +00:00
parent ee250bf9ec
commit 4784509bfe
7 changed files with 0 additions and 370 deletions

View File

@@ -1,12 +0,0 @@
diff -uNr pytorch/c10/macros/Macros.h pytorch.mod/c10/macros/Macros.h
--- pytorch/c10/macros/Macros.h 2022-10-04 19:55:33.000000000 +0900
+++ pytorch.mod/c10/macros/Macros.h 2022-10-04 23:41:33.513647184 +0900
@@ -390,7 +390,7 @@
#include <TargetConditionals.h>
#endif
-#if defined(__ANDROID__)
+#if defined(__ANDROID__) && !defined(__TERMUX__)
#define C10_ANDROID 1
#define C10_MOBILE 1
#elif ( \

View File

@@ -1,98 +0,0 @@
TERMUX_PKG_HOMEPAGE=https://pytorch.org/
TERMUX_PKG_DESCRIPTION="Tensors and Dynamic neural networks in Python"
TERMUX_PKG_LICENSE="BSD 3-Clause"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=1.12.1
TERMUX_PKG_REVISION=1
TERMUX_PKG_SRCURL=https://github.com/pytorch/pytorch.git
TERMUX_PKG_DEPENDS="python, python-numpy, libopenblas, libprotobuf, libzmq, ffmpeg, opencv"
TERMUX_PKG_HOSTBUILD=true
TERMUX_PKG_RM_AFTER_INSTALL="lib/pkgconfig/sleef.pc"
termux_step_post_get_source() {
termux_setup_cmake
}
termux_step_host_build() {
cmake "$TERMUX_PKG_SRCDIR/third_party/sleef"
make -j "$TERMUX_MAKE_PROCESSES" mkrename mkrename_gnuabi mkmasked_gnuabi mkalias mkdisp
}
termux_step_pre_configure() {
_PYTHON_VERSION=$(. $TERMUX_SCRIPTDIR/packages/python/build.sh; echo $_MAJOR_VERSION)
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
termux_setup_python_crossenv
pushd $TERMUX_PYTHON_CROSSENV_SRCDIR
_CROSSENV_PREFIX=$TERMUX_PKG_BUILDDIR/python-crossenv-prefix
python${_PYTHON_VERSION} -m crossenv \
$TERMUX_PREFIX/bin/python${_PYTHON_VERSION} \
${_CROSSENV_PREFIX}
popd
. ${_CROSSENV_PREFIX}/bin/activate
build-pip install -U wheel pyyaml numpy typing_extensions
fi
pip install -U typing_extensions
termux_setup_protobuf
find "$TERMUX_PKG_SRCDIR" -name CMakeLists.txt -o -name '*.cmake' | \
xargs -n 1 sed -i \
-e 's/\([^A-Za-z0-9_]ANDROID\)\([^A-Za-z0-9_]\)/\1_NO_TERMUX\2/g' \
-e 's/\([^A-Za-z0-9_]ANDROID\)$/\1_NO_TERMUX/g'
LDFLAGS+=" -llog -lpython${_PYTHON_VERSION}"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
-DBUILD_PYTHON=ON
-DBUILD_TEST=OFF
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=${TERMUX_PKG_SRCDIR}/torch
-DCMAKE_PREFIX_PATH=${TERMUX_PREFIX}/lib/python${_PYTHON_VERSION}/site-packages
-DNUMPY_INCLUDE_DIR=${TERMUX_PREFIX}/lib/python${_PYTHON_VERSION}/site-packages/numpy/core/include
-DPYTHON_EXECUTABLE=$(command -v python3)
-DPYTHON_INCLUDE_DIR=${TERMUX_PREFIX}/include/python${_PYTHON_VERSION}
-DPYTHON_LIBRARY=${TERMUX_PREFIX}/lib//libpython${_PYTHON_VERSION}.so
-DTORCH_BUILD_VERSION=${TERMUX_PKG_VERSION}
-DUSE_NUMPY=ON
-DUSE_OPENCV=ON
-DUSE_FFMPEG=ON
-DUSE_ZMQ=ON
-DANDROID_NO_TERMUX=OFF
-DOpenBLAS_INCLUDE_DIR=${TERMUX_PREFIX}/include/openblas
-DNATIVE_BUILD_DIR=${TERMUX_PKG_HOSTBUILD_DIR}
-DBUILD_CUSTOM_PROTOBUF=OFF
-DPROTOBUF_PROTOC_EXECUTABLE=$(command -v protoc)
-DCAFFE2_CUSTOM_PROTOC_EXECUTABLE=$(command -v protoc)
-DCXX_AVX512_FOUND=OFF
-DCXX_AVX2_FOUND=OFF
"
# to build x86_64 version anyway
# /home/builder/.termux-build/python-torch/src/third_party/fbgemm/third_party/asmjit/src/asmjit/core/../core/operand.h:910:79: error: use of bitwise '&' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+="
-DCAFFE2_COMPILER_SUPPORTS_AVX512_EXTENSIONS=OFF
"
# /home/builder/.termux-build/python-torch/src/torch/csrc/jit/codegen/onednn/graph_helper.h:3:10: fatal error: 'oneapi/dnnl/dnnl_graph.hpp' file not found
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+="
-DUSE_MKLDNN=OFF
"
# /home/builder/.termux-build/_cache/android-r25b-api-24-v0/sysroot/usr/include/linux/types.h:21:10: fatal error: 'asm/types.h' file not found
ln -s ${TERMUX_STANDALONE_TOOLCHAIN}/sysroot/usr/include/${TERMUX_ARCH}-linux-android$( if test $TERMUX_ARCH = arm; then echo eabi; fi )/asm
ln -s "$TERMUX_PKG_BUILDDIR" build
}
termux_step_make_install() {
pip -v install --prefix $TERMUX_PREFIX "$TERMUX_PKG_SRCDIR"
ln -s ${TERMUX_PREFIX}/lib/python3.10/site-packages/torch/lib/*.so ${TERMUX_PREFIX}/lib
}
termux_step_create_debscripts() {
echo "#!$TERMUX_PREFIX/bin/sh" > postinst
echo "pip3 install typing_extensions" >> postinst
}

View File

@@ -1,33 +0,0 @@
diff -uNr pytorch/torch/csrc/autograd/python_function.cpp pytorch.mod/torch/csrc/autograd/python_function.cpp
--- pytorch/torch/csrc/autograd/python_function.cpp 2022-10-03 21:59:02.604422931 +0900
+++ pytorch.mod/torch/csrc/autograd/python_function.cpp 2022-10-03 23:39:51.207871384 +0900
@@ -448,7 +448,7 @@
} else {
throw torch::TypeError(
"save_for_backward can only save variables, but argument %ld is of "
- "type %s", i, Py_TYPE(obj)->tp_name);
+ "type %s", (long)(i), Py_TYPE(obj)->tp_name);
}
}
// Free .to_save
diff -uNr pytorch/torch/csrc/utils/python_arg_parser.h pytorch.mod/torch/csrc/utils/python_arg_parser.h
--- pytorch/torch/csrc/utils/python_arg_parser.h 2022-10-03 19:00:05.000000000 +0900
+++ pytorch.mod/torch/csrc/utils/python_arg_parser.h 2022-10-03 23:39:46.263853740 +0900
@@ -423,7 +423,7 @@
} catch (const std::exception &e) {
throw TypeError("%s(): argument '%s' must be %s, but found element of type %s at pos %ld",
signature.name.c_str(), signature.params[i].name.c_str(),
- signature.params[i].type_name().c_str(), Py_TYPE(obj)->tp_name, idx + 1);
+ signature.params[i].type_name().c_str(), Py_TYPE(obj)->tp_name, (long)(idx + 1));
}
}
return res;
@@ -450,7 +450,7 @@
} catch (const std::exception &e) {
throw TypeError("%s(): argument '%s' must be %s, but found element of type %s at pos %ld",
signature.name.c_str(), signature.params[i].name.c_str(),
- signature.params[i].type_name().c_str(), Py_TYPE(obj)->tp_name, idx + 1);
+ signature.params[i].type_name().c_str(), Py_TYPE(obj)->tp_name, (long)(idx + 1));
}
}
return res;

View File

@@ -1,12 +0,0 @@
diff -uNr pytorch-v1.12.1/torch/csrc/init_flatbuffer_module.cpp pytorch-v1.12.1.mod/torch/csrc/init_flatbuffer_module.cpp
--- pytorch-v1.12.1/torch/csrc/init_flatbuffer_module.cpp 2022-08-06 04:37:12.000000000 +0900
+++ pytorch-v1.12.1.mod/torch/csrc/init_flatbuffer_module.cpp 2022-09-05 00:27:22.542774737 +0900
@@ -27,7 +27,7 @@
std::shared_ptr<char> bytes_copy(
static_cast<char*>(_aligned_malloc(size, FLATBUFFERS_MAX_ALIGNMENT)),
_aligned_free);
-#elif defined(__APPLE__)
+#elif defined(__APPLE__) || defined(__ANDROID__)
void* p;
::posix_memalign(&p, FLATBUFFERS_MAX_ALIGNMENT, size);
TORCH_INTERNAL_ASSERT(p, "Could not allocate memory for flatbuffer");

View File

@@ -1,68 +0,0 @@
diff -uNr pytorch-v1.12.1/torch/lib/libshm/manager.cpp pytorch-v1.12.1.mod/torch/lib/libshm/manager.cpp
--- pytorch-v1.12.1/torch/lib/libshm/manager.cpp 2022-08-06 04:37:12.000000000 +0900
+++ pytorch-v1.12.1.mod/torch/lib/libshm/manager.cpp 2022-09-05 00:26:25.218153450 +0900
@@ -25,6 +25,65 @@
#define DEBUG(...) (void)0
#endif
+static int shm_unlink(const char *name) {
+ size_t namelen;
+ char *fname;
+
+ /* Construct the filename. */
+ while (name[0] == '/') ++name;
+
+ if (name[0] == '\0') {
+ /* The name "/" is not supported. */
+ errno = EINVAL;
+ return -1;
+ }
+
+ namelen = strlen(name);
+ fname = (char *) alloca(sizeof("@TERMUX_PREFIX@/tmp/") - 1 + namelen + 1);
+ memcpy(fname, "@TERMUX_PREFIX@/tmp/", sizeof("@TERMUX_PREFIX@/tmp/") - 1);
+ memcpy(fname + sizeof("@TERMUX_PREFIX@/tmp/") - 1, name, namelen + 1);
+
+ return unlink(fname);
+}
+
+static int shm_open(const char *name, int oflag, mode_t mode) {
+ size_t namelen;
+ char *fname;
+ int fd;
+
+ /* Construct the filename. */
+ while (name[0] == '/') ++name;
+
+ if (name[0] == '\0') {
+ /* The name "/" is not supported. */
+ errno = EINVAL;
+ return -1;
+ }
+
+ namelen = strlen(name);
+ fname = (char *) alloca(sizeof("@TERMUX_PREFIX@/tmp/") - 1 + namelen + 1);
+ memcpy(fname, "@TERMUX_PREFIX@/tmp/", sizeof("@TERMUX_PREFIX@/tmp/") - 1);
+ memcpy(fname + sizeof("@TERMUX_PREFIX@/tmp/") - 1, name, namelen + 1);
+
+ fd = open(fname, oflag, mode);
+ if (fd != -1) {
+ /* We got a descriptor. Now set the FD_CLOEXEC bit. */
+ int flags = fcntl(fd, F_GETFD, 0);
+ flags |= FD_CLOEXEC;
+ flags = fcntl(fd, F_SETFD, flags);
+
+ if (flags == -1) {
+ /* Something went wrong. We cannot return the descriptor. */
+ int save_errno = errno;
+ close(fd);
+ fd = -1;
+ errno = save_errno;
+ }
+ }
+
+ return fd;
+}
+
struct ClientSession {
ClientSession(ManagerSocket s) : socket(std::move(s)), pid(0) {}

View File

@@ -1,41 +0,0 @@
TERMUX_PKG_HOMEPAGE=https://github.com/pytorch/vision
TERMUX_PKG_DESCRIPTION="Datasets, Transforms and Models specific to Computer Vision"
TERMUX_PKG_LICENSE="BSD 3-Clause"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=0.13.1
TERMUX_PKG_REVISION=1
TERMUX_PKG_SRCURL=https://github.com/pytorch/vision.git
TERMUX_PKG_DEPENDS="python, python-numpy, python-pillow, python-torch, libjpeg-turbo, libpng, ffmpeg, zlib"
termux_step_pre_configure() {
_PYTHON_VERSION=$(. $TERMUX_SCRIPTDIR/packages/python/build.sh; echo $_MAJOR_VERSION)
termux_setup_python_crossenv
pushd $TERMUX_PYTHON_CROSSENV_SRCDIR
_CROSSENV_PREFIX=$TERMUX_PKG_BUILDDIR/python-crossenv-prefix
python${_PYTHON_VERSION} -m crossenv \
$TERMUX_PREFIX/bin/python${_PYTHON_VERSION} \
${_CROSSENV_PREFIX}
popd
. ${_CROSSENV_PREFIX}/bin/activate
build-pip install -U wheel setuptools
CFLAGS+=" -I${TERMUX_PREFIX}/lib/python${_PYTHON_VERSION}/site-packages/torch/include"
CFLAGS+=" -I${TERMUX_PREFIX}/lib/python${_PYTHON_VERSION}/site-packages/torch/include/torch/csrc/api/include"
CXXFLAGS+=" -DUSE_PYTHON"
LDFLAGS+=" -ltorch_cpu -ltorch_python -lc10"
}
termux_step_configure() {
:
}
termux_step_make_install() {
pip -v install --prefix "$TERMUX_PREFIX" "$TERMUX_PKG_SRCDIR"
}
termux_step_create_debscripts() {
echo "#!$TERMUX_PREFIX/bin/sh" > postinst
echo "pip3 install typing_extensions requests" >> postinst
}

View File

@@ -1,106 +0,0 @@
diff -uNr vision/setup.py vision.mod/setup.py
--- vision/setup.py 2022-10-07 23:30:59.696293602 +0900
+++ vision.mod/setup.py 2022-10-08 01:16:59.594996000 +0900
@@ -6,10 +6,9 @@
import subprocess
import sys
-import torch
from pkg_resources import parse_version, get_distribution, DistributionNotFound
from setuptools import setup, find_packages
-from torch.utils.cpp_extension import BuildExtension, CppExtension, CUDAExtension, CUDA_HOME
+from setuptools import Extension as CppExtension
def read(*names, **kwargs):
@@ -141,11 +140,6 @@
is_rocm_pytorch = False
- if torch.__version__ >= "1.5":
- from torch.utils.cpp_extension import ROCM_HOME
-
- is_rocm_pytorch = (torch.version.hip is not None) and (ROCM_HOME is not None)
-
if is_rocm_pytorch:
from torch.utils.hipify import hipify_python
@@ -182,10 +176,8 @@
define_macros = []
- extra_compile_args = {"cxx": []}
- if (torch.cuda.is_available() and ((CUDA_HOME is not None) or is_rocm_pytorch)) or os.getenv(
- "FORCE_CUDA", "0"
- ) == "1":
+ extra_compile_args = []
+ if False:
extension = CUDAExtension
sources += source_cuda
if not is_rocm_pytorch:
@@ -308,11 +300,7 @@
# Locating nvjpeg
# Should be included in CUDA_HOME for CUDA >= 10.1, which is the minimum version we have in the CI
- nvjpeg_found = (
- extension is CUDAExtension
- and CUDA_HOME is not None
- and os.path.exists(os.path.join(CUDA_HOME, "include", "nvjpeg.h"))
- )
+ nvjpeg_found = False
print(f"NVJPEG found: {nvjpeg_found}")
image_macros += [("NVJPEG_FOUND", str(int(nvjpeg_found)))]
@@ -340,7 +328,7 @@
)
)
- ffmpeg_exe = shutil.which("ffmpeg")
+ ffmpeg_exe = "@TERMUX_PREFIX@/bin/ffmpeg"
has_ffmpeg = ffmpeg_exe is not None
# FIXME: Building torchvision with ffmpeg on MacOS or with Python 3.9
# FIXME: causes crash. See the following GitHub issues for more details.
@@ -348,13 +336,6 @@
# FIXME: https://github.com/pytorch/vision/issues/3367
if sys.platform != "linux" or (sys.version_info.major == 3 and sys.version_info.minor == 9):
has_ffmpeg = False
- if has_ffmpeg:
- try:
- # This is to check if ffmpeg is installed properly.
- subprocess.check_output(["ffmpeg", "-version"])
- except subprocess.CalledProcessError:
- print("Error fetching ffmpeg version, ignoring ffmpeg.")
- has_ffmpeg = False
print(f"FFmpeg found: {has_ffmpeg}")
@@ -435,13 +416,7 @@
# CUDA_HOME should be set to the cuda root directory.
# TORCHVISION_INCLUDE and TORCHVISION_LIBRARY should include the location to
# video codec header files and libraries respectively.
- video_codec_found = (
- extension is CUDAExtension
- and CUDA_HOME is not None
- and any([os.path.exists(os.path.join(folder, "cuviddec.h")) for folder in vision_include])
- and any([os.path.exists(os.path.join(folder, "nvcuvid.h")) for folder in vision_include])
- and any([os.path.exists(os.path.join(folder, "libnvcuvid.so")) for folder in library_dirs])
- )
+ video_codec_found = False
print(f"video codec found: {video_codec_found}")
@@ -525,14 +500,9 @@
packages=find_packages(exclude=("test",)),
package_data={package_name: ["*.dll", "*.dylib", "*.so"]},
zip_safe=False,
- install_requires=requirements,
extras_require={
"scipy": ["scipy"],
},
ext_modules=get_extensions(),
python_requires=">=3.7",
- cmdclass={
- "build_ext": BuildExtension.with_options(no_python_abi_suffix=True),
- "clean": clean,
- },
)