Skip to content

Commit ecee2bf

Browse files
authored
Setup.cfg for py2 (NewFuture#483)
1 parent 860e601 commit ecee2bf

7 files changed

Lines changed: 35 additions & 13 deletions

File tree

.github/workflows/build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,9 @@ jobs:
159159
macos-app-name: ${{ runner.os == 'macOS' && 'DDNS' || '' }}
160160
macos-app-icon: ${{ runner.os == 'macOS' && 'doc/img/ddns.png' || '' }}
161161

162-
- run: ./dist/ddns || test -f config.json
162+
- run: ./dist/ddns -v
163163
- run: ./dist/ddns -h
164+
- run: ./dist/ddns || test -f config.json
164165

165166
# Upload build result
166167
- name: Upload Artifacts
@@ -309,6 +310,7 @@ jobs:
309310
echo "Loading image for $platform..."
310311
docker load < ddns-oci-${tag}.tar
311312
echo "Running test..."
313+
docker run --platform $platform --rm ${{ env.DOCKER_IMG }}:$tag -v
312314
docker run --platform $platform --rm ${{ env.DOCKER_IMG }}:$tag -h
313315
docker run --platform $platform --rm -v "$(pwd):/ddns/" ${{ env.DOCKER_IMG }}:$tag || test -e "config.json"
314316
sudo rm -f config.json

ddns/__init__.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
build_date = "${BUILD_DATE}"
1313

1414
__doc__ = """
15-
ddns[%s]
15+
ddns[{}@{}]
1616
(i) homepage or docs [文档主页]: https://ddns.newfuture.cc/
17-
(?) issues or bugs [问题和帮助]: https://github.com/NewFuture/DDNS/issues
17+
(?) issues or bugs [问题和反馈]: https://github.com/NewFuture/DDNS/issues
1818
Copyright (c) New Future (MIT License)
19-
""" % (
20-
__version__
21-
)
19+
""".format(__version__, build_date)

ddns/__main__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313

1414
import sys
1515

16-
from .__init__ import __version__ as version, __description__, __doc__
16+
from .__init__ import __version__, __description__, __doc__, build_date
1717
from .util import ip
1818
from .util.cache import Cache
1919
from .util.config import init_config, get_config
2020

21-
environ["DDNS_VERSION"] = "${BUILD_VERSION}"
21+
environ["DDNS_VERSION"] = __version__
2222

2323

2424
def is_false(value):
@@ -124,7 +124,7 @@ def main():
124124
# 兼容windows 和部分ASCII编码的老旧系统
125125
sys.stdout = TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
126126
sys.stderr = TextIOWrapper(sys.stderr.buffer, encoding='utf-8')
127-
init_config(__description__, __doc__, version)
127+
init_config(__description__, __doc__, __version__, build_date)
128128

129129
log_level = get_config('log.level')
130130
log_format = get_config('log.format', '%(asctime)s %(levelname)s [%(module)s]: %(message)s')
@@ -138,7 +138,7 @@ def main():
138138
filename=get_config('log.file'),
139139
)
140140

141-
info("DDNS[ %s ] run: %s %s", version, os_name, sys.platform)
141+
info("DDNS[ %s ] run: %s %s", __version__, os_name, sys.platform)
142142

143143
# Dynamically import the dns module as configuration
144144
dns_provider = str(get_config('dns', 'dnspod').lower())

ddns/util/config.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from logging import error, getLevelName
77
from ast import literal_eval
88

9+
import platform
910
import sys
1011

1112

@@ -75,15 +76,33 @@ def parse_array_string(value, enable_simple_split):
7576
return value
7677

7778

78-
def init_config(description, doc, version):
79+
def get_system_info_str():
80+
system = platform.system()
81+
release = platform.release()
82+
machine = platform.machine()
83+
arch = platform.architecture()[0] # '64bit' or '32bit'
84+
85+
return "{}-{} {} ({})".format(system, release, machine, arch)
86+
87+
88+
def get_python_info_str():
89+
version = platform.python_version()
90+
branch, py_build_date = platform.python_build()
91+
return "Python-{} {} ({})".format(version, branch, py_build_date)
92+
93+
94+
def init_config(description, doc, version, date):
7995
"""
8096
配置
8197
"""
8298
global __cli_args
8399
parser = ArgumentParser(
84100
description=description, epilog=doc, formatter_class=RawTextHelpFormatter
85101
)
86-
parser.add_argument("-v", "--version", action="version", version=version)
102+
sysinfo = get_system_info_str()
103+
pyinfo = get_python_info_str()
104+
version_str = "v{} ({})\n{}\n{}".format(version, date, pyinfo, sysinfo)
105+
parser.add_argument("-v", "--version", action="version", version=version_str)
87106
parser.add_argument(
88107
"-c", "--config", metavar="FILE", help="load config file [配置文件路径]"
89108
)

docker/test-in-docker.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ else
4141
fi
4242

4343
docker run --rm -v="$volume:/dist" --platform=$platform $container /dist/$file -h
44+
docker run --rm -v="$volume:/dist" --platform=$platform $container /dist/$file --version
4445
docker run --rm -v="$volume:/dist" --platform=$platform $container sh -c "/dist/$file || test -f config.json"
4546
# delete to avoid being reused
4647
docker image rm $container

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ dev = [
5454
# "pytest-cov",
5555
"black",
5656
"flake8",
57-
"setuptools_scm"
57+
# "setuptools_scm"
5858
]
5959

6060
# Setuptools configuration

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[bdist_wheel]
2+
universal = 1

0 commit comments

Comments
 (0)