Reverting removal of prepare_command to maintain backwards compatibility of configurations with {python} and {pip}

This commit is contained in:
Yannick Jadoul
2018-04-08 17:01:54 +02:00
parent 4d61b08fa3
commit 2ebde4c078
4 changed files with 23 additions and 4 deletions
+4 -1
View File
@@ -1,6 +1,7 @@
from __future__ import print_function
import os, subprocess, sys
from collections import namedtuple
from .util import prepare_command
try:
from shlex import quote as shlex_quote
@@ -104,7 +105,9 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be
test_command=shlex_quote(
test_command.format(project='/project') if test_command else ''
),
before_build=shlex_quote(before_build or ''),
before_build=shlex_quote(
prepare_command(before_build, python='python', pip='pip') if before_build else ''
),
environment_exports='\n'.join(environment.as_shell_commands()),
)
+4 -1
View File
@@ -7,6 +7,8 @@ try:
except ImportError:
from pipes import quote as shlex_quote
from .util import prepare_command
def build(project_dir, package_name, output_dir, test_command, test_requires, before_build, skip, environment):
PythonConfiguration = namedtuple('PythonConfiguration', ['version', 'identifier', 'url'])
@@ -83,7 +85,8 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be
# run the before_build command
if before_build:
call(before_build, env=env, shell=True)
before_build_prepared = prepare_command(before_build, python='python', pip='pip')
call(before_build_prepared, env=env, shell=True)
# build the wheel
call(['pip', 'wheel', abs_project_dir, '-w', '/tmp/built_wheel', '--no-deps'], env=env)
+12
View File
@@ -1,6 +1,18 @@
from fnmatch import fnmatch
def prepare_command(command, python, pip):
'''
Preprocesses a command by expanding variables like {python} or {pip}.
For example, used for the before_build option, where the user would
like to run a command like `python setup.py test`. If the command should run on
Python 3, the user could write `{python} setup.py test`. This command would expand
it out to python2 or python3 as appropriate.
'''
return command.format(python=python, pip=pip)
class BuildSkipper(object):
def __init__(self, skip_config):
self.patterns = skip_config.split()
+3 -2
View File
@@ -7,7 +7,7 @@ except ImportError:
from collections import namedtuple
from glob import glob
from .util import Unbuffered
from .util import prepare_command, Unbuffered
def build(project_dir, package_name, output_dir, test_command, test_requires, before_build, skip, environment):
@@ -78,7 +78,8 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be
# run the before_build command
if before_build:
shell([before_build], env=env)
before_build_prepared = prepare_command(before_build, python='python', pip='pip')
shell([before_build_prepared], env=env)
# build the wheel
shell(['pip', 'wheel', abs_project_dir, '-w', built_wheel_dir, '--no-deps'], env=env)