diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 04be6e7..c0779d7 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -74,6 +74,7 @@ body: - Python 3.9 - Python 3.8 - Python 3.7 + - Python 3.6 default: 1 validations: required: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c0d8d00..d67b8ee 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,7 +16,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-20.04, windows-2022, macOS-13] - python-version: [3.7, 3.8, 3.9, 3.10.0, 3.11.0, 3.12.0] + python-version: [3.6, 3.7, 3.8, 3.9, 3.10.0, 3.11.0, 3.12.0] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} diff --git a/dev-requirements.txt b/dev-requirements.txt index 2028f84..03bce60 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,7 +1,7 @@ requests==2.31.0 -setuptools==69.5.1 -wheel==0.43.0 -twine==5.0.0 +setuptools==40.8.0 +wheel==0.35.0 +twine==3.5.0 vulture>=1.0 bandit>=1.5.1 pydocstyle>=3.0.0 diff --git a/requirements.txt b/requirements.txt index 44f27bd..d8fcee2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ requests>=1.0.0 setuptools>=40.8.0 -wheel>=0.40.0 -twine>=4.0.0 +wheel>=0.35.0 +twine>=3.5.0 diff --git a/reserver/reserver_func.py b/reserver/reserver_func.py index 2c9d656..bbfcdc6 100644 --- a/reserver/reserver_func.py +++ b/reserver/reserver_func.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- """Reserver functions.""" -from requests import get +import requests +import requests.adapters from .reserver_param import PYPI_TEST_URL, PYPI_MAIN_URL from hashlib import sha256 from time import time @@ -32,7 +33,18 @@ def does_package_exist(suggested_name, test_pypi): url = PYPI_TEST_URL + "/" + suggested_name + "/" else: url = PYPI_MAIN_URL + "/" + suggested_name + "/" - response = get(url, timeout=5) + + s = requests.Session() + retries = requests.adapters.Retry( + total=5, + backoff_factor=0.1, + status_forcelist=[ 500, 502, 503, 504 ] + ) + + s.mount('http://', requests.adapters.HTTPAdapter(max_retries=retries)) + s.mount('https://', requests.adapters.HTTPAdapter(max_retries=retries)) + + response = s.get(url, timeout=5) return not response.status_code == 404 diff --git a/reserver/reserver_obj.py b/reserver/reserver_obj.py index d23a065..fa771cc 100644 --- a/reserver/reserver_obj.py +++ b/reserver/reserver_obj.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- """Reserver modules.""" from .reserver_func import does_package_exist, generate_template_setup_py +from .util import has_named_parameter from os import environ, path, getcwd, remove from shutil import rmtree from sys import executable @@ -93,10 +94,13 @@ def upload(self, package_name): error = None for command in commands: try: - check_output(command, shell=True, text=True) + if has_named_parameter(check_output, "text"): + check_output(command, shell=True, text=True) + else: + check_output(command, shell=True) except CalledProcessError as e: publish_failed = True - error = e.output + error = e.__str__() if command == commands[-2]: if "403" in error and "Invalid or non-existent authentication information" in error: error = "Invalid or non-existent authentication information(PyPI API Key)." diff --git a/reserver/util.py b/reserver/util.py new file mode 100644 index 0000000..a02da86 --- /dev/null +++ b/reserver/util.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +"""utility module.""" +from inspect import signature + + +def has_named_parameter(func, param_name): + """ + Check whether the given function has a parameter named param_name or not. + + :param func: function to check it's params + :type func: function + :param param_name: parameter's name + :type param_name: str + + :return: boolean + """ + _signature = signature(func) + parameter_names = [p.name for p in _signature.parameters.values()] + return param_name in parameter_names diff --git a/setup.py b/setup.py index 5daf019..88739fa 100644 --- a/setup.py +++ b/setup.py @@ -49,6 +49,7 @@ def read_description(): 'Natural Language :: English', 'License :: OSI Approved :: MIT License', 'Operating System :: OS Independent', + 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9',