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

1.0.10 -> 1.1 regression: EnvCommandError: 'No module named setuptools' on Python 3.7 #3153

Closed
gitpushdashf opened this issue Oct 8, 2020 · 42 comments

Comments

@gitpushdashf
Copy link

This may because it's installing a nested package. Python 3.8 doesn't have this issue but 3.7 does. I don't have a reduced test case yet. I'm hoping the traceback is helpful and someone knows what's going on from it. Python 3.7 and 3.8 are fine with Poetry 1.0.10, everything else being identical. Python 3.8 with Poetry 1.1.2 is fine as well, just not Python 3.7 with Poetry 1.1.2.

 EnvCommandError
  Command ['/usr/local/bin/python', '-m', 'pip', 'install', '--no-deps', '-U', '/builds/[redacted]'] errored with the following return code 2, and output: 
  Looking in indexes: https://[redacted]
  Processing ./packages/[redacted]
    Installing build dependencies: started
    Installing build dependencies: finished with status 'done'
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'done'
  ERROR: Exception:
  Traceback (most recent call last):
    File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 216, in _main
      status = self.run(options, args)
    File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 182, in wrapper
      return func(self, options, args)
    File "/usr/local/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 325, in run
      reqs, check_supported_wheels=not options.target_dir
    File "/usr/local/lib/python3.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 183, in resolve
      discovered_reqs.extend(self._resolve_one(requirement_set, req))
    File "/usr/local/lib/python3.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 388, in _resolve_one
      abstract_dist = self._get_abstract_dist_for(req_to_install)
    File "/usr/local/lib/python3.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 340, in _get_abstract_dist_for
      abstract_dist = self.preparer.prepare_linked_requirement(req)
    File "/usr/local/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 483, in prepare_linked_requirement
      req, self.req_tracker, self.finder, self.build_isolation,
    File "/usr/local/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 91, in _get_prepared_distribution
      abstract_dist.prepare_distribution_metadata(finder, build_isolation)
    File "/usr/local/lib/python3.7/site-packages/pip/_internal/distributions/sdist.py", line 38, in prepare_distribution_metadata
      self._setup_isolation(finder)
    File "/usr/local/lib/python3.7/site-packages/pip/_internal/distributions/sdist.py", line 96, in _setup_isolation
      reqs = backend.get_requires_for_build_wheel()
    File "/usr/local/lib/python3.7/site-packages/pip/_vendor/pep517/wrappers.py", line 161, in get_requires_for_build_wheel
      'config_settings': config_settings
    File "/usr/local/lib/python3.7/site-packages/pip/_vendor/pep517/wrappers.py", line 265, in _call_hook
      raise BackendUnavailable(data.get('traceback', ''))
  pip._vendor.pep517.wrappers.BackendUnavailable: Traceback (most recent call last):
    File "/usr/local/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 86, in _build_backend
      obj = import_module(mod_path)
    File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
    File "<frozen importlib._bootstrap>", line 983, in _find_and_load
    File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
    File "<frozen importlib._bootstrap_external>", line 728, in exec_module
    File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
    File "/tmp/pip-build-env-l4t_85ci/overlay/lib/python3.7/site-packages/poetry/masonry/api.py", line 1, in <module>
      from poetry.core.masonry.api import build_sdist
    File "/tmp/pip-build-env-l4t_85ci/overlay/lib/python3.7/site-packages/poetry/core/masonry/__init__.py", line 10, in <module>
      from .builder import Builder
    File "/tmp/pip-build-env-l4t_85ci/overlay/lib/python3.7/site-packages/poetry/core/masonry/builder.py", line 6, in <module>
      from .builders.sdist import SdistBuilder
    File "/tmp/pip-build-env-l4t_85ci/overlay/lib/python3.7/site-packages/poetry/core/masonry/builders/__init__.py", line 2, in <module>
      from .wheel import WheelBuilder
    File "/tmp/pip-build-env-l4t_85ci/overlay/lib/python3.7/site-packages/poetry/core/masonry/builders/wheel.py", line 18, in <module>
      from packaging.tags import sys_tags
    File "/tmp/pip-build-env-l4t_85ci/overlay/lib/python3.7/site-packages/poetry/core/_vendor/packaging/tags.py", line 7, in <module>
      import distutils.util
    File "/usr/local/lib/python3.7/site-packages/_distutils_hack/__init__.py", line 83, in create_module
      return importlib.import_module('._distutils', 'setuptools')
    File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
  ModuleNotFoundError: No module named 'setuptools'
@gitpushdashf gitpushdashf added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Oct 8, 2020
@abn
Copy link
Member

abn commented Oct 9, 2020

@gitpushdashf looks like this is an issue with the version of pip installed with your 3.7 installation. Looks like you are installing without a virtual environment. If this is the case, first try after perorming /usr/local/bin/python -m pip install -U pip.

Command ['/usr/local/bin/python', '-m', 'pip', 'install', '--no-deps', '-U', '/builds/[redacted]'] errored with the following return code 2, and output: 

Another possibility is, if you are using an Ubuntu distro, the distutils version installed might be interfering with your install.

@gitpushdashf
Copy link
Author

Thanks for replying!

This is using the python:3.7 and python3.8 Docker images which I believe are Debian based. With that image should I be doing python3 -m pip install or is pip3 install okay?

@abn
Copy link
Member

abn commented Oct 9, 2020

@gitpushdashf fwiw; I cannot reproduce this in a container, any chance you can provide some steps to reproduce this? Typically the containers should have python pointing to the tag version and pip pointing to the corresponding pip version. The use of python3.7 -m pip is more done for safety and portability.

$ podman run --rm -i --entrypoint bash python:3.7 -c 'pip --version'
pip 20.2.3 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)

@abn
Copy link
Member

abn commented Oct 9, 2020

Also this indicates you are using the old build-system configuration in your dependency project.

    File "/tmp/pip-build-env-l4t_85ci/overlay/lib/python3.7/site-packages/poetry/masonry/api.py", line 1, in <module>
      from poetry.core.masonry.api import build_sdist

I would recommend you try moving to the standalone build backend.

@jonapich
Copy link
Contributor

jonapich commented Oct 16, 2020

I am also getting this error and I can reproduce it.

https://github.com/jonapich/test-poetry-setuptools

Clone that repo, and try "poetry install" in the test-functools folder, you will get the same stacktrace as in the bug report.

This seems pretty serious 🤔

I'm on 1.1.3, Windows, using powershell. I installed using the get-poetry bootstrap.

I have confirmed that this bug appears when going from 1.0.10 -> 1.1 and it was also working in 1.0.9

Also, I never used python 3.7; only 3.6 and 3.8.

@guhcampos
Copy link

guhcampos commented Oct 19, 2020

I can confirm this is a problem and affects anything that ultimately still depends on calling python setup.py, such as:

  • installing a poetry powered package with pip install -e
  • using a local package in pyproject.toml like @jonapich demonstrates with test-testing = { path = "../test-testing/" }

I can confirm the problem with Python 3.6, 3.7 and 3.8 alike.

And this is really hard to debug because even if you literally copy and paste the command it's trying to run, it just works, in my case for a sample package:

[EnvCommandError]
Command ['/home/gustavo/.cache/pypoetry/virtualenvs/package-94uOVQQp-py3.8/bin/pip', 'install', '--no-deps', '-U', '-e', '/home/gustavo/my-package/package/../packb'] errored with the following return code 1, and output: 
Looking in indexes: https://pypi.org/simple, Obtaining file:///home/gustavo/my-package/packb
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
    Preparing wheel metadata: started
    Preparing wheel metadata: finished with status 'done'
Installing collected packages: packb
  Running setup.py develop for packb
    ERROR: Command errored out with exit status 1:
     command: /home/gustavo/.cache/pypoetry/virtualenvs/package-94uOVQQp-py3.8/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/gustavo/my-package/packb/setup.py'"'"'; __file__='"'"'/home/gustavo/my-package/packb/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps
         cwd: /home/gustavo/my-package/packb/
    Complete output (3 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ModuleNotFoundError: No module named 'setuptools'
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/gustavo/.cache/pypoetry/virtualenvs/package-94uOVQQp-py3.8/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/gustavo/my-package/packb/setup.py'"'"'; __file__='"'"'/home/gustavo/my-package/packb/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps Check the logs for full command output.

But if I simply copy and paste the command below, it runs ok:

○ → /home/gustavo/.cache/pypoetry/virtualenvs/package-94uOVQQp-py3.8/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/gustavo/my-package/packb/setup.py'"'"'; __file__='"'"'/home/gustavo/my-package/packb/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps
running develop
running egg_info
creating packb.egg-info
writing packb.egg-info/PKG-INFO
writing dependency_links to packb.egg-info/dependency_links.txt
writing top-level names to packb.egg-info/top_level.txt
writing manifest file 'packb.egg-info/SOURCES.txt'
reading manifest file 'packb.egg-info/SOURCES.txt'
writing manifest file 'packb.egg-info/SOURCES.txt'
running build_ext
Creating /home/gustavo/.cache/pypoetry/virtualenvs/package-94uOVQQp-py3.8/lib/python3.8/site-packages/packb.egg-link (link to .)
Adding packb 0.0.0 to easy-install.pth file

Installed /home/gustavo/my-package/package

To make this "work" I had to install bogus setup.py files to my packages, such as:

from setuptools import setup
setup(name="packb")

Yet it still fails when running from within poetry.

@abn
Copy link
Member

abn commented Oct 19, 2020

@jonapich based on your description I have attempted to recreate the scenario (minus the windows environment). Let me know what needs to be changed to reproduce the issue.

podman run --rm -i --entrypoint bash python:3.8 <<EOF
set -ex
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python - --version 1.0.10
source ~/.poetry/env
poetry --version
git clone https://github.com/jonapich/test-poetry-setuptools.git
pushd test-poetry-setuptools/test-functools/
poetry lock
poetry install
poetry self update
poetry install
rm -rf \$(poetry env info -p)
poetry --version
poetry install
rm -rf \$(poetry env info -p)
git checkout poetry.lock
poetry install
EOF
Console Output

+ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py
+ python - --version 1.0.10
Retrieving Poetry metadata

# Welcome to Poetry!

This will download and install the latest version of Poetry,
a dependency and package manager for Python.

It will add the `poetry` command to Poetry's bin directory, located at:

$HOME/.poetry/bin

This path will then be added to your `PATH` environment variable by
modifying the profile file located at:

$HOME/.profile

You can uninstall at any time by executing this script with the --uninstall option,
and these changes will be reverted.

Installing version: 1.0.10
  - Downloading poetry-1.0.10-linux.tar.gz (29.66MB)

Poetry (1.0.10) is installed now. Great!

To get started you need Poetry's bin directory ($HOME/.poetry/bin) in your `PATH`
environment variable. Next time you log in this will be done
automatically.

To configure your current shell run `source $HOME/.poetry/env`

+ source /root/.poetry/env
++ export PATH=/root/.poetry/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ PATH=/root/.poetry/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+ poetry --version
Poetry version 1.0.10
+ git clone https://github.com/jonapich/test-poetry-setuptools.git
Cloning into 'test-poetry-setuptools'...
+ pushd test-poetry-setuptools/test-functools/
/test-poetry-setuptools/test-functools /
+ poetry lock
Creating virtualenv test-functools-HE92XDqH-py3.8 in /root/.cache/pypoetry/virtualenvs
The lock file might not be compatible with the current version of Poetry.
Upgrade Poetry to ensure the lock file is read properly or, alternatively, regenerate the lock file with the `poetry lock` command.
Updating dependencies
Resolving dependencies...

Writing lock file
+ poetry install
Installing dependencies from lock file


Package operations: 15 installs, 0 updates, 0 removals

  - Installing pyparsing (2.4.7)
  - Installing six (1.15.0)
  - Installing attrs (20.2.0)
  - Installing iniconfig (1.1.1)
  - Installing packaging (20.4)
  - Installing pluggy (0.13.1)
  - Installing py (1.9.0)
  - Installing toml (0.10.1)
  - Installing mypy-extensions (0.4.3)
  - Installing pytest (6.1.1)
  - Installing typed-ast (1.4.1)
  - Installing typing-extensions (3.7.4.3)
  - Installing inflection (0.5.1)
  - Installing mypy (0.790)
  - Installing test-testing (0.1.4 ../test-testing)
  - Installing test-functools (0.1.4)
+ poetry self update
Updating to 1.1.3
 - Downloading poetry-1.1.3-linux.tar.gz 0%
 - Downloading poetry-1.1.3-linux.tar.gz 10%
 - Downloading poetry-1.1.3-linux.tar.gz 20%
 - Downloading poetry-1.1.3-linux.tar.gz 30%
 - Downloading poetry-1.1.3-linux.tar.gz 40%
 - Downloading poetry-1.1.3-linux.tar.gz 50%
 - Downloading poetry-1.1.3-linux.tar.gz 60%
 - Downloading poetry-1.1.3-linux.tar.gz 70%
 - Downloading poetry-1.1.3-linux.tar.gz 80%
 - Downloading poetry-1.1.3-linux.tar.gz 90%
 - Downloading poetry-1.1.3-linux.tar.gz 100%

Poetry (1.1.3) is installed now. Great!
+ poetry install
Installing dependencies from lock file

No dependencies to install or update

Installing the current project: test-functools (0.1.4)
++ poetry env info -p
+ rm -rf /root/.cache/pypoetry/virtualenvs/test-functools-HE92XDqH-py3.8
+ poetry --version
Poetry version 1.1.3
+ poetry install
Creating virtualenv test-functools-HE92XDqH-py3.8 in /root/.cache/pypoetry/virtualenvs
Installing dependencies from lock file

Package operations: 15 installs, 0 updates, 0 removals

  • Installing pyparsing (2.4.7)
  • Installing six (1.15.0)
  • Installing attrs (20.2.0)
  • Installing iniconfig (1.1.1)
  • Installing packaging (20.4)
  • Installing pluggy (0.13.1)
  • Installing py (1.9.0)
  • Installing toml (0.10.1)
  • Installing mypy-extensions (0.4.3)
  • Installing pytest (6.1.1)
  • Installing typed-ast (1.4.1)
  • Installing typing-extensions (3.7.4.3)
  • Installing inflection (0.5.1)
  • Installing mypy (0.790)
  • Installing test-testing (0.1.4 /test-poetry-setuptools/test-testing)

Installing the current project: test-functools (0.1.4)
++ poetry env info -p
+ rm -rf /root/.cache/pypoetry/virtualenvs/test-functools-HE92XDqH-py3.8
+ git checkout poetry.lock
+ poetry install
Creating virtualenv test-functools-HE92XDqH-py3.8 in /root/.cache/pypoetry/virtualenvs
Installing dependencies from lock file

Package operations: 15 installs, 0 updates, 0 removals

  • Installing pyparsing (2.4.7)
  • Installing six (1.15.0)
  • Installing attrs (20.2.0)
  • Installing iniconfig (1.1.1)
  • Installing packaging (20.4)
  • Installing pluggy (0.13.1)
  • Installing py (1.9.0)
  • Installing toml (0.10.1)
  • Installing mypy-extensions (0.4.3)
  • Installing pytest (6.1.1)
  • Installing typed-ast (1.4.1)
  • Installing typing-extensions (3.7.4.3)
  • Installing inflection (0.5.1)
  • Installing mypy (0.790)
  • Installing test-testing (0.1.4 /test-poetry-setuptools/test-testing)

Installing the current project: test-functools (0.1.4)

@jonapich
Copy link
Contributor

I was able to make it work on a clean windows 2019 server as well... 🤔 But you need py3.8 or below, because there's no wheels for typed_ast in 3.9 and you'll need to install the vs c++ build tools.

I'll have to investigate what's different on my system.

@jonapich
Copy link
Contributor

jonapich commented Oct 21, 2020

So far, I can still reproduce the issue when going through poetry, but not when going through pip. My issue matches the OP's behavior:

Console Output


❭❭  test-functools  10:04  (Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py -UseBasicParsing).Content | python - --uninstall
# We are sorry to see you go!

This will uninstall Poetry.

It will remove the `poetry` command from Poetry's bin directory, located at:

%USERPROFILE%\.poetry\bin

This will also remove Poetry from your system's PATH.

❭❭  test-functools  10:05  poetry
poetry: The term 'poetry' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Suggestion [4,General]: The most similar commands are: where, popd, copy, gerr, clear, sort, history, set, etsn, Setup.


❭❭  test-functools ✗  10:05  (Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py -UseBasicParsing).Content | py -3.8
Retrieving Poetry metadata

# Welcome to Poetry!

This will download and install the latest version of Poetry,
a dependency and package manager for Python.

It will add the `poetry` command to Poetry's bin directory, located at:

%USERPROFILE%\.poetry\bin

This path will then be added to your `PATH` environment variable by
modifying the `HKEY_CURRENT_USER/Environment/PATH` registry key.

You can uninstall at any time by executing this script with the --uninstall option,
and these changes will be reverted.

Installing version: 1.1.3
  - Downloading poetry-1.1.3-win32.tar.gz (38.81MB)

Poetry (1.1.3) is installed now. Great!

To get started you need Poetry's bin directory (%USERPROFILE%\.poetry\bin) in your `PATH`
environment variable. Future applications will automatically have the
correct environment, but you may need to restart your current shell.


❭❭  test-functools  10:06  poetry --version
Poetry version 1.1.3


❭❭  test-functools ✗  10:06  py -3.8 -c "import sys; print(sys.executable)"
C:\Users\jonapich\AppData\Local\Programs\Python\Python38\python.exe


❭❭  test-functools ✗  10:07  poetry env use C:\Users\jonapich\AppData\Local\Programs\Python\Python38\python.exe
Creating virtualenv test-functools-44VBZfUY-py3.8 in C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs
Using virtualenv: C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8


❭❭  test-functools  10:07  poetry install
Installing dependencies from lock file

Package operations: 17 installs, 0 updates, 0 removals

  • Installing pyparsing (2.4.7)
  • Installing six (1.15.0)
  • Installing atomicwrites (1.4.0)
  • Installing attrs (20.2.0)
  • Installing colorama (0.4.4)
  • Installing iniconfig (1.1.1)
  • Installing packaging (20.4)
  • Installing pluggy (0.13.1)
  • Installing py (1.9.0)
  • Installing toml (0.10.1)
  • Installing mypy-extensions (0.4.3)
  • Installing pytest (6.1.1)
  • Installing typed-ast (1.4.1)
  • Installing typing-extensions (3.7.4.3)
  • Installing inflection (0.5.1)
  • Installing test-testing (0.1.4 C:/Users/jonapich/Documents/workspace/test-poetry/test-testing)
  • Installing mypy (0.790)

  EnvCommandError

  Command C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\Scripts\pip.exe install --no-deps -U C:/Users/jonapich/Documents/workspace/test-poetry/test-testing errored with the following return code 2, and output:
  Processing c:\users\jonapich\documents\workspace\test-poetry\test-testing
    Installing build dependencies: started
    Installing build dependencies: finished with status 'done'
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'done'
  ERROR: Exception:
  Traceback (most recent call last):
    File "C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\lib\site-packages\pip\_internal\cli\base_command.py", line 216, in _main
      status = self.run(options, args)
    File "C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\lib\site-packages\pip\_internal\cli\req_command.py", line 182, in wrapper
      return func(self, options, args)
    File "C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\lib\site-packages\pip\_internal\commands\install.py", line 324, in run
      requirement_set = resolver.resolve(
    File "C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 183, in resolve
      discovered_reqs.extend(self._resolve_one(requirement_set, req))
    File "C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 388, in _resolve_one
      abstract_dist = self._get_abstract_dist_for(req_to_install)
    File "C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 340, in _get_abstract_dist_for
      abstract_dist = self.preparer.prepare_linked_requirement(req)
    File "C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\lib\site-packages\pip\_internal\operations\prepare.py", line 482, in prepare_linked_requirement
      abstract_dist = _get_prepared_distribution(
    File "C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\lib\site-packages\pip\_internal\operations\prepare.py", line 91, in _get_prepared_distribution
      abstract_dist.prepare_distribution_metadata(finder, build_isolation)
    File "C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\lib\site-packages\pip\_internal\distributions\sdist.py", line 38, in prepare_distribution_metadata
      self._setup_isolation(finder)
    File "C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\lib\site-packages\pip\_internal\distributions\sdist.py", line 96, in _setup_isolation
      reqs = backend.get_requires_for_build_wheel()
    File "C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\lib\site-packages\pip\_vendor\pep517\wrappers.py", line 160, in get_requires_for_build_wheel
      return self._call_hook('get_requires_for_build_wheel', {
    File "C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\lib\site-packages\pip\_vendor\pep517\wrappers.py", line 265, in _call_hook
      raise BackendUnavailable(data.get('traceback', ''))
  pip._vendor.pep517.wrappers.BackendUnavailable: Traceback (most recent call last):
    File "C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 86, in _build_backend
      obj = import_module(mod_path)
    File "C:\Users\jonapich\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py", line 127, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
    File "<frozen importlib._bootstrap>", line 991, in _find_and_load
    File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
    File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
    File "<frozen importlib._bootstrap>", line 991, in _find_and_load
    File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
    File "<frozen importlib._bootstrap_external>", line 783, in exec_module
    File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
    File "C:\Users\jonapich\AppData\Local\Temp\pip-build-env-2_yuojjf\overlay\Lib\site-packages\poetry\core\masonry\__init__.py", line 10, in <module>
      from .builder import Builder
    File "C:\Users\jonapich\AppData\Local\Temp\pip-build-env-2_yuojjf\overlay\Lib\site-packages\poetry\core\masonry\builder.py", line 6, in <module>
      from .builders.sdist import SdistBuilder
    File "C:\Users\jonapich\AppData\Local\Temp\pip-build-env-2_yuojjf\overlay\Lib\site-packages\poetry\core\masonry\builders\__init__.py", line 2, in <module>
      from .wheel import WheelBuilder
    File "C:\Users\jonapich\AppData\Local\Temp\pip-build-env-2_yuojjf\overlay\Lib\site-packages\poetry\core\masonry\builders\wheel.py", line 18, in <module>
      from packaging.tags import sys_tags
    File "C:/Users/jonapich/AppData/Local/Temp/pip-build-env-2_yuojjf/overlay/Lib/site-packages/poetry/core/_vendor\packaging\tags.py", line 7, in <module>
      import distutils.util
    File "C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\lib\site-packages\_distutils_hack\__init__.py", line 83, in create_module
      return importlib.import_module('setuptools._distutils')
    File "C:\Users\jonapich\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py", line 127, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
  ModuleNotFoundError: No module named 'setuptools'

  WARNING: You are using pip version 20.2.2; however, version 20.2.4 is available.
  You should consider upgrading via the 'C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\Scripts\python.exe -m pip install --upgrade pip' command.


  at ~\.poetry\lib\poetry\utils\env.py:948 in _run
       944│                 output = subprocess.check_output(
       945│                     cmd, stderr=subprocess.STDOUT, **kwargs
       946│                 )
       947│         except CalledProcessError as e:
    →  948│             raise EnvCommandError(e, input=input_)
       949│
       950│         return decode(output)
       951│
       952│     def execute(self, bin, *args, **kwargs):


❭❭  test-functools  10:07  C:\Users\jonapich\AppData\Local\Programs\Python\Python38\python.exe -m venv py38
❭❭  test-functools ✗  10:08  cd .\py38\Scripts\


❭❭  Scripts ✗  10:08  ./pip.exe install --no-deps -U C:/Users/jonapich/Documents/workspace/test-poetry/test-testing
Processing c:\users\jonapich\documents\workspace\test-poetry\test-testing
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Building wheels for collected packages: test-testing
  Building wheel for test-testing (PEP 517) ... done
  Created wheel for test-testing: filename=test_testing-0.1.4-py3-none-any.whl size=1057 sha256=0dc5e08a26902022cb80200b444cb79ce44410e91677bccdf7170e2174120e60
  Stored in directory: c:\users\jonapich\appdata\local\pip\cache\wheels\9f\5a\af\cb6a6cf29a333225d43d6c533921e8a09291dc81b67555a9cd
Successfully built test-testing
Installing collected packages: test-testing
Successfully installed test-testing-0.1.4
WARNING: You are using pip version 20.2.1; however, version 20.2.4 is available.
You should consider upgrading via the 'c:\users\jonapich\documents\workspace\test-poetry\test-functools\py38\scripts\python.exe -m pip install --upgrade pip' command.


❭❭  Scripts  10:08  cd C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\Scripts
❭❭  Scripts  10:08  ./pip.exe install --no-deps -U C:/Users/jonapich/Documents/workspace/test-poetry/test-testing
Processing c:\users\jonapich\documents\workspace\test-poetry\test-testing
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
ERROR: Exception:
Traceback (most recent call last):
  File "C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\lib\site-packages\pip\_internal\cli\base_command.py", line 216, in _main
    status = self.run(options, args)
  File "C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\lib\site-packages\pip\_internal\cli\req_command.py", line 182, in wrapper
    return func(self, options, args)
  File "C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\lib\site-packages\pip\_internal\commands\install.py", line 324, in run
    requirement_set = resolver.resolve(
  File "C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 183, in resolve
    discovered_reqs.extend(self._resolve_one(requirement_set, req))
  File "C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 388, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 340, in _get_abstract_dist_for
    abstract_dist = self.preparer.prepare_linked_requirement(req)
  File "C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\lib\site-packages\pip\_internal\operations\prepare.py", line 482, in prepare_linked_requirement
    abstract_dist = _get_prepared_distribution(
  File "C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\lib\site-packages\pip\_internal\operations\prepare.py", line 91, in _get_prepared_distribution
    abstract_dist.prepare_distribution_metadata(finder, build_isolation)
  File "C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\lib\site-packages\pip\_internal\distributions\sdist.py", line 38, in prepare_distribution_metadata
    self._setup_isolation(finder)
  File "C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\lib\site-packages\pip\_internal\distributions\sdist.py", line 96, in _setup_isolation
    reqs = backend.get_requires_for_build_wheel()
  File "C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\lib\site-packages\pip\_vendor\pep517\wrappers.py", line 160, in get_requires_for_build_wheel
    return self._call_hook('get_requires_for_build_wheel', {
  File "C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\lib\site-packages\pip\_vendor\pep517\wrappers.py", line 265, in _call_hook
    raise BackendUnavailable(data.get('traceback', ''))
pip._vendor.pep517.wrappers.BackendUnavailable: Traceback (most recent call last):
  File "C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 86, in _build_backend
    obj = import_module(mod_path)
  File "C:\Users\jonapich\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\jonapich\AppData\Local\Temp\pip-build-env-1hbdbs59\overlay\Lib\site-packages\poetry\core\masonry\__init__.py", line 10, in <module>
    from .builder import Builder
  File "C:\Users\jonapich\AppData\Local\Temp\pip-build-env-1hbdbs59\overlay\Lib\site-packages\poetry\core\masonry\builder.py", line 6, in <module>
    from .builders.sdist import SdistBuilder
  File "C:\Users\jonapich\AppData\Local\Temp\pip-build-env-1hbdbs59\overlay\Lib\site-packages\poetry\core\masonry\builders\__init__.py", line 2, in <module>
    from .wheel import WheelBuilder
  File "C:\Users\jonapich\AppData\Local\Temp\pip-build-env-1hbdbs59\overlay\Lib\site-packages\poetry\core\masonry\builders\wheel.py", line 18, in <module>
    from packaging.tags import sys_tags
  File "C:/Users/jonapich/AppData/Local/Temp/pip-build-env-1hbdbs59/overlay/Lib/site-packages/poetry/core/_vendor\packaging\tags.py", line 7, in <module>
    import distutils.util
  File "C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\lib\site-packages\_distutils_hack\__init__.py", line 83, in create_module
    return importlib.import_module('setuptools._distutils')
  File "C:\Users\jonapich\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'setuptools'

WARNING: You are using pip version 20.2.2; however, version 20.2.4 is available.
You should consider upgrading via the 'C:\Users\jonapich\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-44VBZfUY-py3.8\Scripts\python.exe -m pip install --upgrade pip' command.

@jonapich
Copy link
Contributor

I went through the trouble of removing everything python and poetry off my system. I then reinstalled py3.8 using the latest installer and then reinstalled poetry using the Invoke-Webrequest method from the docs.

The behavior is still the same. Some observations:

  • Through poetry run python -m pip list I can see setuptools is installed in the project's virtual environment.
  • If I launch poetry run python I can import distutils.util

This is where poetry breaks it for me even though python/pip can handle it:

  • If I launch poetry shell and then proceed to pip install ../test-testing/ it will fail.
  • If I create my own environment python -m venv virtualenv and then call virtualenv/Scripts/pip install ../test-testing/ it works.

Additional note: The dependencies in test-testing have no effect on the issue. I tried to remove them all but I'm still unable to install it if poetry is involved with it.

@jonapich
Copy link
Contributor

I wasn't able to find the cause of the problem. After a fresh install of Windows 10, I am no longer experiencing the issue and I can install the test repo that I created for this issue.

@gitpushdashf
Copy link
Author

Did something change between 1.1.3 and 1.1.4 that may have fixed this?

Python 3.7 Docker container:

root@c55cbfe70290:~/test-poetry-setuptools/test-functools# poetry install
Creating virtualenv test-functools-vuIxD4Qa-py3.7 in /root/.cache/pypoetry/virtualenvs
Installing dependencies from lock file

Package operations: 17 installs, 0 updates, 0 removals

  • Installing zipp (3.3.1)
  • Installing importlib-metadata (2.0.0)
  • Installing pyparsing (2.4.7)
  • Installing six (1.15.0)
  • Installing attrs (20.2.0)
  • Installing iniconfig (1.1.1)
  • Installing packaging (20.4)
  • Installing pluggy (0.13.1)
  • Installing py (1.9.0)
  • Installing toml (0.10.1)
  • Installing mypy-extensions (0.4.3)
  • Installing pytest (6.1.1)
  • Installing typed-ast (1.4.1)
  • Installing typing-extensions (3.7.4.3)
  • Installing inflection (0.5.1)
  • Installing mypy (0.790)
  • Installing test-testing (0.1.4 /root/test-poetry-setuptools/test-testing)

Installing the current project: test-functools (0.1.4)

@jonapich
Copy link
Contributor

jonapich commented Nov 4, 2020

The repo reproduced the issue on my system only. Then I had to reformat for a non related reason, and I could not reproduce the issue anymore.

Sorry I cannot be of any more help. This issue is resolved as far as I'm concerned. Is your original issue still happening? Did you try to repo in a container or VM?

@gitpushdashf
Copy link
Author

I can't reproduce this now. I'll close it out unless someone else runs into it on 1.1.4.

@kbakk
Copy link
Contributor

kbakk commented Nov 11, 2020

@gitpushdashf Would you mind reopening this issue - I'm seeing this on 1.1.4 (and 1.1.3).

Here's a minimal project where I'm able to reproduce the ModuleNotFoundError: No module named 'setuptools'.

reproduce-3153.zip

$ poetry install
Creating virtualenv reproduce-issue-QXZ_ZScA-py3.7 in /Users/kristofferb/Library/Caches/pypoetry/virtualenvs
Installing dependencies from lock file

Installing the current project: reproduce-issue (0.1.0)

$ poetry env info                                                                             

Virtualenv
Python:         3.7.6
Implementation: CPython
Path:           /Users/kristofferb/Library/Caches/pypoetry/virtualenvs/reproduce-issue-QXZ_ZScA-py3.7
Valid:          True

System
Platform: darwin
OS:       posix
Python:   /Users/kristofferb/.pyenv/versions/3.7.6

$ poetry run pip install -e .
Obtaining file:///Users/kristofferb/Code/temp/gist-reproduce-3153
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Installing collected packages: reproduce-issue
  Attempting uninstall: reproduce-issue
    Found existing installation: reproduce-issue 0.1.0
    Uninstalling reproduce-issue-0.1.0:
      Successfully uninstalled reproduce-issue-0.1.0
  Running setup.py develop for reproduce-issue
    ERROR: Command errored out with exit status 1:
     command: /Users/kristofferb/Library/Caches/pypoetry/virtualenvs/reproduce-issue-QXZ_ZScA-py3.7/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/Users/kristofferb/Code/temp/gist-reproduce-3153/setup.py'"'"'; __file__='"'"'/Users/kristofferb/Code/temp/gist-reproduce-3153/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps
         cwd: /Users/kristofferb/Code/temp/gist-reproduce-3153/
    Complete output (3 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ModuleNotFoundError: No module named 'setuptools'
    ----------------------------------------
  Rolling back uninstall of reproduce-issue
  Moving to /Users/kristofferb/Library/Caches/pypoetry/virtualenvs/reproduce-issue-QXZ_ZScA-py3.7/lib/python3.7/site-packages/reproduce_issue-0.1.0.dist-info/
   from /Users/kristofferb/Library/Caches/pypoetry/virtualenvs/reproduce-issue-QXZ_ZScA-py3.7/lib/python3.7/site-packages/~eproduce_issue-0.1.0.dist-info
  Moving to /Users/kristofferb/Library/Caches/pypoetry/virtualenvs/reproduce-issue-QXZ_ZScA-py3.7/lib/python3.7/site-packages/reproduce_issue.pth
   from /private/var/folders/3j/l__gnf4n6t73fpcg8nk3tqhc0000gn/T/pip-uninstall-cz50uscc/reproduce_issue.pth
ERROR: Command errored out with exit status 1: /Users/kristofferb/Library/Caches/pypoetry/virtualenvs/reproduce-issue-QXZ_ZScA-py3.7/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/Users/kristofferb/Code/temp/gist-reproduce-3153/setup.py'"'"'; __file__='"'"'/Users/kristofferb/Code/temp/gist-reproduce-3153/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps Check the logs for full command output.

$ poetry --version           
Poetry version 1.1.4

I'm on MacOS 10.15.7 fwiw.

@finswimmer
Copy link
Member

I don't understand completely what's going on here. But the root cause seems to be, that setuptools started to vendor distutils in a way, that whenever a module imports distutils it gets redirected to the vendored version of setuptools. And that seems not work in any case. See pypa/distutils#17

So the problem is not, that setuptools is not installed. The problem is, that the version of setuptools that comes with the isolated build environment doesn't work as expected. A workaround is to run export SETUPTOOLS_USE_DISTUTILS=stdlib before a pip install.

So at it stands now, it looks to me a setuptools problem and not a poetry problem.

@kbakk
Copy link
Contributor

kbakk commented Nov 14, 2020

In #1135 (comment) @NeilGirdhar pointed out that one would need to change pyproject.toml to include setuptools:

[build-system]
-requires = ["poetry_core>=1.0"]
+requires = ["setuptools", "poetry_core>=1.0"]
build-backend = "poetry.core.masonry.api"

With this added in my above example (reproduce-3153.zip) it now builds:

poetry run pip install -e .
Obtaining file:///Users/kristofferb/Code/temp/gist-reproduce-3153
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Installing collected packages: reproduce-issue
  Attempting uninstall: reproduce-issue
    Found existing installation: reproduce-issue 0.1.0
    Uninstalling reproduce-issue-0.1.0:
      Successfully uninstalled reproduce-issue-0.1.0
  Running setup.py develop for reproduce-issue
Successfully installed reproduce-issue

And indeed, as others have mentioned in #34, this is not a poetry issue. But it seems like many would like poetry to have a workaround.

abey79 added a commit to abey79/vpype that referenced this issue Nov 14, 2020
@jonapich
Copy link
Contributor

jonapich commented Nov 14, 2020 via email

@hyliu1989
Copy link
Contributor

hyliu1989 commented Nov 16, 2020

And indeed, as others have mentioned in #34, this is not a poetry issue. But it seems like many would like poetry to have a workaround.

Yes, a poetry workaround would be perfect. I can also reproduce this error in the setting of #2015 (comment). I got that it is caused by build isolation but I am afraid that keeping things to the minimal will end up having a lot of boilerplate text in pyproject.toml.

@jwg4
Copy link

jwg4 commented Jan 12, 2021

Hi, if I understood the status of this issue correctly, a workaround (for the obscure setuptools problem, which will not go away until poetry no longer uses setuptools) is on main, but not released yet, and for a package which is built by poetry, but which has a setup.py (for example, setup.py which is used to install the sdist), one can workaround until the next release, by adding

[build-system]
-requires = ["poetry_core>=1.0"]
+requires = ["setuptools", "poetry_core>=1.0"]
build-backend = "poetry.core.masonry.api"

as suggested by @kbakk. Is this correct?

jwg4 added a commit to jwg4/exact_cover that referenced this issue Jan 12, 2021
nyanpasu64 added a commit to corrscope/corrscope that referenced this issue Jul 14, 2021
corrscope uses poetry, while pip expects a setuptools project and will
create package name UNKNOWN if run without setup.py or pyproject.toml
[build-system]. This adds an up-to-date pyproject.toml [build-system]
tag.

"setuptools" is required to make `pip install .` work, due to
python-poetry/poetry#3153 (comment)

Right now, `pip install [--editable] .` and `pipx install .` work, but
`pipx install --editable .` fails with message "No apps associated with
package UNKNOWN or its dependencies."

I'm not aware of how to fix this.
@LGro
Copy link

LGro commented Aug 3, 2021

For me it seems like the issue went away once I removed ~/.cache/pypoetry - can someone confirm this?

@Bharathkumarraju
Copy link

i am also getting same issue even with this setup

requires = ["setuptools","poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

@jtzero
Copy link

jtzero commented Aug 10, 2021

same issue, wrapt depends on it,
manually removing setuptools from the poetry.lock worked for me

diff --git a/poetry.lock b/poetry.lock
index c8f8357..f858bfe 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -868,18 +868,6 @@ botocore = ">=1.12.36,<2.0a.0"
 [package.extras]
 crt = ["botocore[crt] (>=1.20.29,<2.0a.0)"]

-[[package]]
-name = "setuptools"
-version = "57.4.0"
-description = "Easily download, build, install, upgrade, and uninstall Python packages"
-category = "main"
-optional = false
-python-versions = ">=3.6"
-
-[package.extras]
-docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "sphinx-inline-tabs", "sphinxcontrib-towncrier", "furo"]
-testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "mock", "flake8-2020", "virtualenv (>=13.0.0)", "pytest-virtualenv (>=1.2.7)", "wheel", "paver", "pip (>=19.1)", "jaraco.envs", "pytest-xdist", "sphinx", "jaraco.path (>=3.2.0)", "pytest-black (>=0.3.7)", "pytest-mypy"]
-
 [[package]]
 name = "six"
 version = "1.16.0"
@@ -1555,10 +1543,6 @@ s3transfer = [
     {file = "s3transfer-0.5.0-py3-none-any.whl", hash = "sha256:9c1dc369814391a6bda20ebbf4b70a0f34630592c9aa520856bf384916af2803"},
     {file = "s3transfer-0.5.0.tar.gz", hash = "sha256:50ed823e1dc5868ad40c8dc92072f757aa0e653a192845c94a3b676f4a62da4c"},
 ]
-setuptools = [
-    {file = "setuptools-57.4.0-py3-none-any.whl", hash = "sha256:a49230977aa6cfb9d933614d2f7b79036e9945c4cdd7583163f4e920b83418d6"},
-    {file = "setuptools-57.4.0.tar.gz", hash = "sha256:6bac238ffdf24e8806c61440e755192470352850f3419a52f26ffe0a1a64f465"},
-]
 six = [
     {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"},
     {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"},
> rm -rf "$(poetry env info --path)"
> poetry install
...
Installing wrapt (1.12.1)

@Bharathkumarraju
Copy link

Bharathkumarraju commented Aug 10, 2021

@jtzero yes after removing setuptools in poetry.lock its working now. Thank you.!!!

@martinxsliu
Copy link

I ran into this issue with Poetry 1.2.0a2 as it adds setuptools to the lock file when 1.1.x would not. Relocking the project with 1.1.8 removes the setuptools dependency and resolves my issue.

@lovetoburnswhen
Copy link

Deleting poetry.lock then installing worked for me on Python 3.9.5 + poetry 1.1.9

@generalpiston
Copy link

generalpiston commented Nov 18, 2021

I get the exact same error when building a docker image based on python:3.9.7-alpine3.14.
I ended up exporting to a requirements file and skipping poetry install:

RUN poetry export -f requirements.txt --output requirements.txt
RUN pip install -r requirements.txt

@abn
Copy link
Member

abn commented Nov 18, 2021

@generalpiston can you please provide a bit more information on the error please?

  1. What version of poetry are you using?
  2. How did you install it?
  3. Do you have logs I can use or better yet a Dockerfile I can reproduce with (or steps with a simplified project)?

If at build time the package requires setuptools it needs to go to build-system.requires section. However, there is also an open question about how the build requirements get into the virtual environment in which the project is executing. See also #2789.

As to why setuptools appear in the lockfile, this is related to #2826. This change meant that it is no longer excluded from dependency resolution. This means if a dependency in your project's dependency tree requires setuptools it will be added to the lock file.

@generalpiston
Copy link

generalpiston commented Nov 18, 2021

@abn see below.

poetry 1.1.11.

Reproduction

Dockerfile:

FROM python:3.9.7-alpine3.14

RUN apk update && apk add postgresql-dev gcc g++ python3-dev musl-dev libffi-dev openssl-dev rust cargo
RUN pip install poetry==1.1.11

COPY pyproject.toml ./
COPY poetry.lock ./

RUN poetry install -vvv

pyproject.toml:

[tool.poetry]
name = "t"
version = "0.1.0"
description = ""
authors = ["..."]
readme = "README.md"

[tool.poetry.dependencies]
python = "3.9.7"
Flask = "^2.0.2"
gunicorn = "^20.1.0"

[build-system]
requires = ["poetry-core","setuptools"]
build-backend = "poetry.core.masonry.api"
  1. pip install poetry==1.1.11
  2. poetry init
  3. poetry install
  4. docker build -t test .

@abn
Copy link
Member

abn commented Nov 19, 2021

@generalpiston looks like I can only reproduce it if the lock file was generated with a 1.2.0a version and then attempted to be instaleld using 1.1.11.

I believe the issue here is that since 1.2.z will no longer treat setuptools as an ignored dependency (#2826), they end up in the lock file. So, if the lock file was generated by such a version, the the older version (here 1.1.11), will behave unexpectedly.

Try either regenerating the lock file using 1.1.11 or using a preview release in your container.

@generalpiston
Copy link

@abn good point. Apparently I have 1.2.0a installed for some reason. Thanks for pointing that out! Downgrading to 1.1.11 fixes the problem.

@abn
Copy link
Member

abn commented Nov 19, 2021

I'm going to close this issue as poetry no longer depends on using the venv provided setuptools not pip.

And the only case this seems to be triggered is when lock file was generated with a pre-release version and installed using an older release.

@abn abn removed kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Nov 19, 2021
@abn abn closed this as completed Nov 19, 2021
apjanco added a commit to HCDigitalScholarship/intervals that referenced this issue Jan 3, 2022
srevinsaju added a commit to srevinsaju/pyuploadtool that referenced this issue Jan 16, 2022
pyuploadtool now generates changelog for GitHub releases
which is opt-in. Changelogs will be generated only when

GENERATE_CHANGELOG=true

feat: prepend the metadata.description with the generated changelog

fix: rename get_changelog to render_to_markdown

its a more intuitive function name and clearly explains
that the output is a string of markdown data

fix: do not replace the existing metadata description, but append to it

feat: expose get_changelog

this function can in be future be replaced by a
a changelog handling object

feat: add support for restrictive conventional commit spec

fix: remove redundant comment

style: add more blank lines

feat: restructure changelog generator

style: format with black

fix: circular imports on changelog

docs: update documentation to show CHANGELOG support

refactor: complete refactor from Parser to ChangelogParser

fix: refactor to use attributes for Commit object instead of dict.get

fix: for github releases, set the commit_prefix_link

style: lint with black

style: move ReleaseUpdate below .. imports (pep8)

fix: convert Changelog.structure to staticmethod

feat: use NamedTuple instead of complicating the implementation

style: remove redundant _ prefixes to local variables

style: remove redundant line

feat: do not edit metadata in the release provider

fix: docstrings for Changelog.changelog, Changelog.structure

fix: use type annotations instead of type in docstrings

refactor: ChangelogCommit to ChangelogEntry to make it more general

fix: allow providing lowercase values for CHANGELOG_TYPE env variable

feat: remove the need to specify CHANGELOG_GENERATE environment variable.

Automatically generate changelog if CHANGELOG_TYPE is defined to 'standard' or 'conventional'

docs: improve docstrings of MarkdownChangelogParser.render_to_markdown

docs: improve docstrings of Changelog.structure

Add support for scheduled and manual builds

Print non-string types properly

Improve logging

Convert metadata to correct types

Fix comparison (and show intention more clearly)

Check code format with black

Run checks on PRs as well

Use poetry to manage dependencies in CI

Debug dependencies installatino

Forgot to check out the code

Format YAML properly

Add incomplete list of projects using pyuploadtool

Pin poetry version

Workaround for python-poetry/poetry#3153.

Fix type issue

When calling sanitize on an int, e.g., the pipeline run number, it might fail as the passed type is not iterable. This little fix makes sure whatever is passed is interpreted as a string.

fix: remove redundant imports

fix: do not attempt to generate changelog if the previous tag is missing

fix: changelog.structure is not a property

fix: ChangelogEntry should not be a tuple, because it needs to be edited runtime
srevinsaju added a commit to srevinsaju/pyuploadtool that referenced this issue Jan 16, 2022
pyuploadtool now generates changelog for GitHub releases
which is opt-in. Changelogs will be generated only when

GENERATE_CHANGELOG=true

feat: prepend the metadata.description with the generated changelog

fix: rename get_changelog to render_to_markdown

its a more intuitive function name and clearly explains
that the output is a string of markdown data

fix: do not replace the existing metadata description, but append to it

feat: expose get_changelog

this function can in be future be replaced by a
a changelog handling object

feat: add support for restrictive conventional commit spec

fix: remove redundant comment

style: add more blank lines

feat: restructure changelog generator

style: format with black

fix: circular imports on changelog

docs: update documentation to show CHANGELOG support

refactor: complete refactor from Parser to ChangelogParser

fix: refactor to use attributes for Commit object instead of dict.get

fix: for github releases, set the commit_prefix_link

style: lint with black

style: move ReleaseUpdate below .. imports (pep8)

fix: convert Changelog.structure to staticmethod

feat: use NamedTuple instead of complicating the implementation

style: remove redundant _ prefixes to local variables

style: remove redundant line

feat: do not edit metadata in the release provider

fix: docstrings for Changelog.changelog, Changelog.structure

fix: use type annotations instead of type in docstrings

refactor: ChangelogCommit to ChangelogEntry to make it more general

fix: allow providing lowercase values for CHANGELOG_TYPE env variable

feat: remove the need to specify CHANGELOG_GENERATE environment variable.

Automatically generate changelog if CHANGELOG_TYPE is defined to 'standard' or 'conventional'

docs: improve docstrings of MarkdownChangelogParser.render_to_markdown

docs: improve docstrings of Changelog.structure

Add support for scheduled and manual builds

Print non-string types properly

Improve logging

Convert metadata to correct types

Fix comparison (and show intention more clearly)

Check code format with black

Run checks on PRs as well

Use poetry to manage dependencies in CI

Debug dependencies installatino

Forgot to check out the code

Format YAML properly

Add incomplete list of projects using pyuploadtool

Pin poetry version

Workaround for python-poetry/poetry#3153.

Fix type issue

When calling sanitize on an int, e.g., the pipeline run number, it might fail as the passed type is not iterable. This little fix makes sure whatever is passed is interpreted as a string.

fix: remove redundant imports

fix: do not attempt to generate changelog if the previous tag is missing

fix: changelog.structure is not a property

fix: ChangelogEntry should not be a tuple, because it needs to be edited runtime
@akashkj
Copy link

akashkj commented Feb 5, 2022

It worked for me by upgrading setuptools and pip to the latest versions

@fosskers
Copy link

fosskers commented Feb 21, 2022

This still happens on a fresh install of Poetry (1.1.13) with Python 3.10.2 (on Arch Linux, at least). I tried to follow the poetry-demo tutorial but it exploded when I attempted:

poetry add pendulum

Adding setuptools to the [build-system] section doesn't fix it. Note that I'm using the system-provided versions of pip (20.3.4) and setuptools (59.3.0), although the virtualenv seems to be pulling it's own version of pip anyway (21.3.1).

Update: Actually the problem may be with pendulum itself. I was just able to do a poetry add more-itertools without issue.

@haf haf mentioned this issue Apr 15, 2022
3 tasks
TheAssassin pushed a commit to TheAssassin/pyuploadtool that referenced this issue Jun 14, 2022
pyuploadtool now generates changelog for GitHub releases
which is opt-in. Changelogs will be generated only when

GENERATE_CHANGELOG=true

feat: prepend the metadata.description with the generated changelog

fix: rename get_changelog to render_to_markdown

its a more intuitive function name and clearly explains
that the output is a string of markdown data

fix: do not replace the existing metadata description, but append to it

feat: expose get_changelog

this function can in be future be replaced by a
a changelog handling object

feat: add support for restrictive conventional commit spec

fix: remove redundant comment

style: add more blank lines

feat: restructure changelog generator

style: format with black

fix: circular imports on changelog

docs: update documentation to show CHANGELOG support

refactor: complete refactor from Parser to ChangelogParser

fix: refactor to use attributes for Commit object instead of dict.get

fix: for github releases, set the commit_prefix_link

style: lint with black

style: move ReleaseUpdate below .. imports (pep8)

fix: convert Changelog.structure to staticmethod

feat: use NamedTuple instead of complicating the implementation

style: remove redundant _ prefixes to local variables

style: remove redundant line

feat: do not edit metadata in the release provider

fix: docstrings for Changelog.changelog, Changelog.structure

fix: use type annotations instead of type in docstrings

refactor: ChangelogCommit to ChangelogEntry to make it more general

fix: allow providing lowercase values for CHANGELOG_TYPE env variable

feat: remove the need to specify CHANGELOG_GENERATE environment variable.

Automatically generate changelog if CHANGELOG_TYPE is defined to 'standard' or 'conventional'

docs: improve docstrings of MarkdownChangelogParser.render_to_markdown

docs: improve docstrings of Changelog.structure

Add support for scheduled and manual builds

Print non-string types properly

Improve logging

Convert metadata to correct types

Fix comparison (and show intention more clearly)

Check code format with black

Run checks on PRs as well

Use poetry to manage dependencies in CI

Debug dependencies installatino

Forgot to check out the code

Format YAML properly

Add incomplete list of projects using pyuploadtool

Pin poetry version

Workaround for python-poetry/poetry#3153.

Fix type issue

When calling sanitize on an int, e.g., the pipeline run number, it might fail as the passed type is not iterable. This little fix makes sure whatever is passed is interpreted as a string.

fix: remove redundant imports

fix: do not attempt to generate changelog if the previous tag is missing

fix: changelog.structure is not a property

fix: ChangelogEntry should not be a tuple, because it needs to be edited runtime
Copy link

github-actions bot commented Mar 2, 2024

This issue 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 2, 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

No branches or pull requests