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

Poetry depends on setuptools #5964

Closed
2 tasks done
CLOVIS-AI opened this issue Jul 7, 2022 · 12 comments
Closed
2 tasks done

Poetry depends on setuptools #5964

CLOVIS-AI opened this issue Jul 7, 2022 · 12 comments
Labels
kind/bug Something isn't working as expected

Comments

@CLOVIS-AI
Copy link

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option). The exception doesn't occur in Poetry itself
  • OS version and name: ArchLinux
  • Poetry version: 1.1.13
  • Contents of your pyproject.toml file:
[tool.poetry]
name = "demo"
version = "0.1.0"
description = ""
authors = ["Ivan Canet <ivan.canet@gmail.com>"]

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

[build-system]
requires = ["poetry-core~=1.0.0", "wheel"]
build-backend = "poetry.core.masonry.api"

Issue

After creating a simple project with the default configuration using poetry init, it is not possible to install it with pip.

$ pip install .
ERROR: Exception:
Traceback (most recent call last):
  File "[REDACTED]/lib/python3.10/site-packages/pip/_internal/cli/base_command.py", line 167, in exc_logging_wrapper
    status = run_func(*args)
  File "[REDACTED]/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper
    return func(self, options, args)
  File "[REDACTED]/lib/python3.10/site-packages/pip/_internal/commands/install.py", line 341, in run
    requirement_set = resolver.resolve(
  File "[REDACTED]/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 75, in resolve
    collected = self.factory.collect_root_requirements(root_reqs)
  File "[REDACTED]/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 506, in collect_root_requirements
    req = self._make_requirement_from_install_req(
  File "[REDACTED]/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 468, in _make_requirement_from_install_req
    cand = self._make_candidate_from_link(
  File "[REDACTED]/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 215, in _make_candidate_from_link
    self._link_candidate_cache[link] = LinkCandidate(
  File "[REDACTED]/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 291, in __init__
    super().__init__(
  File "[REDACTED]/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 161, in __init__
    self.dist = self._prepare()
  File "[REDACTED]/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 230, in _prepare
    dist = self._prepare_distribution()
  File "[REDACTED]/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 302, in _prepare_distribution
    return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
  File "[REDACTED]/lib/python3.10/site-packages/pip/_internal/operations/prepare.py", line 428, in prepare_linked_requirement
    return self._prepare_linked_requirement(req, parallel_builds)
  File "[REDACTED]/lib/python3.10/site-packages/pip/_internal/operations/prepare.py", line 497, in _prepare_linked_requirement
    dist = _get_prepared_distribution(
  File "[REDACTED]/lib/python3.10/site-packages/pip/_internal/operations/prepare.py", line 58, in _get_prepared_distribution
    abstract_dist.prepare_distribution_metadata(
  File "[REDACTED]/lib/python3.10/site-packages/pip/_internal/distributions/sdist.py", line 48, in prepare_distribution_metadata
    self._install_build_reqs(finder)
  File "[REDACTED]/lib/python3.10/site-packages/pip/_internal/distributions/sdist.py", line 118, in _install_build_reqs
    build_reqs = self._get_build_requires_wheel()
  File "[REDACTED]/lib/python3.10/site-packages/pip/_internal/distributions/sdist.py", line 95, in _get_build_requires_wheel
    return backend.get_requires_for_build_wheel()
  File "[REDACTED]/lib/python3.10/site-packages/pip/_internal/utils/misc.py", line 685, in get_requires_for_build_wheel
    return super().get_requires_for_build_wheel(config_settings=cs)
  File "[REDACTED]/lib/python3.10/site-packages/pip/_vendor/pep517/wrappers.py", line 172, in get_requires_for_build_wheel
    return self._call_hook('get_requires_for_build_wheel', {
  File "[REDACTED]/lib/python3.10/site-packages/pip/_vendor/pep517/wrappers.py", line 332, in _call_hook
    raise BackendUnavailable(data.get('traceback', ''))
pip._vendor.pep517.wrappers.BackendUnavailable: Traceback (most recent call last):
  File "[REDACTED]/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 89, in _build_backend
    obj = import_module(mod_path)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/tmp/pip-build-env-tinc85gw/overlay/lib/python3.10/site-packages/poetry/core/masonry/__init__.py", line 10, in <module>
    from .builder import Builder
  File "/tmp/pip-build-env-tinc85gw/overlay/lib/python3.10/site-packages/poetry/core/masonry/builder.py", line 7, in <module>
    from .builders.sdist import SdistBuilder
  File "/tmp/pip-build-env-tinc85gw/overlay/lib/python3.10/site-packages/poetry/core/masonry/builders/__init__.py", line 2, in <module>
    from .wheel import WheelBuilder
  File "/tmp/pip-build-env-tinc85gw/overlay/lib/python3.10/site-packages/poetry/core/masonry/builders/wheel.py", line 23, in <module>
    from packaging.tags import sys_tags
  File "/tmp/pip-build-env-tinc85gw/overlay/lib/python3.10/site-packages/poetry/core/_vendor/packaging/tags.py", line 7, in <module>
    import distutils.util
  File "[REDACTED]/lib/python3.10/site-packages/_distutils_hack/__init__.py", line 92, in create_module
    return importlib.import_module('setuptools._distutils')
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'setuptools'

Solution

Adding "setuptools" as a build-system.requires fixes the issue.

If setuptools is required by Poetry, why doesn't poetry init add it?
Also, I thought the goal of Poetry was to avoid using setuptools?

@CLOVIS-AI CLOVIS-AI added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Jul 7, 2022
@Secrus
Copy link
Member

Secrus commented Jul 7, 2022

What if you were to remove the "wheel" from build requirements?

@dimbleby
Copy link
Contributor

dimbleby commented Jul 9, 2022

@Secrus is right

  • poetry init does not add wheel to the build-system requires, @CLOVIS-AI has done this manually
  • without wheel, pip install . runs just fine

ie this is user error and can be closed

@dimbleby
Copy link
Contributor

dimbleby commented Jul 9, 2022

Having said which, I don't reproduce this problem even with wheel included in that list, so 🤷

Using the provided pyproject.toml, with setuptools absent from the virtual environment:

$ pip list
Package Version
------- -------
pip     22.0.2

$ pip install .
Processing /home/dch/foo
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: demo
  Building wheel for demo (pyproject.toml) ... done
  Created wheel for demo: filename=demo-0.1.0-py3-none-any.whl size=962 sha256=a7fae81ec18facc4855830b3f56cb88866e97127d540e4d4fe52edbfecae6f73
  Stored in directory: /tmp/pip-ephem-wheel-cache-2vvc5krf/wheels/74/36/59/5f272a8602c0655288a982d06e0ec48e94c6c3ccfe9d1f1d69
Successfully built demo
Installing collected packages: demo
Successfully installed demo-0.1.0

@CLOVIS-AI
Copy link
Author

I'll try to remove wheel on Monday and update this issue.

Isn't wheel recommended to always include? I've heard it's what all recent python projects should be using.

@dimbleby
Copy link
Contributor

dimbleby commented Jul 9, 2022

news to me, if you have a source and think that poetry is Doing It Wrong then please raise an issue

@CLOVIS-AI
Copy link
Author

I guess this is the closest to an official source as possible: https://packaging.python.org/en/latest/discussions/wheel-vs-egg/

@dimbleby
Copy link
Contributor

that is not even close to saying "all build environments must include the wheel package".

Do you still have a problem here or can this be closed? Per last week I can't reproduce your problem anyway so if you are still hitting an issue you'll have to provide more detail on what you're doing differently.

@CLOVIS-AI
Copy link
Author

I'm away from the machine it happened on for now. What kind of information would you need?

@dimbleby
Copy link
Contributor

A way to reproduce the problem.

I've seen a few issues recently where folk have submitted Dockerfiles reproducing issues. That's a sensible approach.

@finswimmer
Copy link
Member

@CLOVIS-AI
Copy link
Author

My version of pip was already up to date.

Removing wheel did not cause the issue again, so I guess it's a bug with wheel not pulling its own dependencies correctly and not Poetry.

@mkniewallner mkniewallner removed the status/triage This issue needs to be triaged label Jul 31, 2022
Copy link

github-actions bot commented Mar 1, 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 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

5 participants