Poetry: python 2.7 poetry-add failure

Created on 13 Sep 2019  路  4Comments  路  Source: python-poetry/poetry

  • [x] I am on the latest Poetry version.
  • [x] I have searched the issues of this repo and believe that this is not a duplicate.
  • [x] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

versions

$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.3 LTS"

$ poetry --version
Poetry 0.12.17

$ python --version
Python 2.7.15

pyproject.toml

# pyproject.toml 
[tool.poetry]
name = "tmp-project"
version = "0.1.0"
description = ""
authors = ["Darren Weber <[email protected]>"]

[tool.poetry.dependencies]
python = "^2.7"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

Issue

$ poetry -vvv add semver
/home/joe/.poetry/lib/poetry/_vendor/py2.7/subprocess32.py:149: RuntimeWarning: The _posixsubprocess module is not being used. Child process reliability may suffer if your program uses threads.
  "program uses threads.", RuntimeWarning)

[EnvCommandError]                                                                                                            
Command ['/home/joe/.cache/pypoetry/virtualenvs/tmp-project-py2.7/bin/python', '-'] errored with the following return code 1, and output:   
Traceback (most recent call last):                                                                                                        
  File "<stdin>", line 26, in <module>                                                                                                    
  File "/home/joe/miniconda3/envs/py2.7/lib/python2.7/platform.py", line 1470, in python_version                                      
    return _sys_version()[1]                                                                                                              
  File "/home/joe/miniconda3/envs/py2.7/lib/python2.7/platform.py", line 1422, in _sys_version                                        
    repr(sys_version))                                                                                                                    
ValueError: failed to parse CPython sys.version: '2.7.15+ (default, Jul  9 2019, 16:51:35) \n[GCC 7.4.0]'                                 
input was : import json                                                                                                                   
import os                                                                                                                                 
import platform                                                                                                                           
import sys                                                                                                                                
if hasattr(sys, "implementation"):                                                                                                        
    info = sys.implementation.version                                                                                                     
    iver = "{0.major}.{0.minor}.{0.micro}".format(info)                                                                                   
    kind = info.releaselevel                                                                                                              
    if kind != "final":                                                                                                                   
        iver += kind[0] + str(info.serial)                                                                                                
    implementation_name = sys.implementation.name                                                                                         
else:                                                                                                                                     
    iver = "0"                                                                                                                            
    implementation_name = ""                                                                                                              
env = {                                                                                                                                   
    "implementation_name": implementation_name,                                                                                           
    "implementation_version": iver,                                                                                                       
    "os_name": os.name,                                                                                                                   
    "platform_machine": platform.machine(),                                                                                               
    "platform_release": platform.release(),                                                                                               
    "platform_system": platform.system(),                                                                                                 
    "platform_version": platform.version(),                                                                                               
    "python_full_version": platform.python_version(),                                                                                     
    "platform_python_implementation": platform.python_implementation(),                                                                   
    "python_version": platform.python_version()[:3],                                                                                      
    "sys_platform": sys.platform,                                                                                                         
    "version_info": tuple(sys.version_info),                                                                                              
}                                                                                                                                         
print(json.dumps(env))

Exception trace:
 /home/joe/.poetry/lib/poetry/_vendor/py2.7/cleo/application.py in run() at line 94
   status_code = self.do_run(input_, output_)
 /home/joe/.poetry/lib/poetry/console/application.py in do_run() at line 88
   return super(Application, self).do_run(i, o)
 /home/joe/.poetry/lib/poetry/_vendor/py2.7/cleo/application.py in do_run() at line 197
   status_code = command.run(input_, output_)
 /home/joe/.poetry/lib/poetry/console/commands/command.py in run() at line 77
   return super(BaseCommand, self).run(i, o)
 /home/joe/.poetry/lib/poetry/_vendor/py2.7/cleo/commands/base_command.py in run() at line 136
   self.initialize(input_, output_)
 /home/joe/.poetry/lib/poetry/console/commands/env_command.py in initialize() at line 21
   ".".join(str(v) for v in current_env.version_info[:3])
 /home/joe/.poetry/lib/poetry/utils/env.py in version_info() at line 135
   return tuple(self.marker_env["version_info"])
 /home/joe/.poetry/lib/poetry/utils/env.py in marker_env() at line 151
   self._marker_env = self.get_marker_env()
 /home/joe/.poetry/lib/poetry/utils/env.py in get_marker_env() at line 494
   output = self.run("python", "-", input_=GET_ENVIRONMENT_INFO)
 /home/joe/.poetry/lib/poetry/utils/env.py in run() at line 539
   return super(VirtualEnv, self).run(bin, *args, **kwargs)
 /home/joe/.poetry/lib/poetry/utils/env.py in run() at line 388
   raise EnvCommandError(e, input=input_)

add [-D|--dev] [--git GIT] [--path PATH] [-E|--extras EXTRAS] [--optional] [--python PYTHON] [--platform PLATFORM] [--allow-prereleases] [--dry-run] [--] <name> (<name>)...

Bug

Most helpful comment

this problem still exists

All 4 comments

Based on code in master at and py2.7 docs

$ python
Python 2.7.15 | packaged by conda-forge | (default, Jul  2 2019, 00:39:44) 
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> import platform
>>> hasattr(sys, "implementation")
False
>>> GET_ENVIRONMENT_INFO = """\
... import json
... import os
... import platform
... import sys
... if hasattr(sys, "implementation"):
...     info = sys.implementation.version
...     iver = "{0.major}.{0.minor}.{0.micro}".format(info)
...     kind = info.releaselevel
...     if kind != "final":
...         iver += kind[0] + str(info.serial)
...     implementation_name = sys.implementation.name
... else:
...     iver = "0"
...     implementation_name = ""
... env = {
...     "implementation_name": implementation_name,
...     "implementation_version": iver,
...     "os_name": os.name,
...     "platform_machine": platform.machine(),
...     "platform_release": platform.release(),
...     "platform_system": platform.system(),
...     "platform_version": platform.version(),
...     "python_full_version": platform.python_version(),
...     "platform_python_implementation": platform.python_implementation(),
...     "python_version": platform.python_version()[:3],
...     "sys_platform": sys.platform,
...     "version_info": tuple(sys.version_info),
... }
... print(json.dumps(env))
... """
>>> 
>>> import subprocess
>>> input_ = GET_ENVIRONMENT_INFO
>>> cmd = ["python", "-"]
>>> output = subprocess.run(
...                     cmd,
...                     stdout=subprocess.PIPE,
...                     stderr=subprocess.STDOUT,
...                     input=encode(input_),
...                     check=True,
...                     **kwargs
...                 ).stdout
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'run'

OK, so how about this (continued in python repl as above):

>>> cmd = ["python", "-c", input_]
>>> subprocess.check_output(cmd)
'{"os_name": "posix", "python_version": "2.7", "version_info": [2, 7, 15, "final", 0], "platform_system": "Linux", "platform_release": "4.15.0-62-generic", "implementation_version": "0", "python_full_version": "2.7.15", "implementation_name": "", "platform_python_implementation": "CPython", "platform_machine": "x86_64", "sys_platform": "linux2", "platform_version": "#69-Ubuntu SMP Wed Sep 4 20:55:53 UTC 2019"}\n'

I think the root problem is poetry vendorizes packages which aren't python-only. This causes pre-built code to not run properly on machines which otherwise would have installed/built it themselves.

so in short you can't reliably count on the curl installation method to work

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

this problem still exists

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nikaro picture nikaro  路  3Comments

alexlatchford picture alexlatchford  路  3Comments

Euphorbium picture Euphorbium  路  3Comments

etijskens picture etijskens  路  3Comments

jbarlow83 picture jbarlow83  路  3Comments