Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Python_Packaging_Authority
pip
提交
de633cdf
P
pip
项目概览
镜像
/
Python_Packaging_Authority
/
pip
12 个月 前同步成功
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
pip
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
de633cdf
编写于
4月 10, 2020
作者:
P
Pradyun Gedam
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Significantly improve release version validation
上级
4416e88e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
60 addition
and
16 deletion
+60
-16
noxfile.py
noxfile.py
+4
-4
tools/automation/release/__init__.py
tools/automation/release/__init__.py
+13
-12
tools/automation/release/check_version.py
tools/automation/release/check_version.py
+43
-0
未找到文件。
noxfile.py
浏览文件 @
de633cdf
...
...
@@ -155,9 +155,9 @@ def lint(session):
# -----------------------------------------------------------------------------
@
nox
.
session
(
name
=
"prepare-release"
)
def
prepare_release
(
session
):
version
=
release
.
get_version_from_arguments
(
session
.
posargs
)
version
=
release
.
get_version_from_arguments
(
session
)
if
not
version
:
session
.
error
(
"Usage: nox -s prepare-release --
YY.N[.P]
"
)
session
.
error
(
"Usage: nox -s prepare-release --
<version>
"
)
session
.
log
(
"# Ensure nothing is staged"
)
if
release
.
modified_files_in_git
(
"--staged"
):
...
...
@@ -190,7 +190,7 @@ def prepare_release(session):
@
nox
.
session
(
name
=
"build-release"
)
def
build_release
(
session
):
version
=
release
.
get_version_from_arguments
(
session
.
posargs
)
version
=
release
.
get_version_from_arguments
(
session
)
if
not
version
:
session
.
error
(
"Usage: nox -s build-release -- YY.N[.P]"
)
...
...
@@ -249,7 +249,7 @@ def build_dists(session):
@
nox
.
session
(
name
=
"upload-release"
)
def
upload_release
(
session
):
version
=
release
.
get_version_from_arguments
(
session
.
posargs
)
version
=
release
.
get_version_from_arguments
(
session
)
if
not
version
:
session
.
error
(
"Usage: nox -s upload-release -- YY.N[.P]"
)
...
...
tools/automation/release/__init__.py
浏览文件 @
de633cdf
...
...
@@ -14,24 +14,25 @@ from typing import Iterator, List, Optional, Set
from
nox.sessions
import
Session
def
get_version_from_arguments
(
arguments
:
List
[
str
]
)
->
Optional
[
str
]:
def
get_version_from_arguments
(
session
:
Session
)
->
Optional
[
str
]:
"""Checks the arguments passed to `nox -s release`.
If there is only 1 argument that looks like a pip version, returns that.
Otherwise, returns None.
"""
if
len
(
argument
s
)
!=
1
:
if
len
(
session
.
posarg
s
)
!=
1
:
return
None
version
=
arguments
[
0
]
parts
=
version
.
split
(
'.'
)
if
not
2
<=
len
(
parts
)
<=
3
:
# Not of the form: YY.N or YY.N.P
return
None
if
not
all
(
part
.
isdigit
()
for
part
in
parts
):
# Not all segments are integers.
version
=
session
.
posargs
[
0
]
# We delegate to a script here, so that it can depend on packaging.
session
.
install
(
"packaging"
)
cmd
=
[
os
.
path
.
join
(
session
.
bin
,
"python"
),
"tools/automation/release/check_version.py"
,
version
]
not_ok
=
subprocess
.
run
(
cmd
).
returncode
if
not_ok
:
return
None
# All is good.
...
...
tools/automation/release/check_version.py
0 → 100644
浏览文件 @
de633cdf
"""Checks if the version is acceptable, as per this project's release process.
"""
import
sys
from
datetime
import
datetime
from
typing
import
Optional
from
packaging.version
import
InvalidVersion
,
Version
def
is_this_a_good_version_number
(
string
:
str
)
->
Optional
[
str
]:
try
:
v
=
Version
(
string
)
except
InvalidVersion
as
e
:
return
str
(
e
)
if
v
.
local
:
return
"Nope. PyPI refuses local release versions."
if
v
.
dev
:
return
"No development releases on PyPI. What are you even thinking?"
if
v
.
is_prerelease
and
v
.
pre
[
0
]
!=
"b"
:
return
"Only beta releases are allowed. No alphas."
release
=
v
.
release
expected_major
=
datetime
.
now
().
year
%
100
if
len
(
release
)
not
in
[
2
,
3
]:
return
"Not of the form: {0}.N or {0}.N.P"
.
format
(
expected_major
)
return
None
def
main
()
->
None
:
problem
=
is_this_a_good_version_number
(
sys
.
argv
[
1
])
if
problem
is
not
None
:
print
(
"ERROR:"
,
problem
)
sys
.
exit
(
1
)
if
__name__
==
"__main__"
:
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录