Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
后端镜像
Pdm
提交
a6a88bab
P
Pdm
项目概览
后端镜像
/
Pdm
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Pdm
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
a6a88bab
编写于
3月 05, 2021
作者:
F
Frost Ming
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add support for `-f setuppy`
上级
e2d54006
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
90 addition
and
4 deletion
+90
-4
LICENSE
LICENSE
+1
-1
news/289.feature.md
news/289.feature.md
+1
-0
pdm/formats/__init__.py
pdm/formats/__init__.py
+31
-2
pdm/formats/setup_py.py
pdm/formats/setup_py.py
+16
-0
tests/fixtures/projects/demo-package/setup.py
tests/fixtures/projects/demo-package/setup.py
+33
-0
tests/test_formats.py
tests/test_formats.py
+8
-1
未找到文件。
LICENSE
浏览文件 @
a6a88bab
MIT License
MIT License
Copyright (c) 2019-202
0
Frost Ming
Copyright (c) 2019-202
1
Frost Ming
Permission is hereby granted, free of charge, to any person obtaining a copy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
of this software and associated documentation files (the "Software"), to deal
...
...
news/289.feature.md
0 → 100644
浏览文件 @
a6a88bab
Support
`-f setuppy`
for
`pdm export`
to export the metadata as setup.py
pdm/formats/__init__.py
浏览文件 @
a6a88bab
from
pdm.formats
import
flit
,
legacy
,
pipfile
,
poetry
,
requirement
s
from
__future__
import
annotation
s
FORMATS
=
{
import
os
from
typing
import
TYPE_CHECKING
,
Dict
,
Iterable
,
Protocol
,
Tuple
from
pdm.formats
import
flit
,
legacy
,
pipfile
,
poetry
,
requirements
,
setup_py
if
TYPE_CHECKING
:
import
argparse
from
pdm.models.candidates
import
Candidate
from
pdm.project
import
Project
class
FormatConverter
(
Protocol
):
def
check_fingerprint
(
self
,
project
:
Project
,
filename
:
os
.
PathLike
)
->
bool
:
...
def
convert
(
self
,
project
:
Project
,
filename
:
os
.
PathLike
)
->
Tuple
[
dict
,
dict
]:
...
def
export
(
self
,
project
:
Project
,
candidates
:
Iterable
[
Candidate
],
options
:
argparse
.
Namespace
,
)
->
str
:
...
FORMATS
:
Dict
[
str
,
FormatConverter
]
=
{
"pipfile"
:
pipfile
,
"pipfile"
:
pipfile
,
"poetry"
:
poetry
,
"poetry"
:
poetry
,
"flit"
:
flit
,
"flit"
:
flit
,
"requirements"
:
requirements
,
"requirements"
:
requirements
,
"legacy"
:
legacy
,
"legacy"
:
legacy
,
"setuppy"
:
setup_py
,
}
}
pdm/formats/setup_py.py
浏览文件 @
a6a88bab
import
os
def
check_fingerprint
(
project
,
filename
):
return
os
.
path
.
basename
(
filename
)
==
"setup.py"
def
convert
(
project
,
filename
):
raise
NotImplementedError
()
def
export
(
project
,
candidates
,
options
):
from
pdm.pep517.base
import
Builder
builder
=
Builder
(
project
.
root
)
return
builder
.
format_setup_py
()
tests/fixtures/projects/demo-package/setup.py
0 → 100644
浏览文件 @
a6a88bab
# -*- coding: utf-8 -*-
from
setuptools
import
setup
import
codecs
with
codecs
.
open
(
"README.md"
,
encoding
=
"utf-8"
)
as
fp
:
long_description
=
fp
.
read
()
INSTALL_REQUIRES
=
[
"flask"
,
]
setup_kwargs
=
{
"name"
:
"demo-package"
,
"version"
:
"0.1.0"
,
"description"
:
""
,
"long_description"
:
long_description
,
"license"
:
"MIT"
,
"author"
:
""
,
"author_email"
:
"frostming <mianghong@gmail.com>"
,
"maintainer"
:
None
,
"maintainer_email"
:
None
,
"url"
:
""
,
"packages"
:
[
"my_package"
,
],
"package_data"
:
{
""
:
[
"*"
]},
"long_description_content_type"
:
"text/markdown"
,
"install_requires"
:
INSTALL_REQUIRES
,
"python_requires"
:
">=3.5"
,
}
setup
(
**
setup_kwargs
)
tests/test_formats.py
浏览文件 @
a6a88bab
from
pdm.formats
import
flit
,
legacy
,
pipfile
,
poetry
,
requirements
from
pdm.formats
import
flit
,
legacy
,
pipfile
,
poetry
,
requirements
,
setup_py
from
pdm.project
import
Project
from
pdm.utils
import
cd
from
pdm.utils
import
cd
from
tests
import
FIXTURES
from
tests
import
FIXTURES
...
@@ -126,3 +127,9 @@ def test_convert_legacy_format(project):
...
@@ -126,3 +127,9 @@ def test_convert_legacy_format(project):
assert
not
result
[
"dev-dependencies"
]
assert
not
result
[
"dev-dependencies"
]
assert
result
[
"optional-dependencies"
][
"test"
]
==
[
"pytest"
]
assert
result
[
"optional-dependencies"
][
"test"
]
==
[
"pytest"
]
assert
settings
[
"source"
][
0
][
"url"
]
==
"https://test.pypi.org/simple"
assert
settings
[
"source"
][
0
][
"url"
]
==
"https://test.pypi.org/simple"
def
test_export_setup_py
():
project
=
Project
(
FIXTURES
/
"projects/demo-package"
)
content
=
setup_py
.
export
(
project
,
[],
None
)
assert
content
==
project
.
root
.
joinpath
(
"setup.py"
).
read_text
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录