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

Commit

Permalink
add ability to handle extras with local paths
Browse files Browse the repository at this point in the history
  • Loading branch information
garbas committed Feb 16, 2017
1 parent f08c361 commit 25ae5f9
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/pypi2nix/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,17 @@ def handle_requirements_file(project_dir, requirements_file):
requirements_line.startswith("-e hg+"):
pass
elif requirements_line.startswith("-e"):
requirements_line = requirements_line.strip()[3:]
try:
tmp_path, egg = requirements_line.strip().split('#')
tmp_name = egg.split('egg=')[1]
_tmp = tmp_path.split('[')
if len(_tmp) > 1:
tmp_path = _tmp[0]
tmp_other = '[' + _tmp[1]
else:
tmp_path = _tmp
tmp_other = ''
except:
raise click.ClickException(
"Requirement starting with `.` "
Expand All @@ -211,11 +219,11 @@ def handle_requirements_file(project_dir, requirements_file):
tmp_path = os.path.abspath(os.path.join(
os.path.dirname(requirements_file),
os.path.abspath(os.path.join(
current_dir, tmp_path.strip()[3:]
current_dir, tmp_path
)),
))

requirements_line = "-e %s" % tmp_path
requirements_line = "-e %s%s" % (tmp_path, tmp_other)
sources[tmp_name] = dict(url=tmp_path, type='path')

elif requirements_line.startswith("-r ./"):
Expand Down Expand Up @@ -262,7 +270,7 @@ def handle_requirements_file(project_dir, requirements_file):
editable_file = os.path.join(project_dir, 'editable.txt')
with open(editable_file, 'w+') as f:
for item in editable:
item_path = item.split('#')[0]
item_path = item.split('[')[0].split('#')[0]
if item_path.startswith('.'):
item_path = os.path.abspath(os.path.join(current_dir, item_path)) # noqa
if os.path.isdir(item_path):
Expand Down

0 comments on commit 25ae5f9

Please sign in to comment.