Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python bindings: Missing importlib_resources dependency #7041

Closed
tyilo opened this issue Dec 5, 2023 · 7 comments
Closed

Python bindings: Missing importlib_resources dependency #7041

tyilo opened this issue Dec 5, 2023 · 7 comments

Comments

@tyilo
Copy link
Contributor

tyilo commented Dec 5, 2023

The newest version of z3-solver on PyPI (v4.12.3.0) is requires the dependency importlib_resources, but it is not specified as a dependency.

Thus the z3 bindings for Python isn't working out of the box:

$ mkdir /tmp/z3-test
$ cd /tmp/z3-test
$ python -mvenv venv
$ venv/bin/pip install z3-solver
$ venv/bin/python -c 'import z3; print(z3)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/z3-test/venv/lib/python3.11/site-packages/z3/__init__.py", line 1, in <module>
    from .z3 import *
  File "/tmp/z3-test/venv/lib/python3.11/site-packages/z3/z3.py", line 46, in <module>
    from . import z3core
  File "/tmp/z3-test/venv/lib/python3.11/site-packages/z3/z3core.py", line 7, in <module>
    import importlib_resources
ModuleNotFoundError: No module named 'importlib_resources'

Installing the importlib_resources dependency manually fixes the problem:

$ venv/bin/pip install importlib_resources
$ venv/bin/python -c 'import z3; print(z3)'
<module 'z3' from '/tmp/z3-test/venv/lib/python3.11/site-packages/z3/__init__.py'>
@NikolajBjorner
Copy link
Contributor

Python 3.9 and up now use the built-in version thanks to #7042

@youchangkim
Copy link

@NikolajBjorner Is z3-4.12.3 only supporting python 3.9 and above? If so, we need python_requires so that old python versions don't pick up v4.12.3. If not, we need importlib_resources in install_requires to prevent ModuleNotFoundError on old python versions.

@NikolajBjorner
Copy link
Contributor

what is the location to add install_requires?

@youchangkim
Copy link

If you use setup.py to build the wheels, you can add install_requires in the setup function.
https://setuptools.pypa.io/en/latest/userguide/dependency_management.html

@NikolajBjorner
Copy link
Contributor

so pyproject.toml

[build-system]
requires = ["setuptools>=46.4.0", "wheel", "cmake"]
build-backend = "setuptools.build_meta"

becomes

[build-system]
requires = ["setuptools>=46.4.0", "wheel", "cmake", "importlib_resources"]
build-backend = "setuptools.build_meta"

?

@youchangkim
Copy link

youchangkim commented Dec 8, 2023

I'm not super familiar with pyproject.toml, but it should go under [project].

[project]
dependencies = [
    "importlib-resources",
]

NikolajBjorner added a commit that referenced this issue Dec 8, 2023
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
NikolajBjorner added a commit that referenced this issue Dec 14, 2023
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
@whyitfor
Copy link

whyitfor commented Dec 21, 2023

What release fixes this issue? I'm asking because 4.12.4.0 does not appear to fix it.

Would be helpful to know if 4.12.5.0 fixes this and when it will be released. We're using Python3.7 and z3-solver is a dependency of a dependency. If a fix is imminent we would wait for it, otherwise we will have to address this in our package.

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

No branches or pull requests

4 participants