11from __future__ import annotations
22
3+ import logging
34from abc import ABC
45from argparse import SUPPRESS
56from pathlib import Path
6- from warnings import warn
77
88from virtualenv .seed .seeder import Seeder
99from virtualenv .seed .wheels import Version
1010
11+ LOGGER = logging .getLogger (__name__ )
1112PERIODIC_UPDATE_ON_BY_DEFAULT = True
1213
1314
@@ -20,24 +21,27 @@ def __init__(self, options) -> None:
2021
2122 self .pip_version = options .pip
2223 self .setuptools_version = options .setuptools
23- if hasattr (options , "wheel" ):
24- # Python 3.8
25- self .wheel_version = options .wheel
26- self .no_wheel = options .no_wheel
27- elif options .no_wheel :
28- warn (
29- "The --no-wheel option is deprecated. "
30- "It has no effect for Python >= 3.8 as wheel is no longer "
31- "bundled in virtualenv." ,
32- DeprecationWarning ,
33- stacklevel = 1 ,
34- )
24+
25+ # wheel version needs special handling
26+ # on Python > 3.8, the default is None (as in not used)
27+ # so we can differentiate between explicit and implicit none
28+ self .wheel_version = options .wheel or "none"
3529
3630 self .no_pip = options .no_pip
3731 self .no_setuptools = options .no_setuptools
32+ self .no_wheel = options .no_wheel
3833 self .app_data = options .app_data
3934 self .periodic_update = not options .no_periodic_update
4035
36+ if options .py_version [:2 ] >= (3 , 9 ):
37+ if options .wheel is not None or options .no_wheel :
38+ LOGGER .warning (
39+ "The --no-wheel and --wheel options are deprecated. "
40+ "They have no effect for Python > 3.8 as wheel is no longer "
41+ "bundled in virtualenv." ,
42+ )
43+ self .no_wheel = True
44+
4145 if not self .distribution_to_versions ():
4246 self .enabled = False
4347
@@ -53,7 +57,8 @@ def distribution_to_versions(self) -> dict[str, str]:
5357 return {
5458 distribution : getattr (self , f"{ distribution } _version" )
5559 for distribution in self .distributions ()
56- if getattr (self , f"no_{ distribution } " , None ) is False and getattr (self , f"{ distribution } _version" ) != "none"
60+ if getattr (self , f"no_{ distribution } " , None ) is False
61+ and getattr (self , f"{ distribution } _version" ) != "none"
5762 }
5863
5964 @classmethod
@@ -83,15 +88,17 @@ def add_parser_arguments(cls, parser, interpreter, app_data): # noqa: ARG003
8388 default = [],
8489 )
8590 for distribution , default in cls .distributions ().items ():
86- if interpreter .version_info [:2 ] >= (3 , 12 ) and distribution == "setuptools" :
91+ help_ = f"version of { distribution } to install as seed: embed, bundle, none or exact version"
92+ if interpreter .version_info [:2 ] >= (3 , 12 ) and distribution in {"wheel" , "setuptools" }:
8793 default = "none" # noqa: PLW2901
8894 if interpreter .version_info [:2 ] >= (3 , 9 ) and distribution == "wheel" :
89- continue
95+ default = None # noqa: PLW2901
96+ help_ = SUPPRESS
9097 parser .add_argument (
9198 f"--{ distribution } " ,
9299 dest = distribution ,
93100 metavar = "version" ,
94- help = f"version of { distribution } to install as seed: embed, bundle, none or exact version" ,
101+ help = help_ ,
95102 default = default ,
96103 )
97104 for distribution in cls .distributions ():
0 commit comments