Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.

Commit c47d70b

Browse files
committed
Extract author, email, copyright, version, ... information from Python code.
1 parent 32c9c0a commit c47d70b

9 files changed

Lines changed: 41 additions & 23 deletions

File tree

.idea/modules.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
[![Requires.io](https://img.shields.io/requires/github/Paebbels/pyTerminalUI)](https://requires.io/github/Paebbels/pyTerminalUI/requirements/?branch=main)
1717
[![Read the Docs](https://img.shields.io/readthedocs/pyterminalui?label=ReadTheDocs&logo=readthedocs)](https://pyTerminalUI.readthedocs.io/)
1818
[![Documentation License](https://img.shields.io/badge/doc%20license-CC--BY%204.0-green?logo=readthedocs)](LICENSE.md)
19-
[![Documentation - Read Now!](https://img.shields.io/badge/doc-read%20now%20%E2%9E%94-blueviolet?logo=readthedocs)](https://pyTerminalUI.readthedocs.io/)
19+
[![Documentation - Read Now!](https://img.shields.io/badge/doc-read%20now%20%E2%9E%9A-blueviolet?logo=readthedocs)](https://pyTerminalUI.readthedocs.io/)
2020

2121
# pyTerminalUI
2222

doc/Dependencies.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,11 @@ Use the :file:`doc/requirements.txt` file to install all dependencies via
109109
+-------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------+----------------------+
110110
| **Package** | **Version** | **License** | **Dependencies** |
111111
+=================================================================================================+==============+==========================================================================================================+======================+
112-
| `Sphinx <https://github.com/sphinx-doc/sphinx>`__ | ≥4.1.1 | `BSD 3-Clause <https://github.com/sphinx-doc/sphinx/blob/master/LICENSE>`__ | *Not yet evaluated.* |
112+
| `Sphinx <https://github.com/sphinx-doc/sphinx>`__ | ≥4.3.0 | `BSD 3-Clause <https://github.com/sphinx-doc/sphinx/blob/master/LICENSE>`__ | *Not yet evaluated.* |
113113
+-------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------+----------------------+
114114
| `sphinx_btd_theme <https://github.com/buildthedocs/sphinx.theme>`__ | ≥0.5.2 | `MIT <https://github.com/buildthedocs/sphinx.theme/blob/master/LICENSE>`__ | *Not yet evaluated.* |
115115
+-------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------+----------------------+
116116
| !! `sphinx_fontawesome <https://github.com/fraoustin/sphinx_fontawesome>`__ | ≥0.0.6 | `GPL 2.0 <https://github.com/fraoustin/sphinx_fontawesome/blob/master/LICENSE>`__ | *Not yet evaluated.* |
117117
+-------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------+----------------------+
118118
| `sphinx_autodoc_typehints <https://github.com/agronholm/sphinx-autodoc-typehints>`__ | ≥1.12.0 | `MIT <https://github.com/agronholm/sphinx-autodoc-typehints/blob/master/LICENSE>`__ | *Not yet evaluated.* |
119119
+-------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------+----------------------+
120-
| `Pygments <https://github.com/pygments/pygments>`__ | ≥2.9.0 | `BSD 2-Clause <https://github.com/pygments/pygments/blob/master/LICENSE>`__ | *Not yet evaluated.* |
121-
+-------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------+----------------------+

doc/conf.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
# add these directories to sys.path here. If the directory is relative to the
1111
# documentation root, use os.path.abspath to make it absolute, like shown here.
1212
#
13-
import sys
13+
from json import loads
1414
from os.path import abspath
1515
from pathlib import Path
16-
from json import loads
16+
from sys import path as sys_path
1717

18-
sys.path.insert(0, abspath('.'))
19-
sys.path.insert(0, abspath('..'))
20-
sys.path.insert(0, abspath('../pyTooling.TerminalUI'))
21-
sys.path.insert(0, abspath('_extensions'))
22-
#sys.path.insert(0, os.path.abspath('_themes/sphinx_rtd_theme'))
18+
sys_path.insert(0, abspath('.'))
19+
sys_path.insert(0, abspath('..'))
20+
sys_path.insert(0, abspath('../pyTooling.TerminalUI'))
21+
sys_path.insert(0, abspath('_extensions'))
22+
#sys_path.insert(0, os.path.abspath('_themes/sphinx_rtd_theme'))
2323

2424

2525
# ==============================================================================

doc/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
:alt: Documentation License
6868
:height: 22
6969
:target: LICENSE.md
70-
.. |img-TerminalUI-doc| image:: https://img.shields.io/badge/doc-read%20now%20%E2%9E%94-blueviolet?logo=readthedocs
70+
.. |img-TerminalUI-doc| image:: https://img.shields.io/badge/doc-read%20now%20%E2%9E%9A-blueviolet?logo=readthedocs
7171
:alt: Documentation - Read Now!
7272
:height: 22
7373
:target: https://pyTerminalUI.readthedocs.io/

doc/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-r ../requirements.txt
22
# Enforce latest version on ReadTheDocs
3-
sphinx>=4.2.0
3+
sphinx>=4.3.0
44

55
# Sphinx Extenstions
66
#sphinx.ext.coverage

doc/shields.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,11 @@
170170
:target: https://github.com/pyTooling/pyTooling/blob/main/doc/Doc-License.rst
171171

172172
.. # GHPages - read now
173-
.. |SHIELD:svg:pyTooling-ghp-doc| image:: https://img.shields.io/badge/doc-read%20now%20%E2%9E%94-blueviolet
173+
.. |SHIELD:svg:pyTooling-ghp-doc| image:: https://img.shields.io/badge/doc-read%20now%20%E2%9E%9A-blueviolet
174174
:alt: Documentation - Read Now!
175175
:height: 22
176176
:target: https://pyTooling.github.io/pyTooling/
177-
.. |SHIELD:png:pyTooling-ghp-doc| image:: https://img.shields.io/badge/doc-read%20now%20%E2%9E%94-blueviolet
177+
.. |SHIELD:png:pyTooling-ghp-doc| image:: https://img.shields.io/badge/doc-read%20now%20%E2%9E%9A-blueviolet
178178
:alt: Documentation - Read Now!
179179
:height: 22
180180
:target: https://pyTooling.github.io/pyTooling/

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
colorama>=0.4.4
2+
23
pyTooling>=1.4.1

setup.py

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
# SPDX-License-Identifier: Apache-2.0
3030
# ============================================================================
3131
#
32+
from ast import parse as ast_parse, iter_child_nodes, Assign, Constant, Name
3233
from pathlib import Path
3334
from setuptools import (
3435
setup as setuptools_setup,
@@ -37,8 +38,27 @@
3738

3839
gitHubNamespace = "pyTooling"
3940
projectName = "TerminalUI"
40-
projectNameWithPrefix = "pyTooling." + projectName
41-
version = "1.5.2"
41+
prefix = "pyTooling"
42+
projectNameWithPrefix = f"{prefix}.{projectName}"
43+
__author = None
44+
__email = None
45+
__version = None
46+
47+
# Read __version__ from source file
48+
versionFile = Path(f"{projectName}/__init__.py")
49+
with versionFile.open("r") as file:
50+
for item in iter_child_nodes(ast_parse(file.read())):
51+
if isinstance(item, Assign) and len(item.targets) == 1:
52+
target = item.targets[0]
53+
value = item.value
54+
if isinstance(target, Name) and target.id == "__author__" and isinstance(value, Constant) and isinstance(value.value, str):
55+
__author = value.value
56+
if isinstance(target, Name) and target.id == "__email__" and isinstance(value, Constant) and isinstance(value.value, str):
57+
__email = value.value
58+
if isinstance(target, Name) and target.id == "__version__" and isinstance(value, Constant) and isinstance(value.value, str):
59+
__version = value.value
60+
if __version is None:
61+
raise AssertionError(f"Could not extract '__version__' from '{versionFile}'.")
4262

4363
# Read README for upload to PyPI
4464
readmeFile = Path("README.md")
@@ -57,13 +77,12 @@
5777
# Assemble all package information
5878
setuptools_setup(
5979
name=projectNameWithPrefix,
60-
version=version,
61-
62-
author="Patrick Lehmann",
63-
author_email="Paebbels@gmail.com",
80+
version=__version,
81+
author=__author,
82+
author_email=__email,
6483
# maintainer="Patrick Lehmann",
6584
# maintainer_email="Paebbels@gmail.com",
66-
license='Apache 2.0',
85+
license='Apache 2.0',
6786

6887
description="A set of helpers to implement a text user interface (TUI) in a terminal.",
6988
long_description=long_description,

0 commit comments

Comments
 (0)