Repository: conan-io/conan

Issue:
[bug] pyinstaller.py does not work on python 3.8 ( but works with 3.6 ) 
#Environment Details (include every applicable attribute)
  * rhel 7
  * compiler: has no impact
  * Conan version: 1.21
  * Python version: 3.8.1

### Steps to reproduce (Include if Applicable)


```
#make sure you have libffi-devel and sqlite-devel available on your platform.
#Compile and set to use python:
wget https://www.python.org/ftp/python/3.8.1/Python-3.8.1.tgz -O python.tgz
mkdir python
tar -xf python.tgz -C python --strip-components 1

(
cd python
./configure --prefix=${DIR}/python-compiled --enable-optimizations --enable-shared --enable-loadable-sqlite-extensions --disable-tests && make install -j $(nproc)
cd ${DIR}/python-compiled/bin
ln -s python3 python
ln -s pip3 pip
)
export PATH=${CURRENT_DIRECTORY}/python-compiled/bin:$PATH
export LD_LIBRARY_PATH=${CURRENT_DIRECTORY}/python-compiled/lib

git clone https://github.com/conan-io/conan.git

cd conan
git checkout ${CONAN_VERSION}
#first install conan dependencies ( this succeds): 
pip install -r conans/requirements.txt
#offending line here!
python pyinstaller.py

```



### Logs (Executed commands with output) (Include/Attach if Applicable)
Output I got was something along the lines of ...

```
......

18091 INFO: Building PYZ because PYZ-00.toc is non existent
18091 INFO: Building PYZ (ZlibArchive) /var/ig/IGWork/fulara/conan-standalone-package/conan-standalone/conan-bundling/conan/pyinstaller/build/conan/PYZ-00.pyz
Traceback (most recent call last):
  File "/var/ig/IGWork/fulara/conan-standalone-package/conan-standalone/conan-bundling/python-compiled/bin/pyinstaller", line 10, in <module>
    sys.exit(run())
  File "/var/ig/IGWork/fulara/conan-standalone-package/conan-standalone/conan-bundling/python-compiled/lib/python3.8/site-packages/PyInstaller/__main__.py", line 111, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "/var/ig/IGWork/fulara/conan-standalone-package/conan-standalone/conan-bundling/python-compiled/lib/python3.8/site-packages/PyInstaller/__main__.py", line 63, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "/var/ig/IGWork/fulara/conan-standalone-package/conan-standalone/conan-bundling/python-compiled/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 844, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "/var/ig/IGWork/fulara/conan-standalone-package/conan-standalone/conan-bundling/python-compiled/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 791, in build
    exec(code, spec_namespace)
  File "/var/ig/IGWork/fulara/conan-standalone-package/conan-standalone/conan-bundling/conan/pyinstaller/conan.spec", line 18, in <module>
    pyz = PYZ(a.pure, a.zipped_data,
  File "/var/ig/IGWork/fulara/conan-standalone-package/conan-standalone/conan-bundling/python-compiled/lib/python3.8/site-packages/PyInstaller/building/api.py", line 98, in __init__
    self.__postinit__()
  File "/var/ig/IGWork/fulara/conan-standalone-package/conan-standalone/conan-bundling/python-compiled/lib/python3.8/site-packages/PyInstaller/building/datastruct.py", line 158, in __postinit__
    self.assemble()
  File "/var/ig/IGWork/fulara/conan-standalone-package/conan-standalone/conan-bundling/python-compiled/lib/python3.8/site-packages/PyInstaller/building/api.py", line 128, in assemble
    self.code_dict = {
  File "/var/ig/IGWork/fulara/conan-standalone-package/conan-standalone/conan-bundling/python-compiled/lib/python3.8/site-packages/PyInstaller/building/api.py", line 129, in <dictcomp>
    key: strip_paths_in_code(code)
  File "/var/ig/IGWork/fulara/conan-standalone-package/conan-standalone/conan-bundling/python-compiled/lib/python3.8/site-packages/PyInstaller/building/utils.py", line 652, in strip_paths_in_code
    consts = tuple(
  File "/var/ig/IGWork/fulara/conan-standalone-package/conan-standalone/conan-bundling/python-compiled/lib/python3.8/site-packages/PyInstaller/building/utils.py", line 653, in <genexpr>
    strip_paths_in_code(const_co, new_filename)
  File "/var/ig/IGWork/fulara/conan-standalone-package/conan-standalone/conan-bundling/python-compiled/lib/python3.8/site-packages/PyInstaller/building/utils.py", line 660, in strip_paths_in_code
    return code_func(co.co_argcount, co.co_kwonlyargcount, co.co_nlocals, co.co_stacksize,
TypeError: an integer is required (got type bytes)
sh: /var/ig/IGWork/fulara/conan-standalone-package/conan-standalone/conan-bundling/conan/pyinstaller/dist/conan/conan: No such file or directory
Traceback (most recent call last):
  File "pyinstaller.py", line 131, in <module>
    output_folder = pyinstall(source_folder)
  File "pyinstaller.py", line 108, in pyinstall
    _run_bin(pyinstaller_path)
  File "pyinstaller.py", line 27, in _run_bin
    raise Exception("Binary not working")
Exception: Binary not working
```

With python 3.6 this works.
I couldnt find any mentions on your docs file that you dont support newer conans.




Discussion:
Hi, @fulara, currently we are not running the project with python 3.8 but we should add it to our CI asap, it is the current released version, the default installation suggested in Python webpage. More and more users will find issues related to it (not just with pyinstaller).


This is mostly a ``pyinstaller`` issue: https://github.com/pyinstaller/pyinstaller/issues/4311

The rest of Conan seems to work (and is tested in CI) with Python 3.8.

I think we can do little here, except add a check in our code that will raise an informative error saying that pyinstaller dont run with Python 3.8. What do you think?
IMO, nothing to do here. Are there many people creating the installers themselves? We could add the warning/error, and then watch that issue and remove it when available, but if `pyinstaller` themselves are not raising that error, should be?
It is just 2 lines, and yes, some users do use our pyinstaller, so I think it is worth. @fulara ?
yep, we use pytinstaller to bundle conan into self contained package, without this we cannot migrate to python 3.8.

At the moment we are using python 3.6 - I'll test whether it works with python 3.7.

Information stating that pyinstaller does not work with py 3.8 while trying to invoke it would be great, maybe a hint on docs as well, but not essential.
> Information stating that pyinstaller does not work with py 3.8 while trying to invoke it would be great, maybe a hint on docs as well, but not essential.

Good, lets add a proper error in the code, that would be 100% effective, no docs needed in that case. Would you like to contribute it yourself, @fulara?, that should be easy.

Resolving patch:
diff --git a/pyinstaller.py b/pyinstaller.py
--- a/pyinstaller.py
+++ b/pyinstaller.py
@@ -4,6 +4,7 @@
 import platform
 import shutil
 import subprocess
+import sys
 from distutils import dir_util
 
 from conans import __version__
@@ -127,6 +128,10 @@ def pyinstall(source_folder):
 
 
 if __name__ == "__main__":
+    if sys.version_info.major == 3 and sys.version_info.minor >= 8:
+        print("pyinstaller does not yet support python 3.8, "
+              "see: https://github.com/pyinstaller/pyinstaller/issues/4311", file=sys.stderr)
+        exit(1)
     source_folder = os.path.abspath(os.path.dirname(os.path.abspath(__file__)))
     output_folder = pyinstall(source_folder)
     print("\n**************Conan binaries created!******************\n"


Test patch: