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 3.12 support #4011

Closed
josecastillolema opened this issue Nov 15, 2023 · 4 comments · Fixed by #4018
Closed

Python 3.12 support #4011

josecastillolema opened this issue Nov 15, 2023 · 4 comments · Fixed by #4018

Comments

@josecastillolema
Copy link
Contributor

josecastillolema commented Nov 15, 2023

Python 3.12 has dropped the imp module:

$ python --version
Python 3.12.0

$ ./kind.sh --install-cni-plugins --disable-snat-multiple-gws --multi-network-enable
...
+ kind_local_registry_port=5000
+ kind_local_registry_name=kind-registry
+ j2 /home/jose/dev/ovn-kubernetes/contrib/kind.yaml.j2 -o /home/jose/dev/ovn-kubernetes/contrib/kind-ovn.yaml
Traceback (most recent call last):
  File "/home/jose/.local/bin/j2", line 5, in <module>
    from j2cli import main
  File "/home/jose/.local/lib/python3.12/site-packages/j2cli/__init__.py", line 10, in <module>
    from j2cli.cli import main
  File "/home/jose/.local/lib/python3.12/site-packages/j2cli/cli.py", line 8, in <module>
    import imp, inspect
ModuleNotFoundError: No module named 'imp'

Code has to migrate to from imp to importlib

@josecastillolema
Copy link
Contributor Author

python/cpython#104212

@josecastillolema
Copy link
Contributor Author

josecastillolema commented Nov 15, 2023

It looks that the problem comes from the j2 pip dependency: kolypto/j2cli#80

@josecastillolema
Copy link
Contributor Author

Looks like the solution is moving to Jinjanator

@skitt
Copy link
Contributor

skitt commented Nov 17, 2023

In Submariner we handled this by switching to python3-jinja2-cli with a small wrapper (which could be avoided by changing the invocations to pipe the values instead of setting them in the environment). That’s https://pypi.org/project/jinja2-cli/ from which j2cli was derived. Now the original is maintained, j2cli isn’t, and jinjanator was created to fix j2cli!

The advantage of python3-jinja2-cli is that it’s packaged for Fedora, which makes it easy to install; pip on current Debian, Ubuntu, and Fedora distributions requires using virtual environments.

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

Successfully merging a pull request may close this issue.

2 participants