Repository: pyinstaller/pyinstaller

Issue:
Support pyinstaller for arm64 for termux
I use a python3.10 in my daily life when updating the compiler gcc to version 13 I can not install pyinstaller


Discussion:
> updating the compiler gcc to version 13

Is there a gcc 13 already? As far as I know, even 12 was not released yet...

But at any rate, if you expect us to do something, it'd be nice to at least know *why* you cannot install pyinstaller (i.e., what is the error message).
```
ERROR: Command errored out with exit status 1:
   command: /data/data/com.termux/files/usr/bin/python3 /data/data/com.termux/files/usr/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /data/data/com.termux/files/usr/tmp/tmp3w5vqddw
       cwd: /data/data/com.termux/files/usr/tmp/pip-install-9ehmgwym/pyinstaller_396dd277de2f49098f7e5863a15c8bdf
  Complete output (29 lines):
  running bdist_wheel
  running build
  running build_bootloader
  No precompiled bootloader found. Trying to compile it for you ...
  Setting top to                           : /data/data/com.termux/files/usr/tmp/pip-install-9ehmgwym/pyinstaller_396dd277de2f49098f7e5863a15c8bdf/bootloader
  Setting out to                           : /data/data/com.termux/files/usr/tmp/pip-install-9ehmgwym/pyinstaller_396dd277de2f49098f7e5863a15c8bdf/bootloader/build
  Python Version                           : 3.10.1 (main, Dec  9 2021, 15:28:13) [Clang 12.0.8 (https://android.googlesource.com/toolchain/llvm-project c935d99d7
  Checking for 'gcc' (C compiler)          : not found
  Checking for 'clang' (C compiler)        : /data/data/com.termux/files/usr/bin/clang
  Checking size of pointer                 : 8
  Platform                                 : Linux-64bit-arm detected based on compiler
  Checking for compiler flags -m64         : yes
  Checking for linker flags -m64           : yes
  Checking for library dl                  : yes
  Checking for library pthread             : yes
  Checking for library m                   : yes
  Checking for library z                   : yes
  Checking for library cmocka              : not found
  Checking for function unsetenv           : yes
  Checking for function mkdtemp            : yes
  Checking for function dirname            : yes
  Checking for function basename           : yes
  Checking for function strndup            : yes
  Checking for function strnlen            : yes
  Checking for compiler flags -Wl,--as-needed : yes
  Checking for program 'strip'                : not found
  Could not find the program ['strip']
  (complete log in /data/data/com.termux/files/usr/tmp/pip-install-9ehmgwym/pyinstaller_396dd277de2f49098f7e5863a15c8bdf/bootloader/build/config.log)
  ERROR: Failed compiling the bootloader. Please compile manually and rerun setup.py
  ----------------------------------------
  ERROR: Failed building wheel for pyinstaller
Failed to build pyinstaller
ERROR: Could not build wheels for pyinstaller, which is required to install pyproject.toml-based projects
```
There is such an error when using pip install pyinstaller

I will also add 
~ $ clang --version
clang version 13.0.0
Target: aarch64-unknown-linux-android24
Thread model: posix
InstalledDir: /data/data/com.termux/files/usr/bin

Also
~$ gcc --version
clang version 13.0.0
Target: aarch64-unknown-linux-android24                                 Thread model: posix
InstalledDir: /data/data/com.termux/files/usr/bin

> ~$ gcc --version
> clang version 13.0.0
> Target: aarch64-unknown-linux-android24 Thread model: posix
> InstalledDir: /data/data/com.termux/files/usr/bin

So you're actually using `clang`, not `gcc`.

And the error is due to `strip` utility not being found. What is the output of `strip --version`?
Or, if you have `llvm-strip` available instead, can you try doing `export STRIP=llvm-strip` before running `pip install pyinstaller`?
And if you have no variant of strip utility installed, you can probably get away with `export STRIP=touch` as well...
I'm not an expert or know how to fix an installation error, but before I could install pyinstaller only some changes to the lines of code however after updating the packages in termux everything went awry
 Rather, without misleading, I do not even have a green idea of ​​how to use strip
I've had a go at this before. clang is the go-to compiler on termux for some reason. I managed to get the past the compile step (I'm fairly certain i just worked as-is - I can't remember how), build a hello world application but it seg-faulted running and I left it at that.

In all honesty, what do you hope to achieve by compiling a Termux application? Termux is strictly headless only so you can't make GUI apps and you need to install Termux to launch anything you build because AFAIK Android does not have any public way of launching executables so if you're thinking to write apps in it - forget it. All that leaves you with is command line Termux-only applications which can be better distributed via either apt or pip. 
It looks like `strip`  is still provided by termux' [`binutils` package](https://grimler.se/termux-packages-24/pool/main/b/binutils/). Do you have that installed? Without it, you probably won't be able to use PyInstaller anyway, since we require `objdump`/`objcopy` from that package as well...
I installed your package and made changes by ... / PyInstaller / depend $ vim bindepend.py  line 736 paths = ['/data/data/com.termux/files/usr/lib', '/lib', '/usr/lib'] and everything worked

Here are the links https://github.com/termux/termux-app/issues/1595
Well if that really is all we need then I'm happy to support it.

Resolving patch:
diff --git a/PyInstaller/depend/bindepend.py b/PyInstaller/depend/bindepend.py
--- a/PyInstaller/depend/bindepend.py
+++ b/PyInstaller/depend/bindepend.py
@@ -760,6 +760,10 @@ def findLibrary(name):
         except ImportError:
             logger.debug('Multiarch directory not detected.')
 
+        # Termux (a Ubuntu like subsystem for Android) has an additional libraries directory.
+        if os.path.isdir('/data/data/com.termux/files/usr/lib'):
+            paths.append('/data/data/com.termux/files/usr/lib')
+
         if compat.is_aix:
             paths.append('/opt/freeware/lib')
         elif compat.is_hpux:


Test patch: