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

Fix disable cache (#260) #261

Merged
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
6 changes: 4 additions & 2 deletions pex/bin/pex.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def increment_verbosity(option, opt_str, _, parser):


def process_disable_cache(option, option_str, option_value, parser):
setattr(parser.values, option.dest, [])
setattr(parser.values, option.dest, None)


def process_pypi_option(option, option_str, option_value, parser, builder):
Expand Down Expand Up @@ -530,7 +530,9 @@ def main(args=None):
else:
options.pex_root = ENV.PEX_ROOT # If option not specified fallback to env variable.

options.cache_dir = make_relative_to_root(options.cache_dir)
# Don't alter cache if it is disabled.
if options.cache_dir:
options.cache_dir = make_relative_to_root(options.cache_dir)
options.interpreter_cache_dir = make_relative_to_root(options.interpreter_cache_dir)

with ENV.patch(PEX_VERBOSE=str(options.verbosity)):
Expand Down
22 changes: 22 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,28 @@ def test_pex_root():
assert 'build' in os.listdir(td), 'Expected build directory in tmp pex root.'


def test_cache_disable():
with temporary_dir() as tmp_home:
with environment_as(HOME=tmp_home):
with temporary_dir() as td:
with temporary_dir() as output_dir:
env = os.environ.copy()
env['PEX_INTERPRETER'] = '1'

output_path = os.path.join(output_dir, 'pex.pex')
args = [
'pex',
'-o', output_path,
'--not-zip-safe',
'--disable-cache',
'--pex-root={0}'.format(td),
]
results = run_pex_command(args=args, env=env)
results.assert_success()
assert ['pex.pex'] == os.listdir(output_dir), 'Expected built pex file.'
assert [] == os.listdir(tmp_home), 'Expected empty temp home dir.'


def test_pex_interpreter():
with named_temporary_file() as fp:
fp.write(b"print('Hello world')")
Expand Down