From 26ea27d0e28ca675f57e909ef53c8c84d2e46e0a Mon Sep 17 00:00:00 2001 From: Jeremy Frasier Date: Wed, 6 Nov 2024 10:40:14 -0500 Subject: [PATCH] Modernize to agree with cisagov/skeleton-python-library Resolves #107. --- setup.py | 48 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/setup.py b/setup.py index b675f59..58bcc93 100644 --- a/setup.py +++ b/setup.py @@ -8,6 +8,10 @@ - https://blog.ionelmc.ro/2014/05/25/python-packaging/#the-structure """ +# Standard Python Libraries +import codecs +from os.path import abspath, dirname, join + # Third-Party Libraries from setuptools import setup @@ -18,12 +22,22 @@ def readme(): return f.read() -def package_vars(version_file): - """Read in and return the variables defined by the version_file.""" - pkg_vars = {} - with open(version_file) as f: - exec(f.read(), pkg_vars) # nosec - return pkg_vars +# Below two methods were pulled from: +# https://packaging.python.org/guides/single-sourcing-package-version/ +def read(rel_path): + """Open a file for reading from a given relative path.""" + here = abspath(dirname(__file__)) + with codecs.open(join(here, rel_path), "r") as fp: + return fp.read() + + +def get_version(version_file): + """Extract a version number from the given file path.""" + for line in read(version_file).splitlines(): + if line.startswith("__version__"): + delim = '"' if '"' in line else "'" + return line.split(delim)[1] + raise RuntimeError("Unable to find version string.") setup( @@ -33,13 +47,17 @@ def package_vars(version_file): description="Documentation for Github projects in the cisagov organization.", long_description=readme(), long_description_content_type="text/markdown", - # NCATS "homepage" - url="https://www.us-cert.gov/resources/ncats", - # The project's main homepage - download_url="https://github.com/cisagov/skeleton-python-library", + # Landing page for CISA's cybersecurity mission + url="https://www.cisa.gov/cybersecurity", + # Additional URLs for this project per + # https://packaging.python.org/guides/distributing-packages-using-setuptools/#project-urls + project_urls={ + "Source": "https://github.com/cisagov/development-guide", + "Tracker": "https://github.com/cisagov/development-guide/issues", + }, # Author details author="Cyber and Infrastructure Security Agency", - author_email="ncats@hq.dhs.gov", + author_email="github@cisa.dhs.gov", license="License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication", # See https://pypi.python.org/pypi?%3Aaction=list_classifiers classifiers=[ @@ -55,11 +73,15 @@ def package_vars(version_file): # Specify the Python versions you support here. In particular, ensure # that you indicate whether you support Python 2, Python 3 or both. "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: Implementation :: CPython", ], - python_requires=">=3.6", + python_requires=">=3.7", # What does your project relate to? keywords="documentation", package_dir={"": "project_setup/scripts"},