Skip to content

Commit

Permalink
add support for usedevelop (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmeier authored Oct 28, 2020
1 parent d8b4717 commit 527c294
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
22 changes: 21 additions & 1 deletion tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ def get_tox_ini(
force_cpu=None,
deps=None,
skip_install=False,
usedevelop=False,
extra=False,
pep517=True,
):

lines = ["[tox]", "envlist = py"]

if pep517:
Expand All @@ -83,6 +83,8 @@ def get_tox_ini(
lines.append(f"basepython = {basepython}")
if skip_install:
lines.append("skip_install = True")
if usedevelop:
lines.append("usedevelop = True")
if extra:
lines.append("extras = extra")
if disable_light_the_torch is not None:
Expand All @@ -108,6 +110,7 @@ def tox_ltt_initproj_(
force_cpu=None,
deps=None,
skip_install=False,
usedevelop=False,
pep517=True,
):
filedefs = {
Expand All @@ -120,6 +123,7 @@ def tox_ltt_initproj_(
"tox.ini": get_tox_ini(
basepython=basepython,
skip_install=skip_install,
usedevelop=usedevelop,
extra=extra_requires is not None,
disable_light_the_torch=disable_light_the_torch,
force_cpu=force_cpu,
Expand Down Expand Up @@ -274,6 +278,22 @@ def test_tox_ltt_project_extra_pytorch_dists(
assert set(args[0]) == dists


def test_tox_ltt_project_usedevelop(
patch_find_links, tox_ltt_initproj, cmd, install_mock
):
mock = patch_find_links()
install_requires = ("torch>=1.5.0", "torchvision>=0.6.0")
dists = set(install_requires)
tox_ltt_initproj(install_requires=install_requires, usedevelop=True, pep517=False)

result = cmd()

result.assert_success(is_run_test_env=False)

args, _ = mock.call_args
assert set(args[0]) == dists


@pytest.fixture
def other_basepythons(current_tox_py):
current_minor = int(current_tox_py[-1])
Expand Down
5 changes: 4 additions & 1 deletion tox_ltt/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ def tox_testenv_install_deps(venv: VirtualEnv, action: Action) -> None:
requirements = [dep_config.name for dep_config in venv.get_resolved_dependencies()]

if not envconfig.skip_install:
path = venv.package.strpath
if envconfig.usedevelop:
path = config.setupdir.strpath
else:
path = venv.package.strpath
if envconfig.extras:
path += f"[{','.join(envconfig.extras)}]"
requirements.append(path)
Expand Down

0 comments on commit 527c294

Please sign in to comment.