sdispater / clikit

CliKit is a group of utilities to build beautiful and testable command line interfaces.
MIT License
72 stars 17 forks source link

clikit no longer seems to work on Python 3.5 #7

Closed reversefold closed 4 years ago

reversefold commented 4 years ago

I am working on a build for a project which must run on Python 3.5.2 and which uses poetry. It ran fine locally on Python 3.6 during development but when I sent the build out to our build machines it failed with this:

00:01:11.438 2019-10-04 15:35:36,841 INFO: > poetry install
00:01:11.476 Traceback (most recent call last):
00:01:11.476   File "_venv/bin/poetry", line 6, in <module>
00:01:11.476     from poetry.console import main
00:01:11.476   File "/shn/builder/workspace/build-ekg-trunk/_venv/lib/python3.5/site-packages/poetry/console/__init__.py", line 1, in <module>
00:01:11.476     from .application import Application
00:01:11.476   File "/shn/builder/workspace/build-ekg-trunk/_venv/lib/python3.5/site-packages/poetry/console/application.py", line 3, in <module>
00:01:11.476     from cleo import Application as BaseApplication
00:01:11.476   File "/shn/builder/workspace/build-ekg-trunk/_venv/lib/python3.5/site-packages/cleo/__init__.py", line 3, in <module>
00:01:11.476     from .application import Application
00:01:11.476   File "/shn/builder/workspace/build-ekg-trunk/_venv/lib/python3.5/site-packages/cleo/application.py", line 4, in <module>
00:01:11.476     from clikit.console_application import ConsoleApplication
00:01:11.476   File "/shn/builder/workspace/build-ekg-trunk/_venv/lib/python3.5/site-packages/clikit/__init__.py", line 1, in <module>
00:01:11.476     from .api.config.application_config import ApplicationConfig
00:01:11.476   File "/shn/builder/workspace/build-ekg-trunk/_venv/lib/python3.5/site-packages/clikit/api/config/__init__.py", line 1, in <module>
00:01:11.476     from .application_config import ApplicationConfig
00:01:11.476   File "/shn/builder/workspace/build-ekg-trunk/_venv/lib/python3.5/site-packages/clikit/api/config/application_config.py", line 6, in <module>
00:01:11.476     from typing import ContextManager
00:01:11.476 ImportError: cannot import name 'ContextManager'

I've been digging around and noticed that this line was added in 9b0e11e0863c9ed10bff743436ce405add0b6121. However, clikit's pyproject.tomp also has this dependency:

typing = { version = "^3.6", python = "~2.7 || ~3.4" }

Despite that dependency there is no typing module installed on Python 3.5, and this seems correct since Python 3.5 has the typing module built-in.

The build is running on Ubuntu 16.04 (xenial) with Python 3.5.2.

root@87176139d6bb:/# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.6 LTS
Release:        16.04
Codename:       xenial
root@87176139d6bb:/# apt-cache policy python3.5
python3.5:
  Installed: 3.5.2-2ubuntu0~16.04.8
  Candidate: 3.5.2-2ubuntu0~16.04.8
  Version table:
 *** 3.5.2-2ubuntu0~16.04.8 500
        500 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages
        100 /var/lib/dpkg/status
     3.5.1-10 500
        500 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages

In trying things locally with pyenv I found out that while Python 3.5.2 doesn't have typing.ContextManager Python 3.5.7 does, which means that the Python docs are either incorrect or confusing as it says that this was introduced in Python 3.6.

I've also tried installing the 'typing' package in a Python 3.5.2 virtualenv and typing.ContextManager is still not present.

reversefold commented 4 years ago

I'm having the same problem with typing.NoReturn:

00:01:07.913 Traceback (most recent call last):
00:01:07.913   File "_venv/bin/poetry", line 6, in <module>
00:01:07.913     from poetry.console import main
00:01:07.913   File "/shn/builder/workspace/build-ekg-trunk/_venv/lib/python3.5/site-packages/poetry/console/__init__.py", line 1, in <module>
00:01:07.913     from .application import Application
00:01:07.913   File "/shn/builder/workspace/build-ekg-trunk/_venv/lib/python3.5/site-packages/poetry/console/application.py", line 7, in <module>
00:01:07.913     from .commands import AboutCommand
00:01:07.913   File "/shn/builder/workspace/build-ekg-trunk/_venv/lib/python3.5/site-packages/poetry/console/commands/__init__.py", line 2, in <module>
00:01:07.913     from .add import AddCommand
00:01:07.913   File "/shn/builder/workspace/build-ekg-trunk/_venv/lib/python3.5/site-packages/poetry/console/commands/add.py", line 4, in <module>
00:01:07.913     from .init import InitCommand
00:01:07.913   File "/shn/builder/workspace/build-ekg-trunk/_venv/lib/python3.5/site-packages/poetry/console/commands/init.py", line 18, in <module>
00:01:07.913     from poetry.utils.helpers import temporary_directory
00:01:07.913   File "/shn/builder/workspace/build-ekg-trunk/_venv/lib/python3.5/site-packages/poetry/utils/helpers.py", line 10, in <module>
00:01:07.913     from typing import NoReturn
00:01:07.913 ImportError: cannot import name 'NoReturn'

According to the Python docs NoReturn was introduced in Python 3.6.5.

reversefold commented 4 years ago

Ah, the NoReturn traceback is in poetry code, I'll open a ticket there as well.