Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7d81e8f

Browse files
bpo-26544: Get rid of dependence from distutils in platform. (GH-8356)
1 parentb44a1d4 commit7d81e8f

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

‎Lib/platform.py‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,35 @@
132132
# Standard Unix uses /dev/null
133133
DEV_NULL='/dev/null'
134134

135+
# Helper for comparing two version number strings.
136+
# Based on the description of the PHP's version_compare():
137+
# http://php.net/manual/en/function.version-compare.php
138+
139+
_ver_stages= {
140+
# any string not found in this dict, will get 0 assigned
141+
'dev':10,
142+
'alpha':20,'a':20,
143+
'beta':30,'b':30,
144+
'c':40,
145+
'RC':50,'rc':50,
146+
# number, will get 100 assigned
147+
'pl':200,'p':200,
148+
}
149+
150+
_component_re=re.compile(r'([0-9]+|[._+-])')
151+
152+
def_comparable_version(version):
153+
result= []
154+
forvin_component_re.split(version):
155+
ifvnotin'._+-':
156+
try:
157+
v=int(v,10)
158+
t=100
159+
exceptValueError:
160+
t=_ver_stages.get(v,0)
161+
result.extend((t,v))
162+
returnresult
163+
135164
### Platform specific APIs
136165

137166
_libc_search=re.compile(b'(__libc_init)'
@@ -155,7 +184,7 @@ def libc_ver(executable=sys.executable, lib='', version='', chunksize=16384):
155184
The file is read and scanned in chunks of chunksize bytes.
156185
157186
"""
158-
fromdistutils.versionimportLooseVersionasV
187+
V=_comparable_version
159188
ifhasattr(os.path,'realpath'):
160189
# Python 2.2 introduced os.path.realpath(); it is used
161190
# here to work around problems with Cygwin not being

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp