Skip to content

Commit

Permalink
Merge pull request #108 from cisagov/improvement/modernize-setup
Browse files Browse the repository at this point in the history
Modernize to agree with cisagov/skeleton-python-library
  • Loading branch information
jsf9k authored Nov 6, 2024
2 parents 658033e + 26ea27d commit 6222390
Showing 1 changed file with 35 additions and 13 deletions.
48 changes: 35 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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(
Expand All @@ -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=[
Expand All @@ -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"},
Expand Down

0 comments on commit 6222390

Please sign in to comment.