Reverting removal of prepare_command to maintain backwards compatibility of configurations with {python} and {pip}
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import os, subprocess, sys
|
import os, subprocess, sys
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
from .util import prepare_command
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from shlex import quote as shlex_quote
|
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=shlex_quote(
|
||||||
test_command.format(project='/project') if test_command else ''
|
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()),
|
environment_exports='\n'.join(environment.as_shell_commands()),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
from pipes import quote as shlex_quote
|
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):
|
def build(project_dir, package_name, output_dir, test_command, test_requires, before_build, skip, environment):
|
||||||
PythonConfiguration = namedtuple('PythonConfiguration', ['version', 'identifier', 'url'])
|
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
|
# run the before_build command
|
||||||
if before_build:
|
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
|
# build the wheel
|
||||||
call(['pip', 'wheel', abs_project_dir, '-w', '/tmp/built_wheel', '--no-deps'], env=env)
|
call(['pip', 'wheel', abs_project_dir, '-w', '/tmp/built_wheel', '--no-deps'], env=env)
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
from fnmatch import fnmatch
|
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):
|
class BuildSkipper(object):
|
||||||
def __init__(self, skip_config):
|
def __init__(self, skip_config):
|
||||||
self.patterns = skip_config.split()
|
self.patterns = skip_config.split()
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ except ImportError:
|
|||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from glob import glob
|
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):
|
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
|
# run the before_build command
|
||||||
if before_build:
|
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
|
# build the wheel
|
||||||
shell(['pip', 'wheel', abs_project_dir, '-w', built_wheel_dir, '--no-deps'], env=env)
|
shell(['pip', 'wheel', abs_project_dir, '-w', built_wheel_dir, '--no-deps'], env=env)
|
||||||
|
|||||||
Reference in New Issue
Block a user