schubergphilis / awsapilib

A python library exposing services that are not covered by the official boto3 library but are driven by undocumented APIs.
MIT License
60 stars 8 forks source link

Poetry: Invalid requirement (2captcha-python>=1.2.0) found in awsapilib-3.1.3 dependencies, skipping #50

Closed iainelder closed 1 year ago

iainelder commented 1 year ago

Poetry skips the 2captcha dependency when resolving awsapilib's dependencies. It says:

Invalid requirement (2captcha-python>=1.2.0) found in awsapilib-3.1.3 dependencies, skipping

The missing dependency causes the AccountManager class to fail with a ModuleNotFoundError.

I can work around it by adding 2captcha-python to my own project, but I'd rather not.

Here's a full repro in an empty directory.

$ poetry --version
Poetry (version 1.4.0)

$ poetry new .
Created package tmp.2023_05_18.kwpr1amm in .

$ poetry add awsapilib
Creating virtualenv tmp-2023-05-18-kwpr1amm-Kw2CPZUK-py3.8 in /home/isme/.cache/pypoetry/virtualenvs
Using version ^3.1.3 for awsapilib

Updating dependencies
Resolving dependencies... (0.0s)Invalid requirement (2captcha-python>=1.2.0) found in awsapilib-3.1.3 dependencies, skipping
Resolving dependencies... (4.4s)

Writing lock file

Package operations: 19 installs, 0 updates, 0 removals

  • Installing six (1.16.0)
  • Installing jmespath (1.0.1)
  • Installing python-dateutil (2.8.2)
  • Installing urllib3 (1.26.15)
  • Installing botocore (1.29.135)
  • Installing certifi (2023.5.7)
  • Installing charset-normalizer (3.1.0)
  • Installing idna (3.4)
  • Installing s3transfer (0.6.1)
  • Installing soupsieve (2.4.1)
  • Installing typing-extensions (4.5.0)
  • Installing beautifulsoup4 (4.12.2)
  • Installing boto3 (1.26.135)
  • Installing boto3-type-annotations (0.3.1)
  • Installing cachetools (5.3.0)
  • Installing opnieuw (2.0.0)
  • Installing pyotp (2.8.0)
  • Installing requests (2.30.0)
  • Installing awsapilib (3.1.3)

$ poetry run python -c 'from awsapilib import AccountManager; print("OK")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/isme/.cache/pypoetry/virtualenvs/tmp-2023-05-18-kwpr1amm-Kw2CPZUK-py3.8/lib/python3.8/site-packages/awsapilib/__init__.py", line 40, in <module>
    from .console import AccountManager, PasswordManager
  File "/home/isme/.cache/pypoetry/virtualenvs/tmp-2023-05-18-kwpr1amm-Kw2CPZUK-py3.8/lib/python3.8/site-packages/awsapilib/console/__init__.py", line 35, in <module>
    from .console import AccountManager, PasswordManager
  File "/home/isme/.cache/pypoetry/virtualenvs/tmp-2023-05-18-kwpr1amm-Kw2CPZUK-py3.8/lib/python3.8/site-packages/awsapilib/console/console.py", line 45, in <module>
    from awsapilib.captcha import Solver, Iterm, Terminal
  File "/home/isme/.cache/pypoetry/virtualenvs/tmp-2023-05-18-kwpr1amm-Kw2CPZUK-py3.8/lib/python3.8/site-packages/awsapilib/captcha/__init__.py", line 34, in <module>
    from .captcha import Solver, Iterm, Terminal, Captcha2
  File "/home/isme/.cache/pypoetry/virtualenvs/tmp-2023-05-18-kwpr1amm-Kw2CPZUK-py3.8/lib/python3.8/site-packages/awsapilib/captcha/captcha.py", line 40, in <module>
    from twocaptcha import TwoCaptcha, ValidationException, TimeoutException
ModuleNotFoundError: No module named 'twocaptcha'

$ poetry add 2captcha-python
Using version ^1.2.0 for 2captcha-python

Updating dependencies
Resolving dependencies... (0.0s)Invalid requirement (2captcha-python>=1.2.0) found in awsapilib-3.1.3 dependencies, skipping
Resolving dependencies... (0.1s)

Writing lock file

Package operations: 1 install, 0 updates, 0 removals

  • Installing 2captcha-python (1.2.0)

$ poetry run python -c 'from awsapilib import AccountManager; print("OK")'
OK
iainelder commented 1 year ago

See discussion on this topic in the Poetry forum. I've shared it there to get some insight from the Poetry experts.

costastf commented 1 year ago

Thanks! Interesting bug :)

iainelder commented 1 year ago

It may be a bug in Poetry, but it's not a bug in awsapilib itself, so I'll close this here. To avoid the problem, I think either Poetry has to relax its parsing of PyPI project names, or the 2captcha-python project has to change its name. Poetry doesn't like project names that start with digits.

iainelder commented 1 year ago

awsapilib is now compatible with Poetry.

In python-poetry/poetry-core#607 I fixed it to accept dependency names starting with a number.

Poetry 1.6.0 and Poetry Core 1.7.0 contain my fix.

$ poetry --version
Poetry (version 1.6.1)

$ poetry new .
Created package tmp.2023_08_26.585ougjl in .

$ poetry add awsapilib
Creating virtualenv tmp-2023-08-26-585ougjl-aQHfh3WZ-py3.8 in /home/isme/.cache/pypoetry/virtualenvs
Using version ^3.1.3 for awsapilib

Updating dependencies
Resolving dependencies... Downloading https://files.pythonhosted.org/packages/43/d5/c29cd327cb646791f7b24Resolving dependencies... Downloading https://files.pythonhosted.org/packages/96/7f/9477016e1bfd5b87ce9fcResolving dependencies... (5.0s)

Package operations: 20 installs, 0 updates, 0 removals

  • Installing six (1.16.0)
  • Installing jmespath (1.0.1)
  • Installing python-dateutil (2.8.2)
  • Installing urllib3 (1.26.16)
  • Installing botocore (1.31.35)
  • Installing certifi (2023.7.22)
  • Installing charset-normalizer (3.2.0)
  • Installing idna (3.4)
  • Installing requests (2.31.0)
  • Installing s3transfer (0.6.2)
  • Installing soupsieve (2.4.1)
  • Installing typing-extensions (4.7.1)
  • Installing 2captcha-python (1.2.1)
  • Installing beautifulsoup4 (4.12.2)
  • Installing boto3 (1.28.35)
  • Installing boto3-type-annotations (0.3.1)
  • Installing cachetools (5.3.1)
  • Installing opnieuw (2.0.0)
  • Installing pyotp (2.9.0)
  • Installing awsapilib (3.1.3)

Writing lock file

$ poetry run python -c 'from awsapilib import AccountManager; print("OK")'
OK
costastf commented 1 year ago

Awesome!! 😎