1
1
from __future__ import annotations
2
2
3
+ import logging
3
4
from abc import ABC
4
5
from argparse import SUPPRESS
5
6
from pathlib import Path
6
- from warnings import warn
7
7
8
8
from virtualenv .seed .seeder import Seeder
9
9
from virtualenv .seed .wheels import Version
10
10
11
+ LOGGER = logging .getLogger (__name__ )
11
12
PERIODIC_UPDATE_ON_BY_DEFAULT = True
12
13
13
14
@@ -20,24 +21,27 @@ def __init__(self, options) -> None:
20
21
21
22
self .pip_version = options .pip
22
23
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"
35
29
36
30
self .no_pip = options .no_pip
37
31
self .no_setuptools = options .no_setuptools
32
+ self .no_wheel = options .no_wheel
38
33
self .app_data = options .app_data
39
34
self .periodic_update = not options .no_periodic_update
40
35
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
+
41
45
if not self .distribution_to_versions ():
42
46
self .enabled = False
43
47
@@ -53,7 +57,8 @@ def distribution_to_versions(self) -> dict[str, str]:
53
57
return {
54
58
distribution : getattr (self , f"{ distribution } _version" )
55
59
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"
57
62
}
58
63
59
64
@classmethod
@@ -83,15 +88,17 @@ def add_parser_arguments(cls, parser, interpreter, app_data): # noqa: ARG003
83
88
default = [],
84
89
)
85
90
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" }:
87
93
default = "none" # noqa: PLW2901
88
94
if interpreter .version_info [:2 ] >= (3 , 9 ) and distribution == "wheel" :
89
- continue
95
+ default = None # noqa: PLW2901
96
+ help_ = SUPPRESS
90
97
parser .add_argument (
91
98
f"--{ distribution } " ,
92
99
dest = distribution ,
93
100
metavar = "version" ,
94
- help = f"version of { distribution } to install as seed: embed, bundle, none or exact version" ,
101
+ help = help_ ,
95
102
default = default ,
96
103
)
97
104
for distribution in cls .distributions ():
0 commit comments