From ff21177ecc56903861ca888ddb62c71f2d780425 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl>
Date: Fri, 5 Mar 2021 15:50:02 +0100
Subject: [PATCH] 1.3.2

---
 CHANGELOG.md               |  2 +-
 README.md                  | 20 ++++++++++++++++++++
 requirements.txt           |  2 +-
 setup.py                   |  2 +-
 snakehouse/__init__.py     |  3 ++-
 snakehouse/requirements.py | 23 +++++++++++++++++++++++
 6 files changed, 48 insertions(+), 4 deletions(-)
 create mode 100644 snakehouse/requirements.py

diff --git a/CHANGELOG.md b/CHANGELOG.md
index b0d13a3..4534a62 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,6 @@
 # v1.3.2
 
-* _TBA_
+* added `read_requirements_txt`
 
 # v1.3.1
 
diff --git a/README.md b/README.md
index 929e861..32258f3 100644
--- a/README.md
+++ b/README.md
@@ -73,3 +73,23 @@ logger = logging.getLogger(__name__)
 
 Otherwise `PyInit` won't be generated by Cython 
 and such module will be unimportable in Python. Normal import won't suffice.
+
+Further streamlining your builds
+--------------------------------
+
+If you add a MANIFEST.in file with contents:
+
+```
+include requirements.txt
+```
+
+Then you can write the following in your setup.py:
+
+```python
+from snakehouse import read_requirements_txt
+
+setup(install_requires=read_requirements_txt())                       
+```
+
+This will read in your requirements.txt and extract packages from there.
+Be sure to entertain it's [pydoc](snakehouse/requirements.py)!
diff --git a/requirements.txt b/requirements.txt
index e17969f..efe15f8 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,3 +1,3 @@
 Cython
 mako
-satella
+satella>=2.14.46
diff --git a/setup.py b/setup.py
index 5a0916f..b428c83 100644
--- a/setup.py
+++ b/setup.py
@@ -6,7 +6,7 @@ setup(keywords=['cython', 'extension', 'multiple', 'pyx'],
       packages=find_packages(include=['snakehouse']),
       version=__version__,
       install_requires=[
-            'Cython', 'mako', 'satella',
+            'Cython', 'mako', 'satella>=2.14.46',
       ],
       python_requires='!=2.7.*,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*',
       package_data={
diff --git a/snakehouse/__init__.py b/snakehouse/__init__.py
index 9588136..f11983c 100644
--- a/snakehouse/__init__.py
+++ b/snakehouse/__init__.py
@@ -1,5 +1,6 @@
 from .build import build
 from .multibuild import Multibuild
 from .faster_builds import monkey_patch_parallel_compilation
+from .requirements import read_requirements_txt
 
-__version__ = '1.3.2a1'
+__version__ = '1.3.2'
diff --git a/snakehouse/requirements.py b/snakehouse/requirements.py
new file mode 100644
index 0000000..e7bedce
--- /dev/null
+++ b/snakehouse/requirements.py
@@ -0,0 +1,23 @@
+from satella.files import read_lines
+
+
+def read_requirements_txt(path: str = 'requirements.txt'):
+    """
+    Read requirements.txt and parse it into a list of packages
+    as given by setup(install_required=).
+
+    This means it will read in all lines, discard empty and commented ones,
+    and discard all those who are an URL.
+
+    Remember to include your requirements.txt inside your MANIFEST.in!
+
+    :param path: path to requirements.txt. Default is `requirements.txt`.
+    :return: list of packages ready to be fed to setup(install_requires=)
+    """
+    lines = read_lines(path)
+    lines = (line.strip() for line in lines)
+    lines = (line for line in lines if not line.startswith('#'))
+    lines = (line for line in lines if not line.startswith('git+'))
+    lines = (line for line in lines if not line.startswith('http'))
+    lines = (line for line in lines if line)
+    return list(lines)
-- 
GitLab