From b3d8343c0a4ac5d3338cb95954c7a9c03ca224ce Mon Sep 17 00:00:00 2001 From: Fernando Date: Thu, 5 Jun 2025 11:48:36 -0300 Subject: [PATCH 1/8] MNT: Add pyproject.toml and remove explicit usage of setup.py from Makefile. --- Makefile | 2 +- pyproject.toml | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 pyproject.toml diff --git a/Makefile b/Makefile index 2e816c4..4b3d53d 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ help: ## Show this help. @grep '##' Makefile| sed -e '/@/d' | sed -r 's,(.*?:).*##(.*),\1\2,g' dist: ## Build setuptools dist - python setup.py sdist bdist_wheel + python -m build distupload: ## Upload package dist to PyPi python -m twine upload --verbose dist/* diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..7eb46c6 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,34 @@ +[build-system] +requires = ["setuptools>=44"] +build-backend = "setuptools.build_meta" + +[project] +name = "mathphys" +authors = [{ name = "lnls-fac", email="xresende@gmail.com"} ] +description = "LNLS Math and Physics Utilities" +readme = "README.md" +dynamic = ["version", "dependencies"] +requires-python = ">=3.4" +classifiers = [ + "Intended Audience :: Science/Research", + "Programming Language :: Python", + "Topic :: Scientific/Engineering", +] +license = "MIT" +license-files= [ "LICENSE", ] + +[project.urls] +Homepage = "https://github.com/lnls-fac/mathphys" +Download = "https://github.com/lnls-fac/mathphys" + +# --- Configurações específicas do Setuptools --- +[tool.setuptools] +include-package-data = true + +[tool.setuptools.dynamic] +version = { file = "VERSION" } +dependencies = { file = "requirements.txt" } + +[tool.setuptools.package-data] +mathphys = ["VERSION"] + From 58ef8c64968253273bb1688dd6417e37ebd1367c Mon Sep 17 00:00:00 2001 From: Fernando Date: Thu, 5 Jun 2025 11:49:01 -0300 Subject: [PATCH 2/8] MNT: Remove usage of pkg_resources package. --- mathphys/functions.py | 10 +++++----- setup.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mathphys/functions.py b/mathphys/functions.py index f7ba61d..40f07c3 100644 --- a/mathphys/functions.py +++ b/mathphys/functions.py @@ -1,18 +1,18 @@ """Useful functions.""" import os as _os import builtins as _builtins -import importlib as _importlib from collections import namedtuple as _namedtuple from functools import partial as _partial import pickle as _pickle import subprocess as _subprocess -import pkg_resources as _pkg_resources +# NOTE: Change to importlib.metadata once python3.6 is not supported anymore: +import importlib_metadata as _implib_meta from types import ModuleType as _ModuleType import gzip as _gzip try: import h5py as _h5py -except: +except ModuleNotFoundError: _h5py = None @@ -305,8 +305,8 @@ def get_path_from_package(package): pkg = package.__package__ else: raise ValueError('Invalid package type, must be str or module') - dist = _pkg_resources.get_distribution(pkg) - return dist.location, dist.version + dist = _implib_meta.distribution(pkg) + return str(dist.locate_file("")), dist.version def is_git_repo(path): diff --git a/setup.py b/setup.py index bf38892..695d4de 100755 --- a/setup.py +++ b/setup.py @@ -1,12 +1,12 @@ #!/usr/bin/env python-sirius """Setup module.""" +import pathlib from setuptools import setup -import pkg_resources def get_abs_path(relative): - return pkg_resources.resource_filename(__name__, relative) + return str(pathlib.Path(__file__).parent / relative) with open(get_abs_path("README.md"), "r") as _f: From 89de3c79ceba65e218a488e525464b44371d4bbb Mon Sep 17 00:00:00 2001 From: fernandohds564 Date: Thu, 5 Jun 2025 18:46:57 -0300 Subject: [PATCH 3/8] Update test-mathphys.yml add python 3.6 to the tests. --- .github/workflows/test-mathphys.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-mathphys.yml b/.github/workflows/test-mathphys.yml index 9940ac7..f03a15f 100644 --- a/.github/workflows/test-mathphys.yml +++ b/.github/workflows/test-mathphys.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - python-version: [3.9, 3.11] + python-version: [3.6, 3.9, 3.11] steps: - uses: actions/checkout@v2 From aaf6cd2041b3c024cd60c4f9d8416f1731c34f8d Mon Sep 17 00:00:00 2001 From: fernandohds564 Date: Thu, 5 Jun 2025 18:47:39 -0300 Subject: [PATCH 4/8] Update requirements.txt add importlib-metadata to the list of requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index f4e0a77..5fb8af6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +importlib-metadata numpy>=1.18,<=1.23 matplotlib>=3.1.2 h5py>=3.1.0 From 0f4748028d9385491f9f5da8ce75b54da1fbbbe0 Mon Sep 17 00:00:00 2001 From: fernandohds564 Date: Thu, 5 Jun 2025 18:48:58 -0300 Subject: [PATCH 5/8] Update test-mathphys.yml remove python3.6, since it is not supported anymore. --- .github/workflows/test-mathphys.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-mathphys.yml b/.github/workflows/test-mathphys.yml index f03a15f..9940ac7 100644 --- a/.github/workflows/test-mathphys.yml +++ b/.github/workflows/test-mathphys.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - python-version: [3.6, 3.9, 3.11] + python-version: [3.9, 3.11] steps: - uses: actions/checkout@v2 From 8d419814a163fd0bbb04c7974c61480f2c5b39b0 Mon Sep 17 00:00:00 2001 From: fernandohds564 Date: Thu, 5 Jun 2025 18:53:17 -0300 Subject: [PATCH 6/8] Update pypi-mathphys.yml upload github workflow not to use setup.py explicitly. --- .github/workflows/pypi-mathphys.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pypi-mathphys.yml b/.github/workflows/pypi-mathphys.yml index 5257a22..5cd64f8 100644 --- a/.github/workflows/pypi-mathphys.yml +++ b/.github/workflows/pypi-mathphys.yml @@ -17,7 +17,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install setuptools wheel twine + pip install setuptools wheel twine build - name: Build and publish env: @@ -25,6 +25,6 @@ jobs: TWINE_PASSWORD: ${{ secrets.MATHPHYS_PYPI_TOKEN }} run: | git describe --tags | sed -e 's/^v//g' > mathphys/VERSION - python setup.py sdist bdist_wheel + python -m build twine upload dist/* cd .. From f0a0f475d186905302ce9dd315766bbf1ce90a7e Mon Sep 17 00:00:00 2001 From: fernandohds564 Date: Fri, 6 Jun 2025 11:57:03 -0300 Subject: [PATCH 7/8] Update pyproject.toml --- pyproject.toml | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7eb46c6..106b87e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,13 @@ build-backend = "setuptools.build_meta" [project] name = "mathphys" -authors = [{ name = "lnls-fac", email="xresende@gmail.com"} ] +authors = [{ name = "lnls-fac" } ] +maintainers = [ + {name = "Ana Oliveira", email = "ana.clara@lnls.br"}, + {name = "Ximenes Resende", email = "xresende@gmail.com"}, + {name = "Fernando H. de Sá", email = "fernandohds564@gmail.com"}, + {name = "Murilo Barbosa Alves", email= "murilo.alves@lnls.br"} +] description = "LNLS Math and Physics Utilities" readme = "README.md" dynamic = ["version", "dependencies"] @@ -20,6 +26,8 @@ license-files= [ "LICENSE", ] [project.urls] Homepage = "https://github.com/lnls-fac/mathphys" Download = "https://github.com/lnls-fac/mathphys" +Repository = "https://github.com/lnls-fac/mathphys.git" +Issues = "https://github.com/lnls-fac/mathphys/issues" # --- Configurações específicas do Setuptools --- [tool.setuptools] @@ -32,3 +40,34 @@ dependencies = { file = "requirements.txt" } [tool.setuptools.package-data] mathphys = ["VERSION"] +# --- linter and formatter configurations --- +[tool.ruff] +select = [ + "W", "E", "A", "B", "C90", "D", "I002", "N", "F", "G", "ARG", "S", "NPY"] +ignore = [ + "D203", "D204", "D213", "D215", "D400", "D401", "D404", "D406", "D407", + "D408", "D409", "D413", "E203", "E226"] +ignore-init-module-imports = true +preview = true +line-length = 79 +fix = true + +[tool.ruff.extend-per-file-ignores] +"__init__.py" = ["F401", "F821"] + +[tool.ruff.format] +skip-magic-trailing-comma = true + +[tool.ruff.lint.isort] +split-on-trailing-comma = false +combine-as-imports = true + +[tool.isort] +split_on_trailing_comma = false +combine_as_imports = true +combine_star = true +multi_line_output = "HANGING_INDENT" +order_by_type = false + +[tool.black] +line-length = 79 From 87b7648ee4f30345c78757b6ea81d933bf31170c Mon Sep 17 00:00:00 2001 From: fernandohds564 Date: Fri, 6 Jun 2025 13:03:38 -0300 Subject: [PATCH 8/8] Update pyproject.toml Co-authored-by: Murilo B. Alves --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 106b87e..5a06ade 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ maintainers = [ {name = "Ana Oliveira", email = "ana.clara@lnls.br"}, {name = "Ximenes Resende", email = "xresende@gmail.com"}, {name = "Fernando H. de Sá", email = "fernandohds564@gmail.com"}, - {name = "Murilo Barbosa Alves", email= "murilo.alves@lnls.br"} + {name = "Murilo Barbosa Alves", email= "alvesb.murilo@gmail.com"} ] description = "LNLS Math and Physics Utilities" readme = "README.md"