From d9f9a9b023a1361dbfa3f5ef01ffa392e0dcf028 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 26 Mar 2024 09:01:01 +0800 Subject: [PATCH 1/7] Migrate from setup.py/setup.cfg to pyproject.toml --- pyproject.toml | 48 +++++++++++++++++++++++++++++++++++++++ setup.cfg | 2 -- setup.py | 61 -------------------------------------------------- 3 files changed, 48 insertions(+), 63 deletions(-) delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/pyproject.toml b/pyproject.toml index 18efb6c7..b256f99b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,51 @@ +[build-system] +requires = ["setuptools>=64", "setuptools_scm[toml]>=6.2"] +build-backend = "setuptools.build_meta" + +[project] +name = "HinetPy" +description = "A Python package to request and process seismic waveform data from NIED Hi-neta" +readme = "README.rst" +requires-python = ">=3.7" +authors = [{name = "Dongdong Tian", email = "seisman.info@gmail.com"}] +keywords = ["seismology", "NIED", "Hi-net", "waveform"] +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Science/Research", + "Intended Audience :: Education", + "License :: OSI Approved :: MIT License", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python", + "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 :: 3 :: Only", + "Topic :: Internet :: WWW/HTTP", + "Topic :: Scientific/Engineering :: Physics", + "Topic :: Utilities", +] +dependencies = ["requests"] +dynamic = ["version"] + +[project.urls] +homepage = "https://seisman.github.io/HinetPy/" +documentation = "https://seisman.github.io/HinetPy/" +repository = "https://github.com/seisman/HinetPy" + +[tool.setuptools] +license-files = ["LICENSE.txt"] + +[tool.setuptools.packages.find] +include = ["HinetPy*"] +exclude = ["docs", "tests"] + +[tool.setuptools_scm] +local_scheme = "node-and-date" +fallback_version = "999.999.999+unknown" + [tool.black] line-length = 88 exclude = ''' diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 2bcd70e3..00000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[flake8] -max-line-length = 88 diff --git a/setup.py b/setup.py deleted file mode 100644 index 43e066e6..00000000 --- a/setup.py +++ /dev/null @@ -1,61 +0,0 @@ -""" -Build and install the project. -""" - -from setuptools import find_packages, setup - -NAME = "HinetPy" -AUTHOR = "Dongdong Tian" -AUTHOR_EMAIL = "seisman.info@gmail.com" -LICENSE = "MIT License" -URL = "https://github.com/seisman/HinetPy" -DESCRIPTION = ( - "A Python package to request and process seismic waveform data from NIED Hi-net" -) -KEYWORDS = "Seismology, NIED, Hi-net, Waveform" -with open("README.rst", "r", encoding="utf8") as f: - LONG_DESCRIPTION = "".join(f.readlines()) - -PACKAGES = find_packages(exclude=["docs", "tests"]) -SCRIPTS = [] - -CLASSIFIERS = [ - "Development Status :: 4 - Beta", - "Intended Audience :: Science/Research", - "Intended Audience :: Education", - f"License :: OSI Approved :: {LICENSE}", - "Operating System :: POSIX :: Linux", - "Programming Language :: Python", - "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 :: 3 :: Only", - "Topic :: Internet :: WWW/HTTP", - "Topic :: Scientific/Engineering :: Physics", - "Topic :: Utilities", -] -INSTALL_REQUIRES = ["requests"] -# Configuration for setuptools-scm -SETUP_REQUIRES = ["setuptools_scm"] -USE_SCM_VERSION = {"local_scheme": "node-and-date", "fallback_version": "unknown"} - -if __name__ == "__main__": - setup( - name=NAME, - description=DESCRIPTION, - long_description=LONG_DESCRIPTION, - use_scm_version=USE_SCM_VERSION, - author=AUTHOR, - author_email=AUTHOR_EMAIL, - license=LICENSE, - url=URL, - scripts=SCRIPTS, - packages=PACKAGES, - classifiers=CLASSIFIERS, - keywords=KEYWORDS, - install_requires=INSTALL_REQUIRES, - setup_requires=SETUP_REQUIRES, - ) From 875bcd7029834bd77f9f1c29e5fb6a19362a8be8 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 26 Mar 2024 09:10:31 +0800 Subject: [PATCH 2/7] Update the install commands --- .github/workflows/docs.yml | 4 ++-- .github/workflows/pypi-publish.yml | 2 +- .github/workflows/tests.yml | 4 ++-- Makefile | 2 +- docs/installation.rst | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index ffe70a9c..fd51968e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -30,8 +30,8 @@ jobs: run: | pip install -r requirements.txt pip install sphinx sphinx-intl sphinx_rtd_theme - python setup.py sdist --formats=zip - pip install dist/* + python -m build --sdist + python -m install dist/* - name: Build documentation run: make doc diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml index 1f8a777a..ca65d66c 100644 --- a/.github/workflows/pypi-publish.yml +++ b/.github/workflows/pypi-publish.yml @@ -27,7 +27,7 @@ jobs: - name: Build and publish run: | - python setup.py sdist bdist_wheel + python -m build ls -lh dist/ - name: Publish to PyPI diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d686a03d..d5784713 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -40,8 +40,8 @@ jobs: run: | pip install -r requirements.txt pip install pytest>=6.0 pytest-cov coverage[toml] codecov setuptools - python setup.py sdist --formats=zip - pip install dist/* + python -m build --sdist + python -m pip install dist/* - name: Install win32tools run: | diff --git a/Makefile b/Makefile index 28fe945b..8494c08d 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ help: @echo "" install: - pip install --no-deps -e . + python -m pip install --no-deps -e . test: pytest tests/test_*.py diff --git a/docs/installation.rst b/docs/installation.rst index 04a87f8a..b4b98240 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -15,17 +15,17 @@ Install HinetPy To install the latest **release/stable** version:: - pip install HinetPy + python -m pip install HinetPy Or install the **developing/unstable** version:: git clone https://github.com/seisman/HinetPy cd HinetPy - python setup.py install + python -m pip install . If you want to uninstall HinetPy, just run:: - pip uninstall HinetPy + python -m pip uninstall HinetPy Build win32tools ---------------- From db3c6de2e61f721cd29f9be5a5e47e0d8fcba4a0 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 26 Mar 2024 09:13:51 +0800 Subject: [PATCH 3/7] Fix --- .github/workflows/check.yml | 4 ++-- .github/workflows/docs.yml | 4 ++-- .github/workflows/pypi-publish.yml | 7 ++----- .github/workflows/tests.yml | 4 ++-- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index e5550d51..21ce8064 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -25,8 +25,8 @@ jobs: - name: Install dependencies run: | - pip install -r requirements.txt - pip install black blackdoc flake8 isort + python -m pip install -r requirements.txt + python -m pip install black blackdoc flake8 isort - name: Check code style run: make check diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index fd51968e..09c431a1 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -28,8 +28,8 @@ jobs: - name: Install dependencies run: | - pip install -r requirements.txt - pip install sphinx sphinx-intl sphinx_rtd_theme + python -m pip install -r requirements.txt + python -m pip install build sphinx sphinx-intl sphinx_rtd_theme python -m build --sdist python -m install dist/* diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml index ca65d66c..be32104b 100644 --- a/.github/workflows/pypi-publish.yml +++ b/.github/workflows/pypi-publish.yml @@ -21,12 +21,9 @@ jobs: with: python-version: '3.x' - - name: Install dependencies - run: | - pip install setuptools wheel - - - name: Build and publish + - name: Build run: | + python -m install build python -m build ls -lh dist/ diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d5784713..48f77749 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -38,8 +38,8 @@ jobs: - name: Install dependencies run: | - pip install -r requirements.txt - pip install pytest>=6.0 pytest-cov coverage[toml] codecov setuptools + python -m pip install -r requirements.txt + python -m pip install build pytest>=6.0 pytest-cov coverage[toml] codecov python -m build --sdist python -m pip install dist/* From b78b02617aa579dcb3c1ccf93301a8a9842e80d1 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 26 Mar 2024 09:17:07 +0800 Subject: [PATCH 4/7] Typo --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 09c431a1..6b8f97e7 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -31,7 +31,7 @@ jobs: python -m pip install -r requirements.txt python -m pip install build sphinx sphinx-intl sphinx_rtd_theme python -m build --sdist - python -m install dist/* + python -m pip install dist/* - name: Build documentation run: make doc From fc3eb35f0ade435192043bf743b69f39cba17e3d Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 26 Mar 2024 13:00:37 +0800 Subject: [PATCH 5/7] Minor fix --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index bcf0891d..020c0309 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -39,7 +39,7 @@ jobs: run: | python -m pip install -r requirements.txt python -m pip install build sphinx sphinx-intl sphinx_rtd_theme - python setup.py sdist --formats=zip + python -m build --sdist python -m pip install dist/* - name: Build documentation From 0849f919385e45b6aa8b05947d8483a9fad8a208 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 26 Mar 2024 13:13:47 +0800 Subject: [PATCH 6/7] Replace pkg_resouces with importlib --- HinetPy/__init__.py | 4 ++-- HinetPy/utils.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/HinetPy/__init__.py b/HinetPy/__init__.py index f672c48d..b0cc2dfc 100644 --- a/HinetPy/__init__.py +++ b/HinetPy/__init__.py @@ -19,11 +19,11 @@ # pylint: disable=invalid-name -from pkg_resources import get_distribution +from importlib.metadata import version from .client import Client from .header import NETWORK __all__ = ["Client", "NETWORK", "win32"] # Get semantic version through setuptools-scm -__version__ = f'v{get_distribution("HinetPy").version}' # e.g. v0.1.2.dev3+g0ab3cd78 +__version__ = f'v{version("HinetPy")}' # e.g. v0.1.2.dev3+g0ab3cd78 diff --git a/HinetPy/utils.py b/HinetPy/utils.py index 93a589d7..8cb76c44 100644 --- a/HinetPy/utils.py +++ b/HinetPy/utils.py @@ -8,7 +8,7 @@ from distutils.version import LooseVersion import requests -from pkg_resources import get_distribution +from importlib.metadata import version def split_integer(number, maxn): @@ -253,7 +253,7 @@ def check_package_release(): raise requests.HTTPError("Error in connecting to PyPI.") latest_release = res.json()["info"]["version"] - current_version = f'{get_distribution("HinetPy").version}' + current_version = f'v{version("HinetPy")}' if LooseVersion(latest_release) > LooseVersion(current_version): print( f"HinetPy v{latest_release} is released. " From ec8596ada80c95f04d76a27a3b8c61bf57ba99fb Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 26 Mar 2024 13:21:00 +0800 Subject: [PATCH 7/7] Drop support of Python 3.7 --- .github/workflows/tests.yml | 2 +- HinetPy/utils.py | 4 ++-- docs/changelog.rst | 1 + docs/installation.rst | 2 +- docs/locale/zh_CN/LC_MESSAGES/installation.po | 2 +- pyproject.toml | 3 +-- requirements.txt | 1 + 7 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9f216b46..6d736231 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -22,7 +22,7 @@ jobs: max-parallel: 1 # Hinet doesn't allow parallel data request fail-fast: false matrix: - python-version: ["3.7", "3.12"] + python-version: ["3.8", "3.12"] os: [macos-latest, ubuntu-latest] steps: diff --git a/HinetPy/utils.py b/HinetPy/utils.py index 8cb76c44..c0a063e7 100644 --- a/HinetPy/utils.py +++ b/HinetPy/utils.py @@ -5,7 +5,7 @@ import math import shutil from datetime import date, datetime -from distutils.version import LooseVersion +from packaging.version import Version import requests from importlib.metadata import version @@ -254,7 +254,7 @@ def check_package_release(): latest_release = res.json()["info"]["version"] current_version = f'v{version("HinetPy")}' - if LooseVersion(latest_release) > LooseVersion(current_version): + if Version(latest_release) > Version(current_version): print( f"HinetPy v{latest_release} is released. " + "See https://pypi.org/project/HinetPy/ for details." diff --git a/docs/changelog.rst b/docs/changelog.rst index 92f79d48..906916dd 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -3,6 +3,7 @@ Changelog 0.7.2 (XXXX-XX-XX) - Remove the hacking solution for SSL connection issue so it works well with urllib3 v2.x +- Drop support for Python 3.7. 0.7.1 (2022-07-08): - Fix bugs in `get_event_waveform` diff --git a/docs/installation.rst b/docs/installation.rst index b4b98240..2cf7e220 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -6,7 +6,7 @@ Prerequisites To use HinetPy, you need: -- Python >= 3.7 +- Python >= 3.8 - win32tools provided by NIED Hi-net (see below for install instructions) - a Hi-net account (register on Hi-net website to get your user name and password) diff --git a/docs/locale/zh_CN/LC_MESSAGES/installation.po b/docs/locale/zh_CN/LC_MESSAGES/installation.po index 8fe2af57..1b7e802e 100644 --- a/docs/locale/zh_CN/LC_MESSAGES/installation.po +++ b/docs/locale/zh_CN/LC_MESSAGES/installation.po @@ -29,7 +29,7 @@ msgid "To use HinetPy, you need:" msgstr "为了使用 HinetPy,你需要:" #: ../../installation.rst:9 -msgid "Python >= 3.7" +msgid "Python >= 3.8" msgstr "" #: ../../installation.rst:10 diff --git a/pyproject.toml b/pyproject.toml index b256f99b..2a0dd04c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta" name = "HinetPy" description = "A Python package to request and process seismic waveform data from NIED Hi-neta" readme = "README.rst" -requires-python = ">=3.7" +requires-python = ">=3.8" authors = [{name = "Dongdong Tian", email = "seisman.info@gmail.com"}] keywords = ["seismology", "NIED", "Hi-net", "waveform"] classifiers = [ @@ -16,7 +16,6 @@ classifiers = [ "License :: OSI Approved :: MIT License", "Operating System :: POSIX :: Linux", "Programming Language :: Python", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", diff --git a/requirements.txt b/requirements.txt index f2293605..64e6ca44 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ requests +packaging