Skip to content

Instantly share code, notes, and snippets.

@balazs-endresz
Last active April 13, 2016 21:04
Show Gist options
  • Save balazs-endresz/27016cb37edaeda520b49f4a4c47caf0 to your computer and use it in GitHub Desktop.
Save balazs-endresz/27016cb37edaeda520b49f4a4c47caf0 to your computer and use it in GitHub Desktop.
Figure out what verions of python packages are compatible with each other
import sys
import json
import urllib2
from distutils.version import StrictVersion
def versions(package_name):
url = "https://pypi.python.org/pypi/%s/json" % (package_name,)
data = json.load(urllib2.urlopen(urllib2.Request(url)))
versions = data["releases"].keys()
try:
versions.sort(key=StrictVersion)
except:
versions.sort()
return versions
if __name__ == "__main__":
print "\n".join(versions(sys.argv[1]))
import itertools
import subprocess
packages = {
'celery': [
'3.0.25',
'3.1.0',
'3.1.1',
'3.1.2',
'3.1.3',
'3.1.4',
'3.1.5',
'3.1.6',
'3.1.7',
'3.1.8',
'3.1.9',
'3.1.10',
'3.1.11',
'3.1.12',
'3.1.13',
'3.1.14',
'3.1.15',
'3.1.16',
'3.1.17',
'3.1.18',
'3.1.19',
'3.1.20',
'3.1.21',
'3.1.22',
'3.1.23',
],
'redis': [
'2.9.1',
'2.10.0',
'2.10.1',
'2.10.2',
'2.10.3',
'2.10.5',
],
'django-redis': [
'3.7.2',
'3.8.0',
'3.8.1',
'3.8.2',
'3.8.3',
'3.8.4',
'4.0.0',
'4.1.0',
'4.2.0',
'4.3.0',
'4.4.0',
'4.4.1',
]
}
all_package_specs = []
for package, versions in packages.iteritems():
versions.reverse()
package_specs = []
all_package_specs.append(package_specs)
for version in versions:
package_specs.append('{}=={}'.format(package, version))
combinations = [s for s in itertools.product(*all_package_specs)]
print combinations
print ""
print "Number of combinations:"
print len(combinations)
print ""
for batch in combinations:
for specs in batch:
subprocess.call(['pip', 'install', specs])
# test here if this combination of packages works or not
if subprocess.call(['echo', 'test']):
print('negatory')
else:
print('affirmative')
print(batch)
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment