Repository: pyinstaller/pyinstaller

Issue:
Can't find libpython3.8 withoud "m" flag
<!--
Welcome to the PyInstaller issue tracker! Before creating an issue, please heed the following:

1. This tracker should only be used to report bugs and request features / enhancements to PyInstaller
    - For questions and general support, use the mailing list, see
	  <http://www.pyinstaller.org/support.html#mailing-list>
2. Use the search function before creating a new issue. Duplicates will be closed and directed to
   the original discussion.
3. When making a bug report, make sure you provide all required information. The easier it is for
   maintainers to reproduce, the faster it'll be fixed.

+++ ONLY TEXT +++ DO NOT POST IMAGES +++
-->

## Description of the issue

Pyinstaller is searching for `libpython3.8m.so`, but python38-devel package installs only `libpython3.8.so`.

## Context information (for bug reports)

* Output of `pyinstaller --version`: ```4.3``` (the same with latest development version 5.0.dev0)
* Version of Python: 3.8.6
* Platform: GNU/Linux CentOS 7
* Did you also try this on another platform? Does it work there? Haven't tried

### A minimal example program which shows the error

```
$ docker run -it centos:7
```

Inside container:
```
$ yum update -y
$ yum install -y epel-release centos-release-scl scl-utils make
$ yum install -y rh-python38 rh-python38-python-devel
$ scl enable rh-python38 'pip install --upgrade pip'
$ scl enable rh-python38 'pip install pyinstaller'
$ scl enable rh-python38 'pyinstaller ...'
```

```
$ ls -l /opt/rh/rh-python38/root/usr/lib64/
total 3812
dr-xr-xr-x  2 root root    4096 Mar 30  2020 X11
dr-xr-xr-x  2 root root    4096 Mar 30  2020 games
lrwxrwxrwx  1 root root      31 Apr 19 07:00 libpython3.8.so -> libpython3.8.so.rh-python38-1.0
-rwxr-xr-x  1 root root 3846208 Oct 27 09:16 libpython3.8.so.rh-python38-1.0
-rwxr-xr-x  1 root root   14848 Oct 27 09:16 libpython3.so.rh-python38
drwxr-xr-x  2 root root    4096 Apr 19 07:00 pkgconfig
dr-xr-xr-x  5 root root    4096 Apr 19 07:00 pm-utils
drwxr-xr-x 31 root root   12288 Apr 19 07:00 python3.8
dr-xr-xr-x  2 root root    4096 Mar 30  2020 sse2
dr-xr-xr-x  2 root root    4096 Mar 30  2020 tls
```

### Stacktrace / full error message

```
28267 INFO: Python library not in binary dependencies. Doing additional searching...
Traceback (most recent call last):
  File "/opt/rh/rh-python38/root/usr/local/bin/pyinstaller", line 8, in <module>
    sys.exit(run())
  File "/opt/rh/rh-python38/root/usr/local/lib/python3.8/site-packages/PyInstaller/__main__.py", line 114, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "/opt/rh/rh-python38/root/usr/local/lib/python3.8/site-packages/PyInstaller/__main__.py", line 65, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "/opt/rh/rh-python38/root/usr/local/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 737, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "/opt/rh/rh-python38/root/usr/local/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 684, in build
    exec(code, spec_namespace)
  File "cmd.spec", line 7, in <module>
    a = Analysis(['gooddata/cmd/__main__.py'],
  File "/opt/rh/rh-python38/root/usr/local/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 242, in __init__
    self.__postinit__()
  File "/opt/rh/rh-python38/root/usr/local/lib/python3.8/site-packages/PyInstaller/building/datastruct.py", line 160, in __postinit__
    self.assemble()
  File "/opt/rh/rh-python38/root/usr/local/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 476, in assemble
    self._check_python_library(self.binaries)
  File "/opt/rh/rh-python38/root/usr/local/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 581, in _check_python_library
    python_lib = bindepend.get_python_library_path()
  File "/opt/rh/rh-python38/root/usr/local/lib/python3.8/site-packages/PyInstaller/depend/bindepend.py", line 956, in get_python_library_path
    raise IOError(msg)
OSError: Python library not found: libpython3.8m.so.1.0, libpython3.8mu.so.1.0, libpython3.8m.so, libpython3.8.so.1.0
    This would mean your Python installation doesn't come with proper library files.
    This usually happens by missing development package, or unsuitable build parameters of Python installation.

    * On Debian/Ubuntu, you would need to install Python development packages
      * apt-get install python3-dev
      * apt-get install python-dev
    * If you're building Python by yourself, please rebuild your Python with `--enable-shared` (or, `--enable-framework` on Darwin)
```



Discussion:
Yeah, that's an issue that's specific to python installed from RHEL SCL, due to how the python library is named (`libpython3.8.so.rh-python38-1.0` instead of `libpython3.8.so.1.0` that would be found in non-SCL packages). 

I'd say that not checking for `libpython3.X.so` is simply an oversight; b748881a703806d946428f509f7c5f24df8a7488 explictly added check for `libpython3.Xm.so` for SCL compatibility; but that was in the days when m suffix also present in the name (AFAICT, python 3.7 and earlier).

Resolving patch:
diff --git a/PyInstaller/compat.py b/PyInstaller/compat.py
--- a/PyInstaller/compat.py
+++ b/PyInstaller/compat.py
@@ -97,7 +97,8 @@
     PYDYLIB_NAMES = {'libpython%d.%d.so.1.0' % _pyver,
                      'libpython%d.%dm.so.1.0' % _pyver,
                      'libpython%d.%dmu.so.1.0' % _pyver,
-                     'libpython%d.%dm.so' % _pyver}
+                     'libpython%d.%dm.so' % _pyver,
+                     'libpython%d.%d.so' % _pyver}
 else:
     raise SystemExit('Your platform is not yet supported. '
                      'Please define constant PYDYLIB_NAMES for your platform.')


Test patch: