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

Add pkg_resources to UNSAFE_PACKAGES. (bugfix needed for 1.1) #2624

Closed
wants to merge 4 commits into from

Conversation

PetterS
Copy link
Contributor

@PetterS PetterS commented Jul 3, 2020

pkg_resources is part of setuptools. If it is not on this list, --remove-untracked may remove it from the virtualenv, breaking subsequent installation of packages.

@PetterS
Copy link
Contributor Author

PetterS commented Jul 3, 2020

@abn please have a look at this PR.

@finswimmer finswimmer requested a review from a team July 10, 2020 04:01
@PetterS
Copy link
Contributor Author

PetterS commented Jul 12, 2020

Please do not forget about this PR. Needed for 1.1.

@PetterS PetterS changed the title Add pkg_resources to UNSAFE_PACKAGES. Add pkg_resources to UNSAFE_PACKAGES. (bugfix needed for 1.1) Jul 13, 2020
@abn
Copy link
Member

abn commented Jul 13, 2020

@PetterS If we are detecting pkg_resources as an installed package, then there is an issue. Because we expect only setuptools to show up on installed packages, similar to how pip list works.

For what it is worth, I am unable to reproduce the issue.

@PetterS
Copy link
Contributor Author

PetterS commented Jul 16, 2020

@abn It has been removed from my virtualenv at least two times using 1.1a3. After that, installation of other packages fail and the only solution is to delete the virtualenv and start over.

@PetterS
Copy link
Contributor Author

PetterS commented Jul 16, 2020

Reproduces quite easily for me:

$ poetry install --remove-untracked
Creating virtualenv testenv-wETKOq8S-py3.8 in /home/petter/.cache/pypoetry/virtualenvs
Installing dependencies from lock file

Package operations: 22 installs, 0 updates, 1 removal

  • Removing pkg-resources (0.0.0)
  • Installing decorator (4.4.2)
  • Installing ipython-genutils (0.2.0)
  • Installing parso (0.7.0)
  • Installing ptyprocess (0.6.0)
  • Installing pyparsing (2.4.7)
  • Installing six (1.14.0)
  • Installing wcwidth (0.1.9)
  • Installing attrs (19.3.0)
  • Installing backcall (0.1.0): Failed

  EnvCommandError

  Command ['/home/petter/.cache/pypoetry/virtualenvs/testenv-wETKOq8S-py3.8/bin/python', '-m', 'pip', 'install', '--no-deps', '/home/petter/.cache/pypoetry/artifacts/bd/9e/06/91ad63fb068b06d5a00cd3f0e232424bd7000532c6babbfb1e9ce3333f/backcall-0.1.0.tar.gz'] errored with the following return code 1, and output:
  Processing /home/petter/.cache/pypoetry/artifacts/bd/9e/06/91ad63fb068b06d5a00cd3f0e232424bd7000532c6babbfb1e9ce3333f/backcall-0.1.0.tar.gz
      ERROR: Command errored out with exit status 1:
       command: /home/petter/.cache/pypoetry/virtualenvs/testenv-wETKOq8S-py3.8/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-rdqg7x73/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-rdqg7x73/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-req-build-rdqg7x73/pip-egg-info
           cwd: /tmp/pip-req-build-rdqg7x73/
      Complete output (7 lines):
      Traceback (most recent call last):
        File "<string>", line 1, in <module>
        File "/home/petter/.cache/pypoetry/virtualenvs/testenv-wETKOq8S-py3.8/lib/python3.8/site-packages/setuptools/__init__.py", line 18, in <module>
          import setuptools.version
        File "/home/petter/.cache/pypoetry/virtualenvs/testenv-wETKOq8S-py3.8/lib/python3.8/site-packages/setuptools/version.py", line 1, in <module>
          import pkg_resources
      ModuleNotFoundError: No module named 'pkg_resources'
      ----------------------------------------
  ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.


  at /usr/local/lib/python3.8/dist-packages/poetry/utils/env.py:937 in _run
       933│                 output = subprocess.check_output(
       934│                     cmd, stderr=subprocess.STDOUT, **kwargs
       935│                 )
       936│         except CalledProcessError as e:
    →  937│             raise EnvCommandError(e, input=input_)
       938│
       939│         return decode(output)
       940│
       941│     def execute(self, bin, *args, **kwargs):

  • Installing jedi (0.17.0)
  • Installing more-itertools (8.2.0)
  • Installing packaging (20.3)
  • Installing pexpect (4.8.0)
  • Installing pickleshare (0.7.5)
  • Installing pluggy (0.13.1)
  • Installing prompt-toolkit (3.0.3)
  • Installing py (1.8.1)
  • Installing pygments (2.6.1)
  • Installing traitlets (4.3.3)

pyproject.toml:

[tool.poetry]
name = "testenv"
version = "0.1.0"
description = ""
authors = ["Petter"]

[tool.poetry.dependencies]
python = "^3.6"
pytest = "^5.4.2"
quickjs = "^1.12.0"
ipython = "^7.14.0"

[tool.poetry.dev-dependencies]

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

@abn
Copy link
Member

abn commented Jul 16, 2020

@PetterS thanks for the reproducer. Based on your output, I think there is something wrong with how we detect installed packages. Also, note version 0.0.0. Since pkg_resources is part of setup tools, it should not have shown up in the list of installed packages.

@PetterS
Copy link
Contributor Author

PetterS commented Jul 16, 2020

Merge this PR as a work-around? In any case, I filed an issue as well for further discusssion.

@abn
Copy link
Member

abn commented Jul 16, 2020

@PetterS I don't think this is the right solution. And if this is indeed an issue, we need to fix the issue prior to 1.1.0 GA.

I tried your pyproject.toml file. But was unable to reproduce the issue. Would be good to get more information about the environment.

$ poetry install --remove-untracked
Installing dependencies from lock file

No dependencies to install or update
$ ls .venv/lib/python3.8/site-packages/pkg_resources/
extern  __init__.py  py31compat.py  __pycache__  _vendor
$ poetry debug info

Poetry
Version: 1.1.0a3
Python:  3.8.3

Virtualenv
Python:         3.8.3
Implementation: CPython
Path:           /path/to/project/.venv
Valid:          True

System
Platform: linux
OS:       posix
Python:   /usr

In your case, this could be to do somehow with the virtual environment setup. Happy to help narrow this down on Discord.

@PetterS
Copy link
Contributor Author

PetterS commented Jul 17, 2020

$ poetry debug info

Poetry
Version: 1.1.0a3
Python:  3.8.2

Virtualenv
Python:         3.8.2
Implementation: CPython
Path:           /home/petter/.cache/pypoetry/virtualenvs/testenv-wETKOq8S-py3.8
Valid:          True

System
Platform: linux
OS:       posix
Python:   /usr

@PetterS
Copy link
Contributor Author

PetterS commented Jul 17, 2020

Let's close this PR and keep the discussion in the issue.

@PetterS PetterS closed this Jul 17, 2020
Copy link

github-actions bot commented Mar 1, 2024

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants