Add shell-style execution on the Mac
This commit is contained in:
+22
-18
@@ -19,10 +19,14 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be
|
|||||||
PythonConfiguration(version='3.6', identifier='cp36-macosx_10_6_intel', url='https://www.python.org/ftp/python/3.6.0/python-3.6.0-macosx10.6.pkg'),
|
PythonConfiguration(version='3.6', identifier='cp36-macosx_10_6_intel', url='https://www.python.org/ftp/python/3.6.0/python-3.6.0-macosx10.6.pkg'),
|
||||||
]
|
]
|
||||||
|
|
||||||
def shell(args, env=None, cwd=None):
|
def call(args, env=None, cwd=None, shell=False):
|
||||||
# print the command executing for the logs
|
# print the command executing for the logs
|
||||||
print('+ ' + ' '.join(shlex_quote(a) for a in args))
|
if shell:
|
||||||
return subprocess.check_call(args, env=env, cwd=cwd)
|
print('+ %s' % args)
|
||||||
|
else:
|
||||||
|
print('+ ' + ' '.join(shlex_quote(a) for a in args))
|
||||||
|
|
||||||
|
return subprocess.check_call(args, env=env, cwd=cwd, shell=shell)
|
||||||
|
|
||||||
for config in python_configurations:
|
for config in python_configurations:
|
||||||
if skip(config.identifier):
|
if skip(config.identifier):
|
||||||
@@ -30,9 +34,9 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# download the pkg
|
# download the pkg
|
||||||
shell(['curl', '-L', '-o', '/tmp/Python.pkg', config.url])
|
call(['curl', '-L', '-o', '/tmp/Python.pkg', config.url])
|
||||||
# install
|
# install
|
||||||
shell(['sudo', 'installer', '-pkg', '/tmp/Python.pkg', '-target', '/'])
|
call(['sudo', 'installer', '-pkg', '/tmp/Python.pkg', '-target', '/'])
|
||||||
|
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
env['PATH'] = os.pathsep.join([
|
env['PATH'] = os.pathsep.join([
|
||||||
@@ -44,14 +48,14 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be
|
|||||||
pip = 'pip3' if config.version[0] == '3' else 'pip2'
|
pip = 'pip3' if config.version[0] == '3' else 'pip2'
|
||||||
|
|
||||||
# check what version we're on
|
# check what version we're on
|
||||||
shell(['which', python], env=env)
|
call(['which', python], env=env)
|
||||||
shell([python, '--version'], env=env)
|
call([python, '--version'], env=env)
|
||||||
|
|
||||||
# install pip & wheel
|
# install pip & wheel
|
||||||
shell([python, '-m', 'ensurepip', '--upgrade'], env=env)
|
call([python, '-m', 'ensurepip', '--upgrade'], env=env)
|
||||||
shell([pip, '--version'], env=env)
|
call([pip, '--version'], env=env)
|
||||||
shell([pip, 'install', 'wheel'], env=env)
|
call([pip, 'install', 'wheel'], env=env)
|
||||||
shell([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'):
|
||||||
@@ -64,10 +68,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)
|
before_build_prepared = prepare_command(before_build, python=python, pip=pip)
|
||||||
shell(shlex.split(before_build_prepared), env=env)
|
call(before_build_prepared, env=env, shell=True)
|
||||||
|
|
||||||
# build the wheel
|
# build the wheel
|
||||||
shell([pip, 'wheel', project_dir, '-w', '/tmp/built_wheel', '--no-deps'], env=env)
|
call([pip, 'wheel', 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'):
|
||||||
@@ -75,24 +79,24 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be
|
|||||||
shutil.move(built_wheel, '/tmp/delocated_wheel')
|
shutil.move(built_wheel, '/tmp/delocated_wheel')
|
||||||
else:
|
else:
|
||||||
# list the dependencies
|
# list the dependencies
|
||||||
shell(['delocate-listdeps', built_wheel], env=env)
|
call(['delocate-listdeps', built_wheel], env=env)
|
||||||
# rebuild the wheel with shared libraries included and place in output dir
|
# rebuild the wheel with shared libraries included and place in output dir
|
||||||
shell(['delocate-wheel', '-w', '/tmp/delocated_wheel', built_wheel], env=env)
|
call(['delocate-wheel', '-w', '/tmp/delocated_wheel', built_wheel], env=env)
|
||||||
delocated_wheel = glob('/tmp/delocated_wheel/*.whl')[0]
|
delocated_wheel = glob('/tmp/delocated_wheel/*.whl')[0]
|
||||||
|
|
||||||
# install the wheel
|
# install the wheel
|
||||||
shell([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:
|
||||||
shell([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
|
||||||
# and not the repo code)
|
# and not the repo code)
|
||||||
abs_project_dir = os.path.abspath(project_dir)
|
abs_project_dir = os.path.abspath(project_dir)
|
||||||
test_command_absolute = test_command.format(project=abs_project_dir)
|
test_command_absolute = test_command.format(project=abs_project_dir)
|
||||||
shell(shlex.split(test_command_absolute), cwd=os.environ['HOME'], env=env)
|
call(shlex.split(test_command_absolute), cwd=os.environ['HOME'], env=env)
|
||||||
|
|
||||||
# we're all done here; move it to output
|
# we're all done here; move it to output
|
||||||
shutil.move(delocated_wheel, output_dir)
|
shutil.move(delocated_wheel, output_dir)
|
||||||
|
|||||||
Reference in New Issue
Block a user