Bug 1910923

Summary: python3-z3 is broken on a fresh install
Product: [Fedora] Fedora Reporter: nik <nikita>
Component: z3Assignee: Jerry James <loganjerry>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 33CC: loganjerry
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: z3-4.8.9-4.fc33 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-01-04 01:07:09 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description nik 2020-12-25 21:29:25 UTC
Description of problem:
python3-z3 doesn't work on a clean Fedora 33.

Version-Release number of selected component (if applicable):
4.8.9-3.fc33

How reproducible:
Always

Steps to Reproduce:
1. Start with a fresh Fedora (I used a container: `podman run -it fedora:33`)

2. In the container install python3-z3: `dnf install python3-z3`

3. Try to use z3: `python3 -c 'import z3'`. You'll encounter the first problem:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.9/site-packages/z3/__init__.py", line 1, in <module>
    from .z3 import *
  File "/usr/lib/python3.9/site-packages/z3/z3.py", line 43, in <module>
    from . import z3core
  File "/usr/lib/python3.9/site-packages/z3/z3core.py", line 5, in <module>
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'

It means that python3-z3 requires python3-setuptools as a dependency, but it's not there.

4. Fix the dependency issue manually: `dnf install python3-setuptools`

5. Try to use z3 again: `python3 -c 'import z3'`. You'll encounter the second problem:

Could not find libz3.so; consider adding the directory containing it to
  - your system's PATH environment variable,
  - the Z3_LIBRARY_PATH environment variable, or 
  - to the custom Z3_LIBRARY_DIRS Python-builtin before importing the z3 module, e.g. via
    import builtins
    builtins.Z3_LIB_DIRS = [ '/path/to/libz3.so' ] 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.9/site-packages/z3/__init__.py", line 1, in <module>
    from .z3 import *
  File "/usr/lib/python3.9/site-packages/z3/z3.py", line 43, in <module>
    from . import z3core
  File "/usr/lib/python3.9/site-packages/z3/z3core.py", line 67, in <module>
    raise Z3Exception("libz3.%s not found." % _ext)
z3.z3types.Z3Exception: libz3.so not found.

Actual results:
You cannot import and start using z3 successfully in Python 3.


Expected results:
`python3 -c 'import z3'` exits without error.

Additional info:
I think the first problem can be solved by adding python3-setuptools to the .spec file on line 82:
https://src.fedoraproject.org/rpms/z3/blob/259befebd79b14f80baef3ce4bd8dbdf12d253ce/f/z3.spec#_82

The second problem happens because z3 looks for libz3.so but Fedora install the shared object under /usr/lib64/libz3.so.4.8. Therefore /usr/lib64/libz3.so doesn't exists and z3 fails to load.

A temporary workaround is symlinking the shared object: `ln -s libz3.so.4.8 /usr/lib64/libz3.so`

(The code in z3 that looks for the SO is in https://github.com/Z3Prover/z3/blob/7f0b5bc129988225c831314202608a26a18170f9/scripts/update_api.py#L1804)

I'm available if you need any clarifications or assistance :)
Best,
Nik

Comment 1 Jerry James 2020-12-26 16:42:38 UTC
Thank you for the bug report and analysis, Nik.  I've got a candidate fix building and will push an update soon for you to try out.

Comment 2 Fedora Update System 2020-12-26 16:59:34 UTC
FEDORA-2020-8ee3a64b83 has been submitted as an update to Fedora 33. https://bodhi.fedoraproject.org/updates/FEDORA-2020-8ee3a64b83

Comment 3 Fedora Update System 2020-12-27 01:11:47 UTC
FEDORA-2020-8ee3a64b83 has been pushed to the Fedora 33 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2020-8ee3a64b83`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-8ee3a64b83

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 4 nik 2020-12-27 09:32:13 UTC
Thanks for the quick fix. I tested it on a fedora:33 container and the issue is fixed for me.

Comment 5 Fedora Update System 2021-01-04 01:07:09 UTC
FEDORA-2020-8ee3a64b83 has been pushed to the Fedora 33 stable repository.
If problem still persists, please make note of it in this bug report.