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

--no-deps argument is ignored when a pyproject.toml file is present #7444

Closed
wakemaster39 opened this issue Dec 7, 2019 · 5 comments
Closed
Labels
auto-locked Outdated issues that have been locked by automation C: PEP 517 impact Affected by PEP 517 processing type: support User Support

Comments

@wakemaster39
Copy link

Environment

  • pip version: 19.3.1
  • Python version: 3.8
  • OS: MacOS

Description

When installing an editable install and a pyproject.toml file is present, the --no-deps argument is ignored.

Expected behavior
The --no-deps argument should be respected and no dependencies installed

How to Reproduce

  1. git clone https://github.com/psf/black.git
  2. mkdir test
  3. cd test
  4. python3 -m venv .venv
  5. source .venv/bin/activate
  6. pip install --no-deps -U -e ../black/

Output

With pyproject.toml present

Obtaining file:///Users/cahurst/code/black
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Installing collected packages: black
  Running setup.py develop for black
Successfully installed black

Without pyproject.toml

Obtaining file:///Users/cahurst/code/black
Installing collected packages: black
  Running setup.py develop for black
Successfully installed black

I also tested this just trying to remove any of the build system lines and the --no-deps is still ignored.

@chrahunt
Copy link
Member

chrahunt commented Dec 7, 2019

Try invoking pip with the --no-build-isolation flag (you should have setuptools already installed in your environment).

When a pyproject.toml file is present it opts the package into PEP 517/518 as described in the docs. Specifically, pip is required to invoke the build backend in an environment with the explicit or implicit dependencies installed.

@chrahunt chrahunt added C: PEP 517 impact Affected by PEP 517 processing S: awaiting response Waiting for a response/more information type: support User Support labels Dec 7, 2019
@triage-new-issues triage-new-issues bot removed the S: needs triage Issues/PRs that need to be triaged label Dec 7, 2019
@uranusjr
Copy link
Member

uranusjr commented Dec 7, 2019

In any case, --no-deps does not affect build dependencies, since pip won’t be able to install the package otherwise if it needs building. What you see is unavoidable for projects using the build isolation mechanism.

@wakemaster39
Copy link
Author

wakemaster39 commented Dec 7, 2019

I suppose using black as an example repo was the wrong choice then in this case. I didn't confirm it was giving me the same error/output originally. I also realize the difference of the build-dependency line now sorry for the confusion there.

I am using poetry for a package that led me to this issue. I know this isn't a poetry support repo, but I used it to output a setup.py for my project and I am trying to install it now.

# -*- coding: utf-8 -*-
from setuptools import setup

package_dir = \
{'': 'src'}

packages = \
[XXX_PACKAGE_LIST_HERE_XXX]

package_data = \
{'': ['*']}

install_requires = \
['attrs>=19.3,<20.0',
 'cx-labs-utils>=5.0.0-alpha.2,<6.0.0',
 'more-itertools>=7.2,<8.0',
 'netaddr>=0.7.19,<0.8.0']

setup_kwargs = {
    'name': 'cx-labs-core',
    'version': '6.0.0a3',
    'long_description': None,
    'author': 'Cameron Hurst',
    'maintainer': None,
    'maintainer_email': None,
    'package_dir': package_dir,
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'python_requires': '>=3.8,<4.0',
}


setup(**setup_kwargs)

Running pip install --no-deps -U -e ../src/cx-labs-core gives the following output:

errored with the following return code 1, and output:
Obtaining file:///Users/cahurst/Library/Caches/pypoetry/virtualenvs/ae-cx-labs-9umIzy8z-py3.8/src/cx-labs-core
  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'
  Installing backend dependencies: started
  Installing backend dependencies: finished with status 'error'
  ERROR: Command errored out with exit status 1:
   command: /Users/cahurst/Library/Caches/pypoetry/virtualenvs/ae-cx-labs-9umIzy8z-py3.8/bin/python /Users/cahurst/Library/Caches/pypoetry/virtualenvs/ae-cx-labs-9umIzy8z-py3.8/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /private/var/folders/y5/s4rz6yd523x6nkm88_204zvr0000gn/T/pip-build-env-11j9u96w/normal --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'more-itertools>=7.2,<8.0' 'netaddr>=0.7.19,<0.8.0' 'cx-labs-utils>=5.0.0-alpha.2,<6.0.0'
       cwd: None
  Complete output (9 lines):
  Collecting more-itertools<8.0,>=7.2
    Using cached https://files.pythonhosted.org/packages/45/dc/3241eef99eb45f1def35cf93af35d1cf9ef4c0991792583b8f33ea41b092/more_itertools-7.2.0-py3-none-any.whl
  Collecting netaddr<0.8.0,>=0.7.19
    Using cached https://files.pythonhosted.org/packages/ba/97/ce14451a9fd7bdb5a397abf99b24a1a6bb7a1a440b019bebd2e9a0dbec74/netaddr-0.7.19-py2.py3-none-any.whl
  Collecting cx-labs-utils<6.0.0,>=5.0.0-alpha.2
    ERROR: Could not find a version that satisfies the requirement cx-labs-utils<6.0.0,>=5.0.0-alpha.2 (from versions: none)
  ERROR: No matching distribution found for cx-labs-utils<6.0.0,>=5.0.0-alpha.2
  WARNING: You are using pip version 19.2.3, however version 19.3.1 is available.
  You should consider upgrading via the 'pip install --upgrade pip' command.

I know why the install backend dependency step is failing, it is because the package exists on private pypi repository that it doesn't now about. What I don't understand is why it is getting called.

Inside the pyproject.toml file I have the block below. Removing this causes everything to work as expected. Is this a problem with having this build back end? I have went in an attempted to detect when anything in that file is being called and I cannot find a call, it seems it is all internal to pip.

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

@no-response no-response bot removed the S: awaiting response Waiting for a response/more information label Dec 7, 2019
@uranusjr
Copy link
Member

uranusjr commented Dec 7, 2019

I know why the install backend dependency step is failing, it is because the package exists on private pypi repository that it doesn't now about. What I don't understand is why it is getting called.

The backend is getting called because pip needs it to install the package. It is also called if you remove the definitions in pyproject.toml (but not delete the file entirely), although the backend would be different in this case—by default pip uses setuptools as backend.

So the problem here is why --no-deps gets ignored when you use Poetry as the backend. And I don’t have the answer (without digging into the implementation). Maybe pip doesn’t correctly pass this request to it. Maybe Poetry doesn’t interpret this correctly. Maybe --no-deps is just not specified so Poetry doesn’t even know it should implement it.

@wakemaster39
Copy link
Author

Thank you for your help @uranusjr you gave me enough information that I was able to track down how the process flow is being called in pip to see that while the build step is being called by pip the requirements are flowing by from the backend.

I didn't really understand build isolation till now and how it is getting its own copy and all my hook work I was trying to do was failing miserably. This is definitely not a pip issue and is a backend problem.

wakemaster39 pushed a commit to wakemaster39/poetry that referenced this issue Dec 12, 2019
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jan 6, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Jan 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation C: PEP 517 impact Affected by PEP 517 processing type: support User Support
Projects
None yet
Development

No branches or pull requests

3 participants