summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-ximport/pip.to_lorry33
1 files changed, 31 insertions, 2 deletions
diff --git a/import/pip.to_lorry b/import/pip.to_lorry
index 49ec3be..7483b6b 100755
--- a/import/pip.to_lorry
+++ b/import/pip.to_lorry
@@ -19,10 +19,39 @@
from __future__ import print_function
+import subprocess
import requests
+import json
+import sys
-def get_package_json(package_name):
+def fetch_package_metadata(package_name):
return requests.get('http://pypi.python.org/pypi/%s/json'
% package_name).json()
-print(get_package_json('numpy')) \ No newline at end of file
+def is_repo(url):
+ vcss = [('git', 'clone'), ('hg', 'clone'),
+ ('svn', 'checkout'), ('bzr', 'branch')]
+
+ for (vcs, vcs_command) in vcss:
+ p = subprocess.Popen([vcs, vcs_command, url], stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+
+ if p.returncode == 0:
+ return True
+
+ return False
+
+if len(sys.argv) != 2:
+ print('usage: %s python_package' % sys.argv[0], file=sys.stderr)
+ sys.exit(1)
+
+info = fetch_package_metadata('numpy')['info']
+
+if 'home_page' in info:
+ # TODO: detect if git repo, if so then great lorry from here
+ if is_repo(info['home_page']):
+ # lorry this thing
+ print('not implemented yet: lorry from ', info['home_page'])
+ else:
+ # tarball time
+ print("not a repo, it's tarball time!")