Skip to content

Commit 867896f

Browse files
committed
Ensure only relative paths are used in requirements.txt.
1 parent cac77b1 commit 867896f

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ clean :
1919

2020
requirements.txt : requirements.in setup.py
2121
pip-compile -v requirements.in
22+
./make_paths_relative.py < requirements.txt > requirements.tmp
23+
mv requirements.tmp $@

make_paths_relative.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env python
2+
import os
3+
import re
4+
import sys
5+
6+
pattern = re.compile(r"\s*-e\s+file://(?P<path>.*?)\n")
7+
inputs = sys.stdin.readlines()
8+
for line in inputs:
9+
match = pattern.match(line)
10+
if match:
11+
path = match.group("path")
12+
path = os.path.relpath(path)
13+
line = f"-e {path}\n"
14+
sys.stdout.write(line)

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# pip-compile --output-file requirements.txt requirements.in
66
#
7-
-e file:///Users/till/git/pythonflow
7+
-e .
88
alabaster==0.7.12 # via sphinx
99
astroid==1.6.5 # via pylint
1010
atomicwrites==1.3.0 # via pytest

0 commit comments

Comments
 (0)