- Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathapi.py
60 lines (42 loc) · 1.83 KB
/
api.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# SPDX-License-Identifier: BSD-2-Clause
# Copyright (c) 2024 Phil Thompson <phil@riverbankcomputing.com>
from .abstract_projectimportAbstractProject
from .exceptionsimporthandle_exception
defbuild_sdist(sdist_directory, config_settings=None):
""" The PEP 517 hook for building an sdist from pyproject.toml. """
project=AbstractProject.bootstrap('sdist',
arguments=_convert_config_settings(config_settings))
# pip executes this in a separate process and doesn't handle exceptions
# very well. However it does capture stdout and (eventually) show it to
# the user so we use our standard exception handling.
try:
returnproject.build_sdist(sdist_directory)
exceptExceptionase:
handle_exception(e)
defbuild_wheel(wheel_directory, config_settings=None, metadata_directory=None):
""" The PEP 517 hook for building a wheel from pyproject.toml. """
project=AbstractProject.bootstrap('wheel',
arguments=_convert_config_settings(config_settings))
# pip executes this in a separate process and doesn't handle exceptions
# very well. However it does capture stdout and (eventually) show it to
# the user so we use our standard exception handling.
try:
returnproject.build_wheel(wheel_directory)
exceptExceptionase:
handle_exception(e)
def_convert_config_settings(config_settings):
""" Return any configuration settings from the frontend to a pseudo-command
line.
"""
ifconfig_settingsisNone:
config_settings= {}
args= []
forname, valueinconfig_settings.items():
ifvalue:
ifnotisinstance(value, list):
value= [value]
form_valueinvalue:
args.append(name+'='+m_value)
else:
args.append(name)
returnargs