From 706b1f5ed5aea20284bd359410479dcca3e7a2a8 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 31 Dec 2019 00:07:54 -0700 Subject: [PATCH] setuptools & metadata --- hyperglass/__init__.py | 9 ++++++++ setup.py | 49 +++++++++++++++++++++++++++++++----------- 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/hyperglass/__init__.py b/hyperglass/__init__.py index e1979c5..2118959 100644 --- a/hyperglass/__init__.py +++ b/hyperglass/__init__.py @@ -37,6 +37,7 @@ POSSIBILITY OF SUCH DAMAGE. """ # Standard Library Imports +from datetime import datetime import sys # Third Party Imports @@ -55,3 +56,11 @@ from hyperglass import util stackprinter.set_excepthook() uvloop.install() + +__name__ = "hyperglass" +__version__ = "1.0.0" +__author__ = "Matt Love" +__copyright__ = f"Copyright {datetime.now().year} Matthew Love" +__license__ = "BSD 3-Clause Clear License" + +meta = (__name__, __version__, __author__, __copyright__, __license__) diff --git a/setup.py b/setup.py index 3ef1b3b..ce5c7fb 100644 --- a/setup.py +++ b/setup.py @@ -1,30 +1,55 @@ +"""hyperglass setuptools.""" + # Standard Library Imports import sys +from configparser import ConfigParser from distutils.core import setup +from pathlib import Path -if sys.version_info < (3, 7): - sys.exit("Python 3.7+ is required.") +# Project Imports +from hyperglass import meta +# Project metadata +__name__, __version__, __author__, __copyright__, __license__ = meta -with open("README.md", "r") as ld: +# Path & file objects +root_dir = Path.cwd() +pipfile = root_dir / "Pipfile" +readme = root_dir / "README.md" + +# Read Pipfile +config = ConfigParser() +config.read_file(pipfile.open("r")) + +# Pipenv requirements +requirements = list(config["packages"].keys()) +dev_requirements = list(config["dev-packages"].keys()) + +# Pipenv Python versions +_parsed_py_ver = tuple(config["requires"].values())[0] +python_version = tuple(int(i) for i in _parsed_py_ver.strip('"').split(".")) +pretty_python_version = ".".join(python_version) + +if sys.version_info < python_version: + sys.exit(f"Python {pretty_python_version}+ is required.") + +with readme.open("r") as ld: long_description = ld.read() -with open("requirements.txt", "r") as req: - requirements = req.read().split("\n") - desc = "hyperglass is a modern, customizable network looking glass written in Python 3." setup( - name="hyperglass", - version="1.0.0", - author="Matt Love", + name=__name__, + version=__version__, + author=__author__, author_email="matt@hyperglass.io", description=desc, url="https://github.com/checktheroads/hyperglass", - python_requires=">=3.7", - packages=["hyperglass"], + python_requires=f">={pretty_python_version}", + packages=[__name__], install_requires=requirements, - license="BSD 3-Clause Clear License", + extras_require={"dev": dev_requirements}, + license=__license__, long_description=long_description, long_description_content_type="text/markdown", )