Skip to content

Poetry build using wrong virtualenv when installed with pipx? #3054

@alexifm

Description

@alexifm

System Info

  • OS version and name: macos 10.15.6
  • Poetry version: 1.1.0
  • Relevant pyproject.toml file contents:
[tool.poetry]
name = "infima"
version = "0.0.1"
readme = "README.md"
packages = []
build = "build.py"

...


[build-system]
requires = ["poetry_core>=1.0.0", "setuptools", "Cython>=0.29", "numpy>=1.18"]
build-backend = "poetry.core.masonry.api"

Setup

Installed 1.1.0 with pipx:

$ pipx list
venvs are in /Users/alexifm/.local/pipx/venvs
apps are exposed on your $PATH at /Users/alexifm/.local/bin
   package poetry 1.1.0, Python 3.8.5
    - poetry

Have a clean virtualenv with pyenv and Python 3.8.5:

$ pyenv virtualenv 3.8.5 test
$ pyenv shell test

What happens

Building a wheel throws an error saying numpy isn't available

$ poetry build -vvv -f wheel
Using virtualenv: /Users/alexifm/.pyenv/versions/3.7.7/envs/test
Building infima (0.31.4)
  - Building wheel

...

A setup.py file already exists. Using it.
Traceback (most recent call last):
  File "/Users/alexifm/Projects/pyinfima/setup.py", line 109, in <module>
    from build import *
  File "/Users/alexifm/Projects/pyinfima/build.py", line 4, in <module>
    import numpy as np
ModuleNotFoundError: No module named 'numpy'
  Stack trace:

...

  1  ~/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/core/masonry/builders/wheel.py:149 in _run_build_command
      147│ 
      148│     def _run_build_command(self, setup):
    → 149│         subprocess.check_call(
      150│             [
      151│                 self.executable.as_posix(),

  CalledProcessError

  Command '['/Users/alexifm/.local/pipx/venvs/poetry/bin/python', '/Users/alexifm/Projects/pyinfima/setup.py', 'build', '-b', '/Users/alexifm/Projects/pyinfima/build']' returned non-zero exit status 1.

  at /usr/local/Cellar/[email protected]/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py:364 in check_call
       360│     if retcode:
       361│         cmd = kwargs.get("args")
       362│         if cmd is None:
       363│             cmd = popenargs[0]
    →  364│         raise CalledProcessError(retcode, cmd)
       365│     return 0
       366│ 
       367│ 
       368│ def check_output(*popenargs, timeout=None, **kwargs):

The logs say that poetry has detected the virtualenv and will use it:

Using virtualenv: /Users/alexifm/.pyenv/versions/3.7.7/envs/test

But the called process uses the isolated pipx environment, which of course doesn't have numpy

/Users/alexifm/.local/pipx/venvs/poetry/bin/python

What's expected to happen

  • I would expect that poetry would use the proper venv /Users/alexifm/.pyenv/versions/3.7.7/envs/test
  • I also expected that the build system requirements would be installed.

Maybe I'm using Poetry wrong and it shouldn't be used in a clean environment but run as part of a development process in a worn-in environment where poetry install has been run.

That said, I still don't see why the pipx environment is being used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/docs/faqFrequently duplicated/potential addition to FAQkind/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions