-
Notifications
You must be signed in to change notification settings - Fork 579
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Related to https://gitlab.com/coala/mobans/issues/65
- Loading branch information
Showing
4 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from __future__ import print_function | ||
|
||
import subprocess | ||
import sys | ||
|
||
import setuptools | ||
|
||
|
||
def get_setuptools_version(): | ||
with open('requirements.txt') as f: | ||
for line in f: | ||
if line.startswith('setuptools'): | ||
line = line.rstrip() | ||
if '>=' not in line: | ||
raise ValueError('%s doesnt use ">="' % line) | ||
_, version = line.split('>=') | ||
return version | ||
|
||
|
||
def check_setuptools_version(version): | ||
print('Checking setuptools==%s' % version, file=sys.stderr) | ||
if setuptools.__version__ != version: | ||
print('Failed! setuptools==%s' % setuptools.__version__, | ||
file=sys.stderr) | ||
return 2 | ||
|
||
pip_list = subprocess.check_output(['pip', 'list', '--format=legacy']) | ||
pip_list = pip_list.decode('utf8') | ||
if 'setuptools (%s)' % version not in pip_list: | ||
print('Failed! pip list reports wrong setuptools:\n%s' % pip_list, | ||
file=sys.stderr) | ||
return 3 | ||
|
||
if __name__ == '__main__': | ||
version = None | ||
try: | ||
version = get_setuptools_version() | ||
except Exception as e: | ||
print('Exception extracting setuptools version from requirements.txt: ' | ||
'%s' % e, | ||
file=sys.stderr) | ||
sys.exit(1) | ||
|
||
if not version: | ||
print('Unable to find setuptools in requirements.txt', | ||
file=sys.stderr) | ||
sys.exit(1) | ||
sys.exit(check_setuptools_version(version)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters