termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
13.08k stars 3k forks source link

[Bug]: Pypy's pip cannot install Falcon #20809

Closed 1q23lyc45 closed 1 month ago

1q23lyc45 commented 2 months ago

Problem description

Pypy's pip cannot install Falcon. However, it can be installed using the official Python interpreter and Python pip.

[Errno 13] Permission denied

What steps will reproduce the bug?

pypy -m ensurepip
pypy -m pip install falcon
/data/data/com.termux/files/usr/opt/pypy3/lib/pypy3.9/site-packages/pip/_vendor/certifi/cacert.pem None
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting falcon
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/3b/30/a7bc770025b6a7a36d0508e3d735dca239df7c27b862856e54d661f24632/falcon-3.1.3.tar.gz (577 kB)
     ━━━━━━━━━━━━━ 577.8/577.8   2.8 MB/s eta 0:00:00
                   kB
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [14 lines of output]
      running dist_info
      creating /data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info
      writing /data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info/PKG-INFO
      writing dependency_links to /data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info/dependency_links.txt
      writing entry points to /data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info/entry_points.txt
      writing top-level names to /data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info/top_level.txt
      writing manifest file '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info/SOURCES.txt'
      reading manifest file '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      no previously-included directories found matching 'docs/_build'
      adding license file 'LICENSE'
      writing manifest file '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info/SOURCES.txt'
      creating '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon-3.1.3.dist-info'
      error: [('/data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info/not-zip-safe', '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info.__bkp__/not-zip-safe', "[Errno 13] Permission denied: '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info.__bkp__/not-zip-safe'"), ('/data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info/PKG-INFO', '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info.__bkp__/PKG-INFO', "[Errno 13] Permission denied: '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info.__bkp__/PKG-INFO'"), ('/data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info/dependency_links.txt', '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info.__bkp__/dependency_links.txt', "[Errno 13] Permission denied: '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info.__bkp__/dependency_links.txt'"), ('/data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info/entry_points.txt', '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info.__bkp__/entry_points.txt', "[Errno 13] Permission denied: '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info.__bkp__/entry_points.txt'"), ('/data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info/top_level.txt', '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info.__bkp__/top_level.txt', "[Errno 13] Permission denied: '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info.__bkp__/top_level.txt'"), ('/data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info/SOURCES.txt', '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info.__bkp__/SOURCES.txt', "[Errno 13] Permission denied: '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info.__bkp__/SOURCES.txt'"), ('/data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info', '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info.__bkp__', "[Errno 13] Permission denied: '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-wfvpcln8/falcon.egg-info.__bkp__'")]
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

What is the expected behavior?

If I use Python, I can install Falcon using your APT source's python-pip.

~ $ pip install falcon scapy
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting falcon                                      Downloading https://pypi.tuna.tsinghua.edu.cn/packages/3b/30/a7bc770025b6a7a36d0508e3d735dca239df7c27b862856e54d661f24632/falcon-3.1.3.tar.gz (577 kB)
     ━━━━━━━━━━━━━ 577.8/577.8   1.0 MB/s eta 0:00:00
                   kB                                  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting scapy                                       Downloading https://pypi.tuna.tsinghua.edu.cn/packages/67/a1/2a60d5b6f0fed297dd0c0311c887d5e8a30ba1250506585b897e5a662f4c/scapy-2.5.0.tar.gz (1.3 MB)
     ━━━━━━━━━━━━━━━━ 1.3/1.3 MB 1.7 MB/s eta 0:00:00  Installing build dependencies ... done
  Getting requirements to build wheel ... done         Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: falcon, scapy  Building wheel for falcon (pyproject.toml) ... done
  Created wheel for falcon: filename=falcon-3.1.3-py3-none-any.whl size=293860 sha256=b71ebc28fb5c79c59aa10f31a1c16b1ba6ebf5eab1413e1aa2389509f165be76
  Stored in directory: /data/data/com.termux/files/home/.cache/pip/wheels/f2/98/74/5c7e7490b4533dba04339d1081e3362fd0a52ff5211b7b0661
  Building wheel for scapy (pyproject.toml) ... done   Created wheel for scapy: filename=scapy-2.5.0-py2.py3-none-any.whl size=1444328 sha256=96ea13fd9414af46fb4c781702d8ba6946bf853e9354d4e75b6b1143ea0bad33
  Stored in directory: /data/data/com.termux/files/home/.cache/pip/wheels/11/80/f9/52a38f7fc78656c274915481bff0ba1c7936092a129fb50bdd
Successfully built falcon scapy
Installing collected packages: scapy, falcon
Successfully installed falcon-3.1.3 scapy-2.5.0

System information

TERMUX_APK_RELEASE=GITHUB
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP_PID=29750
TERMUX_IS_DEBUGGABLE_BUILD=1
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.1
TERMUX__USER_ID=0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-main stable main
Updatable packages:
All packages up to date
termux-tools version:
1.42.4
Android version:
11
Kernel build information:
Linux localhost 5.4.184 #1 SMP PREEMPT Fri Mar 22 16:11:28 ADT 2024 aarch64 Android
Device manufacturer:
5G
Device model:
5G
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so
licy183 commented 2 months ago

pypy3 tries to call setxattr for a file in shutil.copymode. You can remove or comment the line 338 in $PREFIX/opt/pypy3/lib/pypy3.9/shutil.py.

--- ./shutil.py 2024-07-14 19:01:24.305322336 +0800
+++ /data/data/com.termux/files/usr/opt/pypy3/lib/pypy3.9/shutil.py 2024-07-14 18:56:25.277322450 +0800
@@ -335,7 +335,7 @@
         for name in names:
             try:
                 value = os.getxattr(src, name, follow_symlinks=follow_symlinks)
-                os.setxattr(dst, name, value, follow_symlinks=follow_symlinks)
+                # os.setxattr(dst, name, value, follow_symlinks=follow_symlinks)
             except OSError as e:
                 if e.errno not in (errno.EPERM, errno.ENOTSUP, errno.ENODATA,
                                    errno.EINVAL):

I'll fix it if I have more free time.

1q23lyc45 commented 2 months ago

pypy3 tries to call setxattr for a file in shutil.copymode. You can remove or comment the line 338 in $PREFIX/opt/pypy3/lib/pypy3.9/shutil.py.

--- ./shutil.py   2024-07-14 19:01:24.305322336 +0800
+++ /data/data/com.termux/files/usr/opt/pypy3/lib/pypy3.9/shutil.py   2024-07-14 18:56:25.277322450 +0800
@@ -335,7 +335,7 @@
         for name in names:
             try:
                 value = os.getxattr(src, name, follow_symlinks=follow_symlinks)
-                os.setxattr(dst, name, value, follow_symlinks=follow_symlinks)
+                # os.setxattr(dst, name, value, follow_symlinks=follow_symlinks)
             except OSError as e:
                 if e.errno not in (errno.EPERM, errno.ENOTSUP, errno.ENODATA,
                                    errno.EINVAL):

I'll fix it if I have more free time.

Thank you.

licy183 commented 1 month ago

I only fix the xattr issue for pypy(2) but not for pypy3.

I'm refactoring the build script these days, but have some other issues on pypy3. It's not easy to figure out why.

1q23lyc45 commented 1 month ago

I only fix the xattr issue for pypy(2) but not for pypy3.

I'm refactoring the build script these days, but have some other issues on pypy3. It's not easy to figure out why.

I'm Sorry. I forgot, the ones that passed the test just now were all directly pasted with my script, so the patch was directly applied to pypy3, which gave the illusion of passing the test. When testing the 4.x version kernel, it was not at the same time as the 5.x version kernel. As a result, when testing on my 4.x machine, I directly apt install -y pypy3;pypy3 -m ensurepip;pypy3 -m pip install falcon and got an error, mistakenly thinking that this fix was only for the 5.x kernel. I apologize to you again.