Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/pypi-mathphys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ 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:
TWINE_USERNAME: __token__
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 ..
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
Expand Down
10 changes: 5 additions & 5 deletions mathphys/functions.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -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):
Expand Down
73 changes: 73 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
[build-system]
requires = ["setuptools>=44"]
build-backend = "setuptools.build_meta"

[project]
name = "mathphys"
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= "alvesb.murilo@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"
Repository = "https://github.com/lnls-fac/mathphys.git"
Issues = "https://github.com/lnls-fac/mathphys/issues"

# --- 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"]

# --- 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
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
importlib-metadata
numpy>=1.18,<=1.23
matplotlib>=3.1.2
h5py>=3.1.0
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down