Skip to content
This repository has been archived by the owner on Feb 24, 2023. It is now read-only.

Error when build #30

Closed
blackeangel opened this issue May 11, 2020 · 5 comments
Closed

Error when build #30

blackeangel opened this issue May 11, 2020 · 5 comments
Labels

Comments

@blackeangel
Copy link

blackeangel commented May 11, 2020

  1. if python2 is the default then invalid syntax error.
    To solve this problem it is necessary to replace
    #!/usr/bin/env python
    On
    #!/usr/bin/env python3

in all *.py files

  1. you need to add a check for the version of python and the presence in the variable ndk. Download the latest versions of ndk and python.

The wish is to make the assembly static so that you can safely use it.

I have an article on how to do this and how to achieve a finished size of ~ 50-60 mb instead of 160 mb as it is now
Here how do it
Also this error when compiling
ERROR: Exception: Traceback (most recent call last): File "/tmp/tmp01392fio/pip-19.2.3-py2.py3-none-any.whl/pip/_internal/cli/base_command.py", line 188, in main status = self.run(options, args) File "/tmp/tmp01392fio/pip-19.2.3-py2.py3-none-any.whl/pip/_internal/commands/install.py", line 286, in run with self._build_session(options) as session: File "/tmp/tmp01392fio/pip-19.2.3-py2.py3-none-any.whl/pip/_internal/cli/base_command.py", line 101, in _build_session session = PipSession( File "/tmp/tmp01392fio/pip-19.2.3-py2.py3-none-any.whl/pip/_internal/download.py", line 559, in __init__ self.headers["User-Agent"] = user_agent() File "/tmp/tmp01392fio/pip-19.2.3-py2.py3-none-any.whl/pip/_internal/download.py", line 144, in user_agent zip(["name", "version", "id"], distro.linux_distribution()), File "/tmp/tmp01392fio/pip-19.2.3-py2.py3-none-any.whl/pip/_vendor/distro.py", line 122, in linux_distribution return _distro.linux_distribution(full_distribution_name) File "/tmp/tmp01392fio/pip-19.2.3-py2.py3-none-any.whl/pip/_vendor/distro.py", line 677, in linux_distribution self.version(), File "/tmp/tmp01392fio/pip-19.2.3-py2.py3-none-any.whl/pip/_vendor/distro.py", line 737, in version self.lsb_release_attr('release'), File "/tmp/tmp01392fio/pip-19.2.3-py2.py3-none-any.whl/pip/_vendor/distro.py", line 899, in lsb_release_attr return self._lsb_release_info.get(attribute, '') File "/tmp/tmp01392fio/pip-19.2.3-py2.py3-none-any.whl/pip/_vendor/distro.py", line 552, in __get__ ret = obj.__dict__[self._fname] = self._f(obj) File "/tmp/tmp01392fio/pip-19.2.3-py2.py3-none-any.whl/pip/_vendor/distro.py", line 1012, in _lsb_release_info stdout = subprocess.check_output(cmd, stderr=devnull) File "/home/sam/Загрузки/python3-android-master/src/cpython/Lib/subprocess.py", line 420, in check_output return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, File "/home/sam/Загрузки/python3-android-master/src/cpython/Lib/subprocess.py", line 524, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1. Makefile:1239: recipe for target 'install' failed make: *** [install] Error 2

And why not compiling next modules?
`Python build finished successfully!
The necessary bits to build these optional modules were not found:
_bz2 _dbm _gdbm
_lzma _sqlite3 _ssl
_tkinter _uuid nis
readline spwd zlib
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc atexit pwd
time

Failed to build these modules:
_ctypes _hashlib

Could not build the ssl module!
Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host().
LibreSSL 2.6.4 and earlier do not provide the necessary APIs, libressl/portable#381
`
Sorry for my English (Google translate)

@yan12125
Copy link
Owner

Thanks for the feedback. The error has been reported at python-distro/distro#260.

I will look at other feedback soon.

@blackeangel
Copy link
Author

Thanks for the feedback. The error has been reported at nir0s/distro#260.

I will look at other feedback soon.

Also pushd and popd are only in bash, and not in shell.
Then
#!/bin/sh
change to
#!/bin/bash

@yan12125 yan12125 added the bug label May 13, 2020
yan12125 pushed a commit that referenced this issue May 15, 2020
* Switch to a tagged version. Preparation for stable versions (#29)
    * Switches to official Python docker images
* Fixes for cross-distro compatibility (#30)
* Update OpenSSL to 1.1.1g
@yan12125
Copy link
Owner

I fixed shebang lines for scripts. Now they should run fine for most Linux distros.

you need to add a check for the version of python and the presence in the variable ndk

I already check $ANDROID_NDK here

raise Exception('Requires environment variable $ANDROID_NDK')

Checking Python version is more tricky as newer or older Python versions may or may not work. I don't plan to add complex checks.

The wish is to make the assembly static so that you can safely use it.

Mind to share more details? Dynamic modules already run fine.

how to achieve a finished size of ~ 50-60 mb instead of 160 mb

Well, most likely Python 3.9 has much more stuffs than Python 2.7.8 and 3.4.2. The steps in that article are mostly the same as my scripts.

[1] https://bugs.python.org/issue26852
[2] https://bugs.python.org/issue27640

@yan12125 yan12125 added question and removed bug labels May 15, 2020
@blackeangel
Copy link
Author

blackeangel commented May 15, 2020

Mind

I tried building the static version several times, but I failed in places: ssl, pip and other standard python modules.
It was a static build, but only for python. This bulette is useful to many people.
you can choose which assembly to build (static or dynamic)
https://github.com/andrew-d/static-binaries/tree/master/python
this person did but for python 2

if you use strip -s on a static assembly and then make clean it will reduce the size of python itself by 2-3 times
I tried editing your code under static by adding the "-static" switch to the compiler, but failed

I already check $ANDROID_NDK here

I am not talking about that. I'm generally about checking in bash script for version availability like this:

if [-z $(echo $ANDROID_NDK)]; then
     echo "insert path to ANDROID_NDK"
......
fi

@blackeangel
Copy link
Author

I fixed shebang lines for scripts. Now they should run fine for most Linux distros.

you need to add a check for the version of python and the presence in the variable ndk

I already check $ANDROID_NDK here

raise Exception('Requires environment variable $ANDROID_NDK')

Checking Python version is more tricky as newer or older Python versions may or may not work. I don't plan to add complex checks.

The wish is to make the assembly static so that you can safely use it.

Mind to share more details? Dynamic modules already run fine.

how to achieve a finished size of ~ 50-60 mb instead of 160 mb

Well, most likely Python 3.9 has much more stuffs than Python 2.7.8 and 3.4.2. The steps in that article are mostly the same as my scripts.

[1] https://bugs.python.org/issue26852
[2] https://bugs.python.org/issue27640

yoh!!!
I fix it!
sudo mv /usr/bin/lsb_release /usr/bin/lsb_release_back
And all compiling good!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants