Skip to content

Commit

Permalink
Applied more suggestions and added test
Browse files Browse the repository at this point in the history
  • Loading branch information
chrysle committed Apr 27, 2023
1 parent a32e69f commit a0390e7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
3 changes: 2 additions & 1 deletion docs/user_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ at the moment has two types of virtual environments:
Seeders
-------
These will install for you some seed packages (one or more of: :pypi:`pip`, :pypi:`setuptools`, :pypi:`wheel`) that
enables you to install additional python packages into the created virtual environment (by invoking pip). Installing :pypi:`setuptools` and :pypi:`wheel` is disabled by default on Python 3.12+ environments. There are two
enables you to install additional python packages into the created virtual environment (by invoking pip). Installing
:pypi:`setuptools` and :pypi:`wheel` is disabled by default on Python 3.12+ environments. There are two
main seed mechanisms available:

- ``pip`` - this method uses the bundled pip with virtualenv to install the seed packages (note, a new child process
Expand Down
5 changes: 3 additions & 2 deletions src/virtualenv/seed/embed/base_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ..seeder import Seeder
from ..wheels import Version

PERIODIC_UPDATE_ON_BY_DEFAULT, OPTIONAL_DISTS = True, {"wheel", "setuptools"}
PERIODIC_UPDATE_ON_BY_DEFAULT = True


class BaseEmbed(Seeder, metaclass=ABCMeta):
Expand Down Expand Up @@ -85,7 +85,8 @@ def add_parser_arguments(cls, parser, interpreter, app_data): # noqa: U100
action="store_true",
help=f"do not install {distribution}",
default=True
if (float(interpreter.version_str.rsplit(".", 1)[0]) >= 12) and (distribution in OPTIONAL_DISTS)
if (float(interpreter.version.split(" ")[0].rsplit(".", 1)[0]) >= 12)
and (distribution in {"wheel", "setuptools"})
else False,
)
parser.add_argument(
Expand Down
18 changes: 18 additions & 0 deletions tests/unit/seed/embed/test_base_embed.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations

import sys

import pytest

from virtualenv.run import session_via_cli
Expand All @@ -12,3 +14,19 @@
def test_download_cli_flag(args, download, tmp_path):
session = session_via_cli(args + [str(tmp_path)])
assert session.seeder.download is download


@pytest.mark.parametrize(
("args", "install"),
[([], True)],
)
def test_embed_optional_wheels(args, install, tmp_path):
session = session_via_cli(args + [str(tmp_path)])
if float(sys.version.split(" ")[0].rsplit(".", 1)[0]) >= 12:
assert session.seeder.no_setuptools is install
assert session.seeder.no_wheel is install
assert session.seeder.no_pip is not install
else:
assert session.seeder.no_setuptools is not install
assert session.seeder.no_wheel is not install
assert session.seeder.no_pip is not install
1 change: 0 additions & 1 deletion whitelist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ deque
devnull
distlib
distro
dists
dll
docname
doctree
Expand Down

0 comments on commit a0390e7

Please sign in to comment.