Skip to content

Instantly share code, notes, and snippets.

@Jc2k
Created March 21, 2016 11:31
Show Gist options
  • Save Jc2k/e2b48f884b2a8d9abdb8 to your computer and use it in GitHub Desktop.
Save Jc2k/e2b48f884b2a8d9abdb8 to your computer and use it in GitHub Desktop.
Generate a git repo out of a python packages releases
import os
import subprocess
import sys
import requests
from pip.index import PackageFinder
p = PackageFinder([], ["https://pypi.python.org/simple"], session=requests.Session())
versions = p._find_all_versions("newrelic")
versions = sorted(
versions,
key=p._candidate_sort_key,
)
for v in versions:
print v
subprocess.check_call([
"wget",
v.location.url_without_fragment,
])
basename = os.path.basename(v.location.url_without_fragment)
subprocess.check_call([
"git",
"import-orig",
"-u", v.version.public,
os.path.join(os.getcwd(), basename),
], cwd="../newrelic")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment