Skip to content

Commit

Permalink
Merge pull request #789 from p-l-/fix-readme-pypi
Browse files Browse the repository at this point in the history
setup.py: hack distutils to handle README.md
  • Loading branch information
p-l- committed Sep 25, 2019
2 parents 8009f34 + 959f7dd commit 3defa66
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -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:

Expand All @@ -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 ###
Expand All @@ -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).
28 changes: 27 additions & 1 deletion setup.py
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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=[
Expand Down

0 comments on commit 3defa66

Please sign in to comment.