Removing replacement of {python} and {pip} in CIBW_BEFORE_BUILD
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
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
|
||||||
@@ -105,9 +104,7 @@ 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=shlex_quote(before_build or ''),
|
||||||
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()),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+10
-16
@@ -7,8 +7,6 @@ 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'])
|
||||||
@@ -60,18 +58,15 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be
|
|||||||
])
|
])
|
||||||
env = environment.as_dictionary(prev_environment=env)
|
env = environment.as_dictionary(prev_environment=env)
|
||||||
|
|
||||||
python = 'python3' if config.version[0] == '3' else 'python2'
|
|
||||||
pip = 'pip3' if config.version[0] == '3' else 'pip2'
|
|
||||||
|
|
||||||
# check what version we're on
|
# check what version we're on
|
||||||
call(['which', python], env=env)
|
call(['which', 'python'], env=env)
|
||||||
call([python, '--version'], env=env)
|
call(['python', '--version'], env=env)
|
||||||
|
|
||||||
# install pip & wheel
|
# install pip & wheel
|
||||||
call([python, get_pip_script, '--no-setuptools', '--no-wheel'], env=env)
|
call(['python', get_pip_script, '--no-setuptools', '--no-wheel'], env=env)
|
||||||
call([pip, '--version'], env=env)
|
call(['pip', '--version'], env=env)
|
||||||
call([pip, 'install', 'wheel'], env=env)
|
call(['pip', 'install', 'wheel'], env=env)
|
||||||
call([pip, 'install', 'delocate'], env=env)
|
call(['pip', 'install', 'delocate'], env=env)
|
||||||
|
|
||||||
# setup dirs
|
# setup dirs
|
||||||
if os.path.exists('/tmp/built_wheel'):
|
if os.path.exists('/tmp/built_wheel'):
|
||||||
@@ -83,11 +78,10 @@ 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:
|
||||||
before_build_prepared = prepare_command(before_build, python=python, pip=pip)
|
call(before_build, env=env, shell=True)
|
||||||
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)
|
||||||
built_wheel = glob('/tmp/built_wheel/*.whl')[0]
|
built_wheel = glob('/tmp/built_wheel/*.whl')[0]
|
||||||
|
|
||||||
if built_wheel.endswith('none-any.whl'):
|
if built_wheel.endswith('none-any.whl'):
|
||||||
@@ -101,11 +95,11 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be
|
|||||||
delocated_wheel = glob('/tmp/delocated_wheel/*.whl')[0]
|
delocated_wheel = glob('/tmp/delocated_wheel/*.whl')[0]
|
||||||
|
|
||||||
# install the wheel
|
# install the wheel
|
||||||
call([pip, 'install', delocated_wheel], env=env)
|
call(['pip', 'install', delocated_wheel], env=env)
|
||||||
|
|
||||||
# test the wheel
|
# test the wheel
|
||||||
if test_requires:
|
if test_requires:
|
||||||
call([pip, 'install'] + test_requires, env=env)
|
call(['pip', 'install'] + test_requires, env=env)
|
||||||
if test_command:
|
if test_command:
|
||||||
# run the tests from $HOME, with an absolute path in the command
|
# run the tests from $HOME, with an absolute path in the command
|
||||||
# (this ensures that Python runs the tests against the installed wheel
|
# (this ensures that Python runs the tests against the installed wheel
|
||||||
|
|||||||
@@ -1,18 +1,6 @@
|
|||||||
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 prepare_command, Unbuffered
|
from .util import 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,8 +78,7 @@ 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:
|
||||||
before_build_prepared = prepare_command(before_build, python='python', pip='pip')
|
shell([before_build], env=env)
|
||||||
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