From 9635dda441f4f601c35b31c8a18ddbd98385dfc5 Mon Sep 17 00:00:00 2001 From: "ayanbn7@gmail.com" Date: Thu, 8 Nov 2018 01:57:09 +0530 Subject: [PATCH] setup.py.jj2: Allow comments in requirements.txt Closes https://github.com/moremoban/pypi-mobans/issues/37 --- .moban.dt/local-README.rst.jj2 | 4 ++++ README.rst | 4 ++++ templates/setup.py.jj2 | 13 +++++++++++++ 3 files changed, 21 insertions(+) diff --git a/.moban.dt/local-README.rst.jj2 b/.moban.dt/local-README.rst.jj2 index 8d6d33d..5c85e09 100644 --- a/.moban.dt/local-README.rst.jj2 +++ b/.moban.dt/local-README.rst.jj2 @@ -28,6 +28,10 @@ setup.py - automatically do git release while uploading to pypi 3. configured to build universial wheels by default + +4. comes with a feature of removing comments from requirements.txt while loading +into setup.py + {% endblock %} {% block bottom_block %} diff --git a/README.rst b/README.rst index 8977d70..eb38d27 100644 --- a/README.rst +++ b/README.rst @@ -37,6 +37,10 @@ setup.py 3. configured to build universial wheels by default +4. comes with a feature of removing comments from requirements.txt while loading +into setup.py + + Installation ================================================================================ diff --git a/templates/setup.py.jj2 b/templates/setup.py.jj2 index b50e77e..94c5d8a 100644 --- a/templates/setup.py.jj2 +++ b/templates/setup.py.jj2 @@ -113,7 +113,20 @@ if python_implementation == "PyPy": INSTALL_REQUIRES = [ {% for dependency in dependencies: %} {% if ';' not in dependency and not dependency.startswith('#'): %} + {% if '#egg=' in dependency: %} + {% set dependency = dependency.split('#egg=') %} + {% set repo_link, egg_name = dependency[0], dependency[1] %} + {% set repo_link = repo_link.strip() %} + {% if '#' in egg_name: %} + {% set egg_name = egg_name.split('#')[0].strip() %} + {% endif %} + '{{[repo_link, egg_name] | join('#egg=')}}', + {% elif '#' in dependency: %} + {% set dependency = dependency.split('#')[0].strip() %} + '{{dependency}}', + {% else %} '{{dependency}}', + {% endif %} {% endif %} {% endfor %} ]