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

Commit 25ae5f9

Browse files
committed
add ability to handle extras with local paths
1 parent f08c361 commit 25ae5f9

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/pypi2nix/cli.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,17 @@ def handle_requirements_file(project_dir, requirements_file):
198198
requirements_line.startswith("-e hg+"):
199199
pass
200200
elif requirements_line.startswith("-e"):
201+
requirements_line = requirements_line.strip()[3:]
201202
try:
202203
tmp_path, egg = requirements_line.strip().split('#')
203204
tmp_name = egg.split('egg=')[1]
205+
_tmp = tmp_path.split('[')
206+
if len(_tmp) > 1:
207+
tmp_path = _tmp[0]
208+
tmp_other = '[' + _tmp[1]
209+
else:
210+
tmp_path = _tmp
211+
tmp_other = ''
204212
except:
205213
raise click.ClickException(
206214
"Requirement starting with `.` "
@@ -211,11 +219,11 @@ def handle_requirements_file(project_dir, requirements_file):
211219
tmp_path = os.path.abspath(os.path.join(
212220
os.path.dirname(requirements_file),
213221
os.path.abspath(os.path.join(
214-
current_dir, tmp_path.strip()[3:]
222+
current_dir, tmp_path
215223
)),
216224
))
217225

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

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

0 commit comments

Comments
 (0)