batou icon indicating copy to clipboard operation
batou copied to clipboard

Ensure Python 3.10 support

Open jugmac00 opened this issue 3 years ago • 2 comments

./batou deploy staging
...
Traceback (most recent call last):
  File "/home/jugmac00/Projects/apisweb.batou/.batou/unclean/bin/batou", line 33, in <module>
    sys.exit(load_entry_point('batou==2.2.2', 'console_scripts', 'batou')())
  File "/home/jugmac00/Projects/apisweb.batou/.batou/unclean/lib/python3.10/site-packages/batou/main.py", line 149, in main
    args.func(**func_args)
  File "/home/jugmac00/Projects/apisweb.batou/.batou/unclean/lib/python3.10/site-packages/batou/deploy.py", line 268, in main
    notify("{} SUCCEEDED".format(ACTION), environment)
  File "/home/jugmac00/Projects/apisweb.batou/.batou/unclean/lib/python3.10/site-packages/batou/utils.py", line 70, in notify_send
    subprocess.call(["notify-send", title, description])
  File "/usr/lib/python3.10/subprocess.py", line 345, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/lib/python3.10/subprocess.py", line 965, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.10/subprocess.py", line 1774, in _execute_child
    self.pid = _posixsubprocess.fork_exec(
TypeError: expected str, bytes or os.PathLike object, not Environment

Deployment was successful (green), but an error message was printed afterwards.

jugmac00 avatar Apr 27 '21 14:04 jugmac00

I think that this has been fixed already, but I actually can't test Python 3.10 at the moment because there's breakage with requests/urllib3 and an outdated vendored version of six:

https://github.com/urllib3/urllib3/issues/2238

I'll keep this open on a branch though.

ctheune avatar May 21 '21 11:05 ctheune

I tried to reproduce #116, but failed to setup batou on Python 3.10 for another reason:

❯ curl -sL https://raw.githubusercontent.com/flyingcircusio/batou/master/bootstrap | sh
Update lockfile with with /usr/bin/python3.10.
If you want to use a different version, set it as via
 `# appenv-python-preference:` in requirements.txt.
Updating lockfile
Creating venv ...
/tmp/venv/./appenv:76: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
  import distutils.util  # noqa: F401 imported but unused
Ensuring pip ...
Installing packages ...
Traceback (most recent call last):
  File "/tmp/venv/./appenv", line 500, in <module>
    main()
  File "/tmp/venv/./appenv", line 492, in main
    appenv.meta()
  File "/tmp/venv/./appenv", line 280, in meta
    args.func(args, remaining)
  File "/tmp/venv/./appenv", line 431, in update_lockfile
    import pkg_resources
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 77, in <module>
    __import__('pkg_resources.extern.packaging.requirements')
  File "/usr/lib/python3/dist-packages/pkg_resources/_vendor/packaging/requirements.py", line 9, in <module>
    from pkg_resources.extern.pyparsing import stringStart, stringEnd, originalTextFor, ParseException
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 672, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 632, in _load_backward_compatible
  File "/usr/lib/python3/dist-packages/pkg_resources/extern/__init__.py", line 43, in load_module
    __import__(extant)
  File "/usr/lib/python3/dist-packages/pkg_resources/_vendor/pyparsing.py", line 943, in <module>
    collections.MutableMapping.register(ParseResults)
AttributeError: module 'collections' has no attribute 'MutableMapping'

From Python 3.10 onwards you need to import MutableMapping from collections.abc. https://docs.python.org/3/library/collections.html#module-collections

jugmac00 avatar Aug 19 '21 12:08 jugmac00

For what it's worth, after upgrading existing deployments with ./batou appenv-update-lockfile just now, it works fine with even python-3.11 for me.

wosc avatar Aug 30 '23 09:08 wosc

Yeah, I think we're past this.

ctheune avatar Nov 22 '23 16:11 ctheune