Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
后端镜像
Pdm
提交
5f440c15
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,发现更多精彩内容 >>
未验证
提交
5f440c15
编写于
3月 20, 2020
作者:
F
frostming
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support build script
上级
dd3a34e6
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
65 addition
and
1 deletion
+65
-1
docs/docs/pyproject.md
docs/docs/pyproject.md
+26
-0
news/23.feature
news/23.feature
+1
-0
pdm/builders/base.py
pdm/builders/base.py
+13
-0
pdm/builders/wheel.py
pdm/builders/wheel.py
+25
-1
未找到文件。
docs/docs/pyproject.md
浏览文件 @
5f440c15
...
...
@@ -94,3 +94,29 @@ format of `[tool.pdm.cli]` format:
[tool.pdm.entry_points.pytest11]
myplugin
=
"mypackage.plugin:pytest_plugin"
```
## Build C extensions
Currently building C extensions still rely on
`setuptools`
. You should write a python script which contains
a function named
`build`
and accepts the arguments dictionary of
`setup()`
as the only parameter.
In the function, update the dictionary with your
`ext_modules`
settings.
Here is an example taken from
`MarkupSafe`
:
```
python
# build.py
from
setuptools
import
Extension
ext_modules
=
[
Extension
(
"markupsafe._speedups"
,
[
"src/markupsafe/_speedups.c"
])]
def
build
(
setup_kwargs
):
setup_kwargs
.
update
(
ext_modules
=
ext_modules
)
```
Now, specify the build script path via
`build`
in the
`pyproject.toml`
:
```
toml
# pyproject.toml
[tool.pdm]
build
=
"build.py"
```
news/23.feature
0 → 100644
浏览文件 @
5f440c15
Support
specifying
build
script
for
C
extensions.
pdm/builders/base.py
浏览文件 @
5f440c15
...
...
@@ -195,6 +195,9 @@ class Builder:
if
not
include_build
:
return
if
self
.
meta
.
build
and
os
.
path
.
isfile
(
self
.
meta
.
build
):
yield
self
.
meta
.
build
for
pat
in
(
"COPYING"
,
"LICENSE"
):
for
path
in
glob
.
glob
(
pat
+
"*"
):
if
os
.
path
.
isfile
(
path
):
...
...
@@ -229,6 +232,16 @@ class Builder:
"url"
:
meta
.
homepage
,
}
if
meta
.
build
:
# The build script must contain a `build(setup_kwargs)`, we just import
# and execute it.
after
.
extend
(
[
"from {} import build
\n
"
.
format
(
meta
.
build
.
split
(
"."
)[
0
]),
"build(setup_kwargs)
\n
"
,
]
)
package_paths
=
meta
.
convert_package_paths
()
if
package_paths
[
"packages"
]:
extra
.
append
(
" 'packages': {!r},
\n
"
.
format
(
package_paths
[
"packages"
]))
...
...
pdm/builders/wheel.py
浏览文件 @
5f440c15
...
...
@@ -4,6 +4,7 @@ import hashlib
import
os
import
shutil
import
stat
import
subprocess
import
tempfile
import
zipfile
from
base64
import
urlsafe_b64encode
...
...
@@ -178,7 +179,30 @@ class WheelBuilder(Builder):
if
not
self
.
meta
.
build
:
return
self
.
ensure_setup_py
()
# TODO: C extension build
setup_py
=
self
.
ireq
.
setup_py_path
build_args
=
[
self
.
project
.
environment
.
python_executable
,
setup_py
,
"build"
,
"-b"
,
str
(
self
.
project
.
root
/
"build"
),
]
subprocess
.
run
(
build_args
,
capture_output
=
stream
.
verbosity
>=
stream
.
DETAIL
,
check
=
True
)
build_dir
=
self
.
project
.
root
/
"build"
lib_dir
=
next
(
build_dir
.
glob
(
"lib.*"
),
None
)
if
not
lib_dir
:
return
for
pkg
in
lib_dir
.
glob
(
"**/*"
):
if
pkg
.
is_dir
():
continue
rel_path
=
str
(
pkg
.
relative_to
(
lib_dir
))
if
rel_path
in
wheel
.
namelist
():
continue
self
.
_add_file
(
wheel
,
pkg
,
rel_path
)
def
_copy_module
(
self
,
wheel
):
for
path
in
self
.
find_files_to_add
():
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录