towards virtualenv being exactly requirements.txt

* Ignore already installed (usually global) packages when installing
requirements.txt into the virtualenv.
This commit is contained in:
Chris Meyers
2016-11-15 09:08:59 -05:00
parent ca34ea4c3b
commit 1883485724
3 changed files with 16 additions and 19 deletions
+11 -14
View File
@@ -1,29 +1,29 @@
import os
from pip.operations import freeze
from django.conf import settings
def test_req():
def test_env_matches_requirements_txt():
def check_is_in(src, dests):
if src not in dests:
src2 = [src[0].replace('_', '-'), src[1]]
if src2 not in dests:
print("%s not in" % src2)
return False
else:
print("%s not in" % src)
return False
print("%s not in" % src)
return False
return True
base_dir = settings.BASE_DIR
requirements_path = os.path.join(base_dir, '../', 'requirements/requirements.txt')
reqs_actual = []
xs = freeze.freeze(local_only=True, requirement=base_dir + "/../requirements/requirements.txt")
xs = freeze.freeze(local_only=True, requirement=requirements_path)
for x in xs:
if '## The following requirements were added by pip freeze' in x:
break
reqs_actual.append(x.split('=='))
reqs_expected = []
with open(base_dir + "/../requirements/requirements.txt") as f:
with open(requirements_path) as f:
for line in f:
line.rstrip()
# TODO: process git requiremenst and use egg
@@ -34,15 +34,12 @@ def test_req():
line.rstrip()
reqs_expected.append(line.rstrip().split('=='))
for r in reqs_actual:
print(r)
not_found = []
for r in reqs_expected:
res = check_is_in(r, reqs_actual)
if res is False:
not_found.append(r)
raise RuntimeError("%s not found in \n\n%s" % (not_found, reqs_expected))
raise RuntimeError("%s not found in \n\n%s" % (not_found, reqs_actual))