Commit 2bb8225a authored by Jason R. Coombs's avatar Jason R. Coombs

Extract common behavior into a function

parent 7378e6be
......@@ -149,6 +149,15 @@ def prepare_metadata_for_build_wheel(metadata_directory, config_settings=None):
return dist_infos[0]
def _file_with_extension(directory, extension):
matching = (
f for f in os.listdir(directory)
if f.endswith(extension)
)
file, = matching
return file
def build_wheel(wheel_directory, config_settings=None,
metadata_directory=None):
config_settings = _fix_config(config_settings)
......@@ -160,13 +169,7 @@ def build_wheel(wheel_directory, config_settings=None,
shutil.rmtree(wheel_directory)
shutil.copytree('dist', wheel_directory)
wheels = (
f for f in os.listdir(wheel_directory)
if f.endswith('.whl')
)
wheel, = wheels
return wheel
return _file_with_extension(wheel_directory, '.whl')
def build_sdist(sdist_directory, config_settings=None):
......@@ -177,10 +180,4 @@ def build_sdist(sdist_directory, config_settings=None):
["--dist-dir", sdist_directory]
_run_setup()
sdists = (
f for f in os.listdir(sdist_directory)
if f.endswith('.tar.gz')
)
sdist, = sdists
return sdist
return _file_with_extension(sdist_directory, '.tar.gz')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment