Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
33546858
Commit
33546858
authored
Sep 03, 2017
by
xoviat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: add get_requires_for_build_wheel
parent
bfe0ee27
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
24 deletions
+54
-24
setuptools/pep517.py
setuptools/pep517.py
+10
-0
setuptools/tests/test_pep517.py
setuptools/tests/test_pep517.py
+44
-24
No files found.
setuptools/pep517.py
View file @
33546858
...
...
@@ -21,7 +21,13 @@ def _run_setup(setup_script='setup.py'): #
exec
(
compile
(
code
,
__file__
,
'exec'
))
def
fix_config
(
config_settings
):
config_settings
=
config_settings
or
{}
config_settings
.
setdefault
(
'--global-option'
,
[])
return
config_settings
def
get_build_requires
(
config_settings
):
config_settings
=
fix_config
(
config_settings
)
requirements
=
[
'setuptools'
,
'wheel'
]
dist
.
skip_install_eggs
=
True
...
...
@@ -38,10 +44,12 @@ def get_build_requires(config_settings):
def
get_requires_for_build_wheel
(
config_settings
=
None
):
config_settings
=
fix_config
(
config_settings
)
return
get_build_requires
(
config_settings
)
def
get_requires_for_build_sdist
(
config_settings
=
None
):
config_settings
=
fix_config
(
config_settings
)
return
get_build_requires
(
config_settings
)
...
...
@@ -51,6 +59,7 @@ def prepare_metadata_for_build_wheel(metadata_directory, config_settings=None):
def
build_wheel
(
wheel_directory
,
config_settings
=
None
,
metadata_directory
=
None
):
config_settings
=
fix_config
(
config_settings
)
wheel_directory
=
os
.
path
.
abspath
(
wheel_directory
)
sys
.
argv
=
sys
.
argv
[:
1
]
+
[
'bdist_wheel'
]
+
\
config_settings
[
"--global-option"
]
...
...
@@ -61,6 +70,7 @@ def build_wheel(wheel_directory, config_settings=None,
def
build_sdist
(
sdist_directory
,
config_settings
=
None
):
config_settings
=
fix_config
(
config_settings
)
sdist_directory
=
os
.
path
.
abspath
(
sdist_directory
)
sys
.
argv
=
sys
.
argv
[:
1
]
+
[
'sdist'
]
+
\
config_settings
[
"--global-option"
]
...
...
setuptools/tests/test_pep517.py
View file @
33546858
...
...
@@ -6,7 +6,9 @@ import os
# a concurrent.futures backport for testing
pytest
.
importorskip
(
'concurrent.futures'
)
from
contextlib
import
contextmanager
from
importlib
import
import_module
from
tempfile
import
mkdtemp
from
concurrent.futures
import
ProcessPoolExecutor
from
.files
import
build_files
from
.textwrap
import
DALS
...
...
@@ -24,10 +26,10 @@ class BuildBackend(object):
def
__getattr__
(
self
,
name
):
"""Handles aribrary function invokations on the build backend."""
def
method
(
**
kw
):
def
method
(
*
args
,
*
*
kw
):
return
self
.
pool
.
submit
(
BuildBackendCaller
(
self
.
cwd
,
self
.
env
,
self
.
backend_name
),
(
name
,
kw
)).
result
()
(
name
,
args
,
kw
)).
result
()
return
method
...
...
@@ -38,21 +40,33 @@ class BuildBackendCaller(object):
self
.
env
=
env
self
.
backend_name
=
backend_name
def
__
getattr__
(
self
,
name
):
def
__
call__
(
self
,
info
):
"""Handles aribrary function invokations on the build backend."""
os
.
chdir
(
self
.
cwd
)
os
.
environ
.
update
(
self
.
env
)
return
getattr
(
import_module
(
self
.
backend_name
),
name
)
name
,
args
,
kw
=
info
return
getattr
(
import_module
(
self
.
backend_name
),
name
)(
*
args
,
**
kw
)
@
contextmanager
def
enter_directory
(
dir
,
val
=
None
):
original_dir
=
os
.
getcwd
()
os
.
chdir
(
dir
)
yield
val
os
.
chdir
(
original_dir
)
@
pytest
.
fixture
def
build_backend
():
tmpdir
=
mkdtemp
()
with
enter_directory
(
tmpdir
):
setup_script
=
DALS
(
"""
from setuptools import setup
setup(
name='foo',
py_modules=['hello'],
setup_requires=['test-package'],
entry_points={'console_scripts': ['hi = hello.run']},
zip_safe=False,
)
...
...
@@ -66,4 +80,10 @@ def build_backend():
"""
)
})
return
BuildBackend
(
cwd
=
'.'
)
return
enter_directory
(
tmpdir
,
BuildBackend
(
cwd
=
'.'
))
def
test_get_requires_for_build_wheel
(
build_backend
):
with
build_backend
as
b
:
assert
list
(
sorted
(
b
.
get_requires_for_build_wheel
()))
==
\
list
(
sorted
([
'test-package'
,
'setuptools'
,
'wheel'
]))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment