Skip to content
This repository was archived by the owner on Oct 7, 2022. It is now read-only.

Commit 17ddcf7

Browse files
edoficgarbas
authored andcommitted
Add support for commit hashes in git requirements
fixes #95 fixes #96
1 parent 2119b5d commit 17ddcf7

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/pypi2nix/stage2.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ def process_wheel(wheel_cache_dir, wheel, sources, verbose, index=INDEX_URL,
296296
release['hash_type'] = 'sha256'
297297

298298
if release['url'].startswith('http://') or release['url'].startswith('https://'):
299-
299+
300300
release['fetch_type'] = 'fetchurl'
301301

302302
r = requests.get(release['url'], stream=True, timeout=None)
@@ -310,9 +310,15 @@ def process_wheel(wheel_cache_dir, wheel, sources, verbose, index=INDEX_URL,
310310

311311
release['hash_value'] = hash.hexdigest()
312312
elif release['url'].startswith('git'):
313+
revision = ''
314+
if release['url'].startswith('git+'):
315+
release['url'] = release['url'][4:]
316+
if '@' in release['url']:
317+
release['url'], revision = release['url'].split('@')
313318
release['fetch_type'] = 'fetchgit'
314-
command = 'nix-prefetch-git {url}'.format(
315-
**release
319+
command = 'nix-prefetch-git {url} {revision}'.format(
320+
url=release['url'],
321+
revision=revision
316322
)
317323
return_code, output = cmd(command, verbose != 0)
318324
if return_code != 0:
@@ -365,12 +371,14 @@ def main(verbose, wheels, requirements_files, wheel_cache_dir, index=INDEX_URL):
365371
lines = f.readlines()
366372
for line in lines:
367373
line = line.strip()
374+
if line.startswith('-e '):
375+
line = line[3:]
368376
if line.startswith('http://') or line.startswith('https://') or \
369-
line.startswith('-e git+'):
377+
line.startswith('git+'):
370378
try:
371379
url, egg = line.split('#')
372380
name = egg.split('egg=')[1]
373-
sources[name] = url.replace('-e git+','')
381+
sources[name] = url
374382
except:
375383
raise click.ClickException(
376384
"Requirement starting with http:// or https:// "

0 commit comments

Comments
 (0)