Skip to content

Create virtualenv with direct URLs in requirements.txt #22423

Closed

Description

Hi,

I'm not sure if this is a bug or a feature request.

I'm trying the new Create Virtual environment feature with the following test project:

pyproject.toml

[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "vscodetest"
version = "1.0"
dependencies = ["pip-test-package"]

requirements.txt

pip-test-package @ git+https://github.com/pypa/pip-test-package

The idea is to have abstract unpinned dependencies in project.dependencies and pinned dependencies in requirements.txt.

When I do >Python: Create Environment..., select .venv, then requirements.txt, vscode

  • creates the virtual environment
  • upgrades pip
  • then tries to pip install --editable .

This fails because the pip-test-package dependency is not available on PyPI.

Ideally, it should install requirements.txt in the same command as the editable install: pip install -e . -r requirements.txt.

Activity

  1. sbidoul commented on Nov 4, 2023

    @sbidoul
    Author

    Hm, actually, I think this could be considered a bug. Assume the following project:

    pyproject.toml

    [build-system]
    requires = ["setuptools", "wheel"]
    build-backend = "setuptools.build_meta"
    
    [project]
    name = "vscodetest"
    version = "1.0"
    dependencies = ["urllib3"]

    requirements.txt

    urllib3==2.0.6
    

    Notice we pin urllib3 2.0.6 in requirements.txt.

    In the venv creation log, we see vscode first doing an editable install of the project, and downloading and installing the latest urllib3 2.0.7. And after that, it installs requirements.txt and therefore urllib3 2.0.6.

    The end result is correct but it involved a useless initial install of an unwanted version.

  2. sbidoul commented on Nov 4, 2023

    @sbidoul
    Author

    BTW, this is a super cool feature, thanks for working on this!

  3. added
    needs PRReady to be worked on
    area-environmentsFeatures relating to handling interpreter environments
    and removed
    triage-neededNeeds assignment to the proper sub-team
    on Nov 6, 2023
  4. locked as resolved and limited conversation to collaborators on Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-environmentsFeatures relating to handling interpreter environmentsfeature-requestRequest for new features or functionality

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions