From 959f7dd08d9abe1eadd7223bf38273e0b007f88d Mon Sep 17 00:00:00 2001 From: Pierre LALET Date: Wed, 25 Sep 2019 13:28:19 +0200 Subject: [PATCH] setup.py: hack distutils to handle README.md --- README.md | 6 +++--- setup.py | 28 +++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ac62610059..a7fc277f4a 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ If you are using IVRE in you research, please cite it as follows: Pierre Lalet, Florent Monjalet, Camille Mougey and Vivien Venuti. *IVRE, a network recon framework*. [https://github.com/cea-sec/ivre](https://github.com/cea-sec/ivre), -2011-2018. +2011-2019. Here is the appropriate bibtex entry: @@ -124,7 +124,7 @@ Here is the appropriate bibtex entry: url = {https://ivre.rocks/}, howpublished = {\url{https://github.com/cea-sec/ivre/}}, institution = {{CEA}: the French Alternative Energies and Atomic Energy Commission}, - year = {2011--2018}, + year = {2011--2019}, } ### Technical documents & blog posts ### @@ -139,4 +139,4 @@ On twitter, you can follow and/or mention --- -This file is part of IVRE. Copyright 2011 - 2018 [Pierre LALET](mailto:pierre.lalet@cea.fr). +This file is part of IVRE. Copyright 2011 - 2019 [Pierre LALET](mailto:pierre.lalet@cea.fr). diff --git a/setup.py b/setup.py index 60ba38ebce..7cd001fd43 100755 --- a/setup.py +++ b/setup.py @@ -30,7 +30,9 @@ from distutils.core import setup from distutils.command.install_data import install_data from distutils.command.install_lib import install_lib +from distutils.dist import DistributionMetadata import os +from tempfile import TemporaryFile VERSION = __import__('ivre').VERSION @@ -85,6 +87,30 @@ def run(self): with open(os.path.join(os.path.abspath(os.path.dirname('__file__')), 'README.md')) as fdesc: long_description = fdesc.read() +long_description_content_type = 'text/markdown' + + +# Monkey patching (distutils does not handle Description-Content-Type +# from long_description_content_type parameter in setup()). +_write_pkg_file_orig = DistributionMetadata.write_pkg_file + + +def _write_pkg_file(self, file): + with TemporaryFile(mode="w+") as tmpfd: + _write_pkg_file_orig(self, tmpfd) + tmpfd.seek(0) + for line in tmpfd: + if line.startswith('Metadata-Version: '): + file.write('Metadata-Version: 2.1\n') + elif line.startswith('Description: '): + file.write('Description-Content-Type: %s; charset=UTF-8\n' % + long_description_content_type) + file.write(line) + else: + file.write(line) + + +DistributionMetadata.write_pkg_file = _write_pkg_file setup( @@ -97,7 +123,7 @@ def run(self): license='GPLv3+', description='Network recon framework', long_description=long_description, - long_description_content_type='text/markdown', + long_description_content_type=long_description_content_type, keywords=["network", "network recon", "network cartography", "nmap", "masscan", "zmap", "bro", "zeek", "p0f"], classifiers=[