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

recreate venv when -rrequire.txt changes #668

Closed
wants to merge 10 commits into from
Closed
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
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Itxaka Serrano
Jannis Leidel
Josh Smeaton
Julian Krause
Kapil Thangavelu
Krisztian Fekete
Laszlo Vasko
Lukasz Balcerzak
Expand Down
7 changes: 7 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import tox
import tox.config
from tox.config import CommandParser
from tox.config import DepConfig
from tox.config import DepOption
from tox.config import get_homedir
from tox.config import get_version_info
Expand Down Expand Up @@ -129,6 +130,12 @@ def test_is_same_dep(self):
assert DepOption._is_same_dep('pkg_hello-world3==1.0', 'pkg_hello-world3<=2.0')
assert not DepOption._is_same_dep('pkg_hello-world3==1.0', 'otherpkg>=2.0')

def test_digest(self, tmpdir):
reqs = tmpdir.join('reqs.txt')
reqs.write('hello_world==1.0')
assert (DepConfig('-r%s' % (str(reqs))).digest == reqs.computehash())
assert (DepConfig('pkg_helloworld3==1.0').digest == "0" * 32)


class TestConfigPlatform:
def test_config_parse_platform(self, newconfig):
Expand Down
10 changes: 10 additions & 0 deletions tox/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,16 @@ def __init__(self, name, indexserver=None):
self.name = name
self.indexserver = indexserver

@property
def digest(self):
fname = str(self.name)
if fname.startswith('-r'):
fname = fname[2:]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There may be optional whitespace: -r requirements.txt

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, there can be at the moment, but it won't work as expected: it would search for requirements.txt (note space). See PR #669.

You should check for --requirement as well, in which case you will have to strip an =.

A requirements file itself can depend on a requirements file (e.g. dev requirements on install requirements). I guess that is not being checked here?

path = py.path.local(fname)
if not path.check(file=1):
return "0" * 32
return path.computehash()

def __str__(self):
if self.indexserver:
if self.indexserver.name == "default":
Expand Down
4 changes: 1 addition & 3 deletions tox/venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,7 @@ def _getliveconfig(self):
alwayscopy = self.envconfig.alwayscopy
deps = []
for dep in self._getresolvedeps():
raw_dep = dep.name
md5 = getdigest(raw_dep)
deps.append((md5, raw_dep))
deps.append((dep.digest, dep.name))
return CreationConfig(md5, python, version,
sitepackages, develop, deps, alwayscopy)

Expand Down