Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leverage subprocess32 when available. #411

Merged
merged 1 commit into from
Sep 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ matrix:
python: "2.7"
env: TOXENV=py27

- language: python
python: "2.7"
env: TOXENV=py27-subprocess

- language: python
python: "2.7"
env: TOXENV=py27-requests
Expand Down
18 changes: 15 additions & 3 deletions pex/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@
# Licensed under the Apache License, Version 2.0 (see LICENSE).

import errno
import subprocess

from .compatibility import string
import os

from .compatibility import PY2, string
from .tracer import TRACER

if os.name == 'posix' and PY2:
try:
# Use the subprocess backports if they're available for improved robustness.
import subprocess32 as subprocess
except ImportError:
TRACER.log('Please build pex with the subprocess32 module for more reliable requirement '
'installation and interpreter execution.')
import subprocess
else:
import subprocess


class Executor(object):
Expand Down
8 changes: 8 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@
SETUPTOOLS_REQUIREMENT,
WHEEL_REQUIREMENT,
],
extras_require={
# For improved subprocess robustness under python2.7.
'subprocess': ['subprocess32>=3.2.7'],
# For improved requirement resolution and fetching robustness.
'requests': ['requests>=2.8.14'],
# For improved requirement resolution and fetching performance.
'cachecontrol': ['CacheControl>=0.12.3'],
},
tests_require = [
'mock',
'twitter.common.contextutil>=0.3.1,<0.4.0',
Expand Down
11 changes: 7 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ deps =
cachecontrol: CacheControl
cachecontrol: lockfile
coverage: coverage==4.0.3
subprocess: subprocess32
whitelist_externals = open

[integration]
Expand Down Expand Up @@ -77,10 +78,10 @@ deps =
commands =
# meta
tox -e py27-coverage
tox -e py27-requests-cachecontrol-coverage
tox -e py34-requests-cachecontrol-coverage
tox -e py34-coverage
tox -e pypy-requests-cachecontrol-coverage
tox -e py27-subprocess-requests-cachecontrol-coverage
tox -e py36-requests-cachecontrol-coverage
tox -e py36-coverage
tox -e pypy-subprocess-requests-cachecontrol-coverage
python scripts/combine_coverage.py
coverage report
coverage html
Expand Down Expand Up @@ -137,6 +138,7 @@ commands = pex --cache-dir {envtmpdir}/buildcache wheel requests . -o dist/pex36
[testenv:py27]
[testenv:py27-requests]
[testenv:py27-requests-cachecontrol]
[testenv:py27-subprocess]
[testenv:py33]
[testenv:py33-requests]
[testenv:py33-requests-cachecontrol]
Expand All @@ -152,3 +154,4 @@ commands = pex --cache-dir {envtmpdir}/buildcache wheel requests . -o dist/pex36
[testenv:pypy]
[testenv:pypy-requests]
[testenv:pypy-requests-cachecontrol]
[testenv:pypy-subprocess]