From 9100efdf5058be39a4a7ddf987fa66106517cd26 Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Wed, 31 Jul 2019 17:34:36 +0300 Subject: [PATCH] Re-work as a proper standalone Python package Add a setup.py so that installation is easier and a standalone CLI script called csv-metadata-quality is provided. Now the user only needs to run this from a virtual environment inside the project directory: $ pip install . Eventually I could publish this on PyPi when I settle on a more appropriate package name. See: https://packaging.python.org/tutorials/packaging-projects/ See: https://chriswarrick.com/blog/2014/09/15/python-apps-the-right-way-entry_points-and-scripts/ --- csv_metadata_quality/__main__.py | 6 ++++- csv_metadata_quality/app.py | 2 +- setup.py | 38 ++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 setup.py diff --git a/csv_metadata_quality/__main__.py b/csv_metadata_quality/__main__.py index 82e0811..8b8bdb5 100644 --- a/csv_metadata_quality/__main__.py +++ b/csv_metadata_quality/__main__.py @@ -1,5 +1,9 @@ from csv_metadata_quality import app from sys import argv +def main(): + app.run(argv) + + if __name__ == '__main__': - app.main(argv) + main() diff --git a/csv_metadata_quality/app.py b/csv_metadata_quality/app.py index bc02a1a..4c27ecd 100644 --- a/csv_metadata_quality/app.py +++ b/csv_metadata_quality/app.py @@ -15,7 +15,7 @@ def parse_args(argv): return args -def main(argv): +def run(argv): args = parse_args(argv) # Read all fields as strings so dates don't get converted from 1998 to 1998.0 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..94424dc --- /dev/null +++ b/setup.py @@ -0,0 +1,38 @@ +import setuptools + +with open("README.md", "r") as fh: + long_description = fh.read() + +install_requires = [ + 'pandas', + 'python-stdnum', + 'requests', + 'requests-cache', + 'pycountry' +] + +setuptools.setup( + name="csv-metadata-quality", + version="0.0.1", + author="Alan Orth", + author_email="aorth@mjanja.ch", + description="A simple, but opinionated CSV quality checking and fixing pipeline.", + license="GPLv3", + long_description=long_description, + long_description_content_type="text/markdown", + url="https://github.com/alanorth/csv-metadata-quality", + classifiers=[ + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Operating System :: OS Independent", + "Development Status :: 4 - Beta" + ], + packages=['csv_metadata_quality'], + entry_points={ + 'console_scripts': [ + 'csv-metadata-quality = csv_metadata_quality.__main__:main' + ] + }, + install_requires=install_requires +)