mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-16 02:21:46 +04:00
Merge bace4f7dc9 into e5c9d3614b
This commit is contained in:
commit
d6f470299d
2 changed files with 43 additions and 1 deletions
|
|
@ -73,10 +73,28 @@ def install_environment(
|
|||
else:
|
||||
venv_cmd.extend(['-p', os.path.realpath(sys.executable)])
|
||||
repo_cmd_runner.run(venv_cmd, cwd='/')
|
||||
|
||||
# Determine if items in additional_dependencies are pip requirements
|
||||
# files or package names
|
||||
packages = []
|
||||
requirements_files = []
|
||||
for dependency in additional_dependencies:
|
||||
if dependency.startswith('file:'):
|
||||
requirements_files.append(dependency.split('file:', 1)[1])
|
||||
else:
|
||||
packages.append(dependency)
|
||||
|
||||
with in_env(repo_cmd_runner, version):
|
||||
if requirements_files:
|
||||
helpers.run_setup_cmd(
|
||||
repo_cmd_runner,
|
||||
('pip', 'install') +
|
||||
tuple('-r{}'.format(req_file)
|
||||
for req_file in requirements_files),
|
||||
)
|
||||
helpers.run_setup_cmd(
|
||||
repo_cmd_runner,
|
||||
('pip', 'install', '.') + additional_dependencies,
|
||||
('pip', 'install', '.') + tuple(packages),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -480,6 +480,30 @@ def test_additional_python_dependencies_installed(tempdir_factory, store):
|
|||
assert 'mccabe' in output
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_additional_python_dependencies_requirements_files(
|
||||
tempdir_factory,
|
||||
store
|
||||
):
|
||||
path = make_repo(tempdir_factory, 'python_hooks_repo')
|
||||
config = make_config_from_repo(path)
|
||||
|
||||
# write pip requirements file
|
||||
req_file_path = os.path.join(path, 'requirements.txt')
|
||||
with io.open(req_file_path, 'w') as fp:
|
||||
fp.write('pep8')
|
||||
|
||||
config['hooks'][0]['additional_dependencies'] = \
|
||||
['mccabe', 'file:{}'.format(req_file_path)]
|
||||
|
||||
repo = Repository.create(config, store)
|
||||
repo.require_installed()
|
||||
with python.in_env(repo._cmd_runner, 'default'):
|
||||
output = cmd_output('pip', 'freeze', '-l')[1]
|
||||
assert 'mccabe' in output
|
||||
assert 'pep8' in output
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_additional_dependencies_roll_forward(tempdir_factory, store):
|
||||
path = make_repo(tempdir_factory, 'python_hooks_repo')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue