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
823780e4
Commit
823780e4
authored
Nov 13, 2017
by
Jason R. Coombs
Committed by
GitHub
Nov 13, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1175 from xoviat/build_meta
Build meta: fixes and cleanups
parents
5b6c8d3f
ca5a8186
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
27 deletions
+80
-27
setuptools/build_meta.py
setuptools/build_meta.py
+29
-5
setuptools/command/dist_info.py
setuptools/command/dist_info.py
+2
-6
setuptools/tests/test_build_meta.py
setuptools/tests/test_build_meta.py
+49
-16
No files found.
setuptools/build_meta.py
View file @
823780e4
...
@@ -65,10 +65,11 @@ def _run_setup(setup_script='setup.py'):
...
@@ -65,10 +65,11 @@ def _run_setup(setup_script='setup.py'):
# Note that we can reuse our build directory between calls
# Note that we can reuse our build directory between calls
# Correctness comes first, then optimization later
# Correctness comes first, then optimization later
__file__
=
setup_script
__file__
=
setup_script
__name__
=
'__main__'
f
=
getattr
(
tokenize
,
'open'
,
open
)(
__file__
)
f
=
getattr
(
tokenize
,
'open'
,
open
)(
__file__
)
code
=
f
.
read
().
replace
(
'
\
\
r
\
\
n'
,
'
\
\
n'
)
code
=
f
.
read
().
replace
(
'
\
\
r
\
\
n'
,
'
\
\
n'
)
f
.
close
()
f
.
close
()
exec
(
compile
(
code
,
__file__
,
'exec'
))
exec
(
compile
(
code
,
__file__
,
'exec'
)
,
locals
()
)
def
_fix_config
(
config_settings
):
def
_fix_config
(
config_settings
):
...
@@ -92,6 +93,11 @@ def _get_build_requires(config_settings):
...
@@ -92,6 +93,11 @@ def _get_build_requires(config_settings):
return
requirements
return
requirements
def
_get_immediate_subdirectories
(
a_dir
):
return
[
name
for
name
in
os
.
listdir
(
a_dir
)
if
os
.
path
.
isdir
(
os
.
path
.
join
(
a_dir
,
name
))]
def
get_requires_for_build_wheel
(
config_settings
=
None
):
def
get_requires_for_build_wheel
(
config_settings
=
None
):
config_settings
=
_fix_config
(
config_settings
)
config_settings
=
_fix_config
(
config_settings
)
return
_get_build_requires
(
config_settings
)
return
_get_build_requires
(
config_settings
)
...
@@ -106,10 +112,28 @@ def prepare_metadata_for_build_wheel(metadata_directory, config_settings=None):
...
@@ -106,10 +112,28 @@ def prepare_metadata_for_build_wheel(metadata_directory, config_settings=None):
sys
.
argv
=
sys
.
argv
[:
1
]
+
[
'dist_info'
,
'--egg-base'
,
metadata_directory
]
sys
.
argv
=
sys
.
argv
[:
1
]
+
[
'dist_info'
,
'--egg-base'
,
metadata_directory
]
_run_setup
()
_run_setup
()
dist_infos
=
[
f
for
f
in
os
.
listdir
(
metadata_directory
)
dist_info_directory
=
metadata_directory
while
True
:
dist_infos
=
[
f
for
f
in
os
.
listdir
(
dist_info_directory
)
if
f
.
endswith
(
'.dist-info'
)]
if
f
.
endswith
(
'.dist-info'
)]
if
len
(
dist_infos
)
==
0
and
\
len
(
_get_immediate_subdirectories
(
dist_info_directory
))
==
1
:
dist_info_directory
=
os
.
path
.
join
(
dist_info_directory
,
os
.
listdir
(
dist_info_directory
)[
0
])
continue
assert
len
(
dist_infos
)
==
1
assert
len
(
dist_infos
)
==
1
break
# PEP 517 requires that the .dist-info directory be placed in the
# metadata_directory. To comply, we MUST copy the directory to the root
if
dist_info_directory
!=
metadata_directory
:
shutil
.
move
(
os
.
path
.
join
(
dist_info_directory
,
dist_infos
[
0
]),
metadata_directory
)
shutil
.
rmtree
(
dist_info_directory
,
ignore_errors
=
True
)
return
dist_infos
[
0
]
return
dist_infos
[
0
]
...
...
setuptools/command/dist_info.py
View file @
823780e4
...
@@ -4,7 +4,6 @@ As defined in the wheel specification
...
@@ -4,7 +4,6 @@ As defined in the wheel specification
"""
"""
import
os
import
os
import
shutil
from
distutils.core
import
Command
from
distutils.core
import
Command
from
distutils
import
log
from
distutils
import
log
...
@@ -27,14 +26,11 @@ class dist_info(Command):
...
@@ -27,14 +26,11 @@ class dist_info(Command):
def
run
(
self
):
def
run
(
self
):
egg_info
=
self
.
get_finalized_command
(
'egg_info'
)
egg_info
=
self
.
get_finalized_command
(
'egg_info'
)
egg_info
.
egg_base
=
self
.
egg_base
egg_info
.
finalize_options
()
egg_info
.
run
()
egg_info
.
run
()
dist_info_dir
=
egg_info
.
egg_info
[:
-
len
(
'.egg-info'
)]
+
'.dist-info'
dist_info_dir
=
egg_info
.
egg_info
[:
-
len
(
'.egg-info'
)]
+
'.dist-info'
log
.
info
(
"creating '{}'"
.
format
(
os
.
path
.
abspath
(
dist_info_dir
)))
log
.
info
(
"creating '{}'"
.
format
(
os
.
path
.
abspath
(
dist_info_dir
)))
bdist_wheel
=
self
.
get_finalized_command
(
'bdist_wheel'
)
bdist_wheel
=
self
.
get_finalized_command
(
'bdist_wheel'
)
bdist_wheel
.
egg2dist
(
egg_info
.
egg_info
,
dist_info_dir
)
bdist_wheel
.
egg2dist
(
egg_info
.
egg_info
,
dist_info_dir
)
if
self
.
egg_base
:
destination
=
os
.
path
.
join
(
self
.
egg_base
,
dist_info_dir
)
log
.
info
(
"creating '{}'"
.
format
(
os
.
path
.
abspath
(
destination
)))
shutil
.
move
(
dist_info_dir
,
destination
)
setuptools/tests/test_build_meta.py
View file @
823780e4
...
@@ -42,9 +42,7 @@ class BuildBackendCaller(BuildBackendBase):
...
@@ -42,9 +42,7 @@ class BuildBackendCaller(BuildBackendBase):
return
getattr
(
mod
,
name
)(
*
args
,
**
kw
)
return
getattr
(
mod
,
name
)(
*
args
,
**
kw
)
@
pytest
.
fixture
defns
=
[{
def
build_backend
(
tmpdir
):
defn
=
{
'setup.py'
:
DALS
(
"""
'setup.py'
:
DALS
(
"""
__import__('setuptools').setup(
__import__('setuptools').setup(
name='foo',
name='foo',
...
@@ -56,8 +54,43 @@ def build_backend(tmpdir):
...
@@ -56,8 +54,43 @@ def build_backend(tmpdir):
def run():
def run():
print('hello')
print('hello')
"""
),
"""
),
}
},
build_files
(
defn
,
prefix
=
str
(
tmpdir
))
{
'setup.py'
:
DALS
(
"""
assert __name__ == '__main__'
__import__('setuptools').setup(
name='foo',
py_modules=['hello'],
setup_requires=['six'],
)
"""
),
'hello.py'
:
DALS
(
"""
def run():
print('hello')
"""
),
},
{
'setup.py'
:
DALS
(
"""
variable = True
def function():
return variable
assert variable
__import__('setuptools').setup(
name='foo',
py_modules=['hello'],
setup_requires=['six'],
)
"""
),
'hello.py'
:
DALS
(
"""
def run():
print('hello')
"""
),
}]
@
pytest
.
fixture
(
params
=
defns
)
def
build_backend
(
tmpdir
,
request
):
build_files
(
request
.
param
,
prefix
=
str
(
tmpdir
))
with
tmpdir
.
as_cwd
():
with
tmpdir
.
as_cwd
():
yield
BuildBackend
(
cwd
=
'.'
)
yield
BuildBackend
(
cwd
=
'.'
)
...
...
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