Browse Source

Parse requirements.txt containing comments

rafalp 6 years ago
parent
commit
8106ac59f9
1 changed files with 10 additions and 1 deletions
  1. 10 1
      setup.py

+ 10 - 1
setup.py

@@ -11,7 +11,16 @@ SETUP_DIR = os.path.dirname(__file__)
 README = open(os.path.join(SETUP_DIR, 'README.rst'), 'rb').read().decode('utf-8')
 
 with open(os.path.join(SETUP_DIR, 'requirements.txt'), "r") as f:
-    REQUIREMENTS = [x.strip() for x in f.readlines()]
+    REQUIREMENTS = []
+    for line in f.readlines():
+        line = line.strip()
+        if not line:
+            continue
+        if line.startswith('#'):
+            continue
+        if '#' in line:
+            line = line[:line.find('#')].strip()
+        REQUIREMENTS.append(line)
 
 
 # allow setup.py to be run from any path