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

Editable installs fail when poetry.core is declared as build-system #2956

Closed
albertogomcas opened this issue Sep 24, 2020 · 7 comments
Closed
Labels
kind/bug Something isn't working as expected

Comments

@albertogomcas
Copy link

I have created a minimal package to demonstrate this problem (which I have in a real library).

test_editable/
- test_editable/
-- __init__.py
- pyproject.toml #generated with poetry init
- setup.py # shim

The setup.py file is:

import setuptools

if __name__ == "__main__":
    setuptools.setup(name="test_editable")   # without the name the package is installed as UNKNOWN

The pyproject.toml file is:

[tool.poetry]
name = "test_editable"
version = "0.1.0"
description = "test poetry editable problem"
authors = ["albertogomcas"]
license = "mit"

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

[tool.poetry.dev-dependencies]

[build-system]
#requires = ["poetry>=0.12"]
#build-backend = "poetry.masonry.api"
requires = ["poetry-core>=1.0.0a3"]
build-backend = "poetry.core.masonry.api"

As is above, pip install -e . fails with:

Looking in indexes: https://pypi.org/simple
Obtaining file:///C:/test_editable
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Installing collected packages: test-editable
  Attempting uninstall: test-editable
    Found existing installation: test-editable 0.1.0
    Uninstalling test-editable-0.1.0:
      Successfully uninstalled test-editable-0.1.0
  Running setup.py develop for test-editable
    ERROR: Command errored out with exit status 1:
     command: 'c:\winpython64-master@66fb39fabeb\wpy64-3680\python-3.6.8.amd64\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\test_editable\\setup.py'"'"'; __file__='"'"'C:\\test_editable\\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: C:\test_editable\
    Complete output (3 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ModuleNotFoundError: No module named 'setuptools'
    ----------------------------------------
  Rolling back uninstall of test-editable

However, if I comment the build system lines with core and use instead the upper two:

Looking in indexes: https://pypi.org/simple
Obtaining file:///C:/test_editable
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Installing collected packages: test-editable
  Attempting uninstall: test-editable
    Found existing installation: test-editable 0.1.0
    Uninstalling test-editable-0.1.0:
      Successfully uninstalled test-editable-0.1.0
  Running setup.py develop for test-editable
Successfully installed test-editable

I believe the option that works is actually deprecated (?)

@albertogomcas albertogomcas added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Sep 24, 2020
@abn
Copy link
Member

abn commented Sep 24, 2020

@albertogomcas why I think it works for the poetry backend is because currently, when the PEP518 requirements are processed, poetry will also pull in setuptools. With poetry-core this is not the case. This will work if you, for example, updated build-system table to contain requires = ["poetry-core>=1.0.0a3", "setuptools"]. But since this is for development only, I would suggest using python setup.py develop instead if you virtualenv already has setuptools available.

Seems you are not able to use --no-use-pep517 when a build-system is defined.

If you want to trace whats happening, try passing in -vvv to pip.

@albireox
Copy link

albireox commented Feb 11, 2021

I'm running into the same issue. Note that adding setuptools to requires works but has some undesired effects. For example, it doesn't handle the include section well. If you add your README to the include section, it will install it out of place if you do pip install . Overall, poetry-core doesn't seem to work well if setuptools is also passed as a setup requirement, not sure if that's a bug.

python setup.py develop seems to work fine as far as I can see.

@brechtm
Copy link

brechtm commented Oct 7, 2021

I couldn't get this working. There are two issues with the suggestions described above:

  1. The minimal setup.py does not register entry points ('plugins' in pyproject.toml)
  2. python /path/to/another_project/setup.py develop does not result in a working editable installation of another_project (the CWD path is written to the .pth files in the virtualenv)

I miss being able to editable-install my Poetry-managed project into an arbitrary virtualenv for debugging purposes. I now need to fall back to installing in non-editable mode over and over.

@finswimmer
Copy link
Member

Editable installs for PEP-517 compliant backend wasn't possible for a long time, because it wasn't defined how to do this. This has changed with PEP 660. The hook is already implemented in poetry-core's master branch.

@RafalSkolasinski
Copy link

@finswimmer any hint when that may make to the release?

It does not seem it is enough to install poetry from master with

curl -sSL https://install.python-poetry.org | python3 - --git https://github.com/python-poetry/poetry.git@master

@abn abn removed the status/triage This issue needs to be triaged label Mar 3, 2022
@Jacob-Stevens-Haas
Copy link

See https://python-poetry.org/docs/faq/#is-tox-supported:

The following works for me in pyproject.toml:

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

Jacob-Stevens-Haas added a commit to Jacob-Stevens-Haas/derivative that referenced this issue Jun 18, 2022
This allows editable installs of packages without a setup.py, a la
```
pip install -e derivative
```

PEP-660 supported by poetry.core ~=1.0.0.  Following recommendation
in
python-poetry/poetry#2956 (comment)
and
https://python-poetry.org/docs/faq/#is-tox-supported
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

7 participants