|
3 | 3 |
|
4 | 4 | # Python Repo Template
|
5 | 5 | # ..................................
|
6 |
| -# Copyright (c) 2017-2020, Kendrick Walls |
| 6 | +# Copyright (c) 2017-2024, Kendrick Walls |
7 | 7 | # ..................................
|
8 | 8 | # Licensed under MIT (the "License");
|
9 | 9 | # you may not use this file except in compliance with the License.
|
|
17 | 17 | # See the License for the specific language governing permissions and
|
18 | 18 | # limitations under the License.
|
19 | 19 |
|
| 20 | +"""Sets up the package. |
| 21 | +
|
| 22 | +Minimal Acceptance Testing: |
| 23 | +
|
| 24 | + Testcase 0: Just setup test fixtures by importing pythonrepo. |
| 25 | +
|
| 26 | + >>> import pythonrepo |
| 27 | + >>> |
| 28 | + >>> pythonrepo.__package__ is not None |
| 29 | + True |
| 30 | + >>> |
| 31 | +
|
| 32 | +""" |
20 | 33 |
|
21 | 34 | try:
|
| 35 | + import os |
| 36 | + import warnings |
| 37 | + warnings.simplefilter("default") # Change the filter in this process |
| 38 | + os.environ["PYTHONWARNINGS"] = "default" # Also affect subprocesses |
22 | 39 | from setuptools import setup
|
23 | 40 | from setuptools import find_packages
|
| 41 | + with warnings.catch_warnings(): |
| 42 | + warnings.simplefilter("ignore") |
| 43 | + try: |
| 44 | + from setuptools.config import read_configuration |
| 45 | + except Exception: |
| 46 | + from setuptools.config.setupcfg import read_configuration |
24 | 47 | except Exception:
|
25 |
| - raise ImportError("""Not Implemented.""") |
| 48 | + raise NotImplementedError("""[CWE-440] Not Implemented.""") |
26 | 49 |
|
27 | 50 |
|
28 | 51 | def readFile(filename):
|
29 |
| - """Helper Function to read files""" |
| 52 | + """Will attempt to read the file at with the given filename or path. |
| 53 | +
|
| 54 | + Used as a helper function to read files and return strings with the content. |
| 55 | +
|
| 56 | + Testing: |
| 57 | +
|
| 58 | + First setup test fixtures by importing pythonrepo. |
| 59 | +
|
| 60 | + >>> import pythonrepo |
| 61 | + >>> |
| 62 | +
|
| 63 | + Testcase 0: Should have Function readFile() WHEN loading setup.py. |
| 64 | +
|
| 65 | + >>> pythonrepo.readFile is not None |
| 66 | + True |
| 67 | + >>> type(pythonrepo.readFile) is type(1) |
| 68 | + False |
| 69 | + >>> |
| 70 | +
|
| 71 | + """ |
30 | 72 | theResult = None
|
31 |
| - if filename in ("""README.md""", """LICENSE.md"""): |
32 |
| - try: |
33 |
| - with open(str("""./{}""").format(str(filename))) as file: |
34 |
| - theResult = file.read() |
35 |
| - except Exception: |
36 |
| - theResult = str( |
37 |
| - """See https://github.com/reactive-firewall/python-repo/{}""" |
38 |
| - ).format(filename) |
39 |
| - return theResult |
| 73 | + try: |
| 74 | + if str("""E.md""") not in filename: |
| 75 | + raise NotImplementedError("""[CWE-440] Not Implemented.""") |
| 76 | + with open(str("""./{}""").format(str(filename))) as f: |
| 77 | + theResult = f.read() |
| 78 | + except Exception: |
| 79 | + theResult = str( |
| 80 | + """See https://github.com/reactive-firewall/python-repo/{}""" |
| 81 | + ).format(filename) |
| 82 | + return str(theResult) |
40 | 83 |
|
41 | 84 |
|
42 | 85 | try:
|
43 |
| - with open("""./requirements.txt""") as f: |
44 |
| - requirements = f.read().splitlines() |
| 86 | + with open("""./requirements.txt""") as rfile: |
| 87 | + requirements = rfile.read().splitlines() |
45 | 88 | except Exception:
|
46 | 89 | requirements = None
|
47 | 90 |
|
| 91 | + |
| 92 | +conf_dict = None |
| 93 | + |
| 94 | + |
| 95 | +with warnings.catch_warnings(): |
| 96 | + warnings.simplefilter("ignore") |
| 97 | + conf_dict = read_configuration("""setup.cfg""", ignore_option_errors=True) |
| 98 | + |
| 99 | + |
48 | 100 | readme = readFile("""README.md""")
|
| 101 | +"""The multi-line description and/or summary of this program.""" |
| 102 | + |
49 | 103 | SLA = readFile("""LICENSE.md""")
|
| 104 | +"""The "Software License Agreement" of this program.""" |
| 105 | + |
| 106 | +try: |
| 107 | + class_tags = [ |
| 108 | + str("""Development Status :: 4 - Beta"""), |
| 109 | + str("""Environment :: Console"""), |
| 110 | + str("""Intended Audience :: Developers"""), |
| 111 | + str("""Operating System :: MacOS :: MacOS X"""), |
| 112 | + str("""Operating System :: POSIX :: Linux"""), |
| 113 | + str("""License :: OSI Approved :: MIT License"""), |
| 114 | + str("""Programming Language :: Python :: 3"""), |
| 115 | + str("""Programming Language :: Python :: 3 :: Only"""), |
| 116 | + str("""Programming Language :: Python :: 3.14"""), |
| 117 | + str("""Programming Language :: Python :: 3.13"""), |
| 118 | + str("""Programming Language :: Python :: 3.12"""), |
| 119 | + str("""Programming Language :: Python :: 3.11"""), |
| 120 | + str("""Programming Language :: Python :: 3.10"""), |
| 121 | + str("""Programming Language :: Python :: 3.9"""), |
| 122 | + str("""Programming Language :: Python :: 3.8"""), |
| 123 | + str("""Programming Language :: Python :: 3.7"""), |
| 124 | + str("""Programming Language :: Python :: 3.6"""), |
| 125 | + str("""Programming Language :: Python :: 3.5"""), |
| 126 | + str("""Programming Language :: Python :: 3.4"""), |
| 127 | + str("""Programming Language :: Python :: 2.7"""), |
| 128 | + str("""Topic :: Software Development :: Libraries :: Python Modules""") |
| 129 | + ] |
| 130 | +except Exception: |
| 131 | + class_tags = str("""Development Status :: 4 - Beta""") |
50 | 132 |
|
51 | 133 | setup(
|
52 |
| - name="""pythonrepo""", |
53 |
| - version="""1.1.4""", |
54 |
| - description="""Python Repo""", |
| 134 | + name=conf_dict["""metadata"""]["""name"""], |
| 135 | + version=conf_dict["""metadata"""]["""version"""], |
| 136 | + description=conf_dict["""metadata"""]["""description"""], |
55 | 137 | long_description=readme,
|
| 138 | + long_description_content_type="""text/markdown""", |
| 139 | + zip_safe=True, |
| 140 | + include_package_data=True, |
56 | 141 | install_requires=requirements,
|
57 |
| - author="""reactive-firewall""", |
58 |
| - author_email="""[email protected]""", |
59 |
| - url="""https://github.com/reactive-firewall/python-repo.git""", |
| 142 | + author=conf_dict["""metadata"""]["""author"""], |
| 143 | + author_email=conf_dict["""metadata"""]["""author_email"""], |
| 144 | + classifiers=class_tags, |
| 145 | + url=conf_dict["""metadata"""]["""url"""], |
| 146 | + download_url=conf_dict["""metadata"""]["""download_url"""], |
60 | 147 | license=SLA,
|
61 | 148 | packages=find_packages(exclude=("""tests""", """docs""")),
|
62 | 149 | )
|
0 commit comments