Skip to content

Commit

Permalink
Leverage subprocess32 when available. (#411)
Browse files Browse the repository at this point in the history
This allows for an upgrade in subprocess robustness when available that
Pants will leverage for one. Also formalize the pex optional
dependencies with `extras_require`, mainly for documentation purposes.
  • Loading branch information
jsirois authored Sep 1, 2017
1 parent e7ff4be commit c07c70f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
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]

0 comments on commit c07c70f

Please sign in to comment.