Skip to content

Commit

Permalink
Merge pull request #12 from BristolComputing/kreczko-fixing-github-ac…
Browse files Browse the repository at this point in the history
…tions

build: switch to hatchling (dynamic version, better external data)
  • Loading branch information
kreczko authored Dec 7, 2023
2 parents 4a96ac9 + 8d8e955 commit eafb9d6
Show file tree
Hide file tree
Showing 18 changed files with 201 additions and 155 deletions.
94 changes: 40 additions & 54 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
ci:
autoupdate_commit_msg: "chore: update pre-commit hooks"
autofix_commit_msg: "style: pre-commit fixes"

repos:
- repo: https://github.com/psf/black
rev: 22.6.0
- repo: https://github.com/psf/black-pre-commit-mirror
rev: "23.11.0"
hooks:
- id: black-jupyter

- repo: https://github.com/adamchainz/blacken-docs
rev: "1.16.0"
hooks:
- id: blacken-docs
additional_dependencies: [black==23.*]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: "v4.5.0"
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -21,84 +31,48 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
rev: "v1.10.0"
hooks:
- id: python-check-blanket-noqa
- id: python-check-blanket-type-ignore
- id: python-no-eval
- id: python-use-type-annotations
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v2.7.1"
rev: "v3.1.0"
hooks:
- id: prettier
types_or: [yaml, markdown, html, css, scss, javascript, json]
args: [--prose-wrap=always]

- repo: https://github.com/asottile/blacken-docs
rev: v1.12.1
hooks:
- id: blacken-docs
additional_dependencies: [black==22.3.0]

- repo: https://github.com/PyCQA/isort
rev: 5.10.1
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.5"
hooks:
- id: isort
args: ["-a", "from __future__ import annotations"] # Python 3.7+

- repo: https://github.com/asottile/pyupgrade
rev: v2.34.0
hooks:
- id: pyupgrade
args: ["--py37-plus"]

- repo: https://github.com/hadialqattan/pycln
rev: v1.3.5
hooks:
- id: pycln
additional_dependencies: [click<8.1]
args: [--all]
stages: [manual]

- repo: https://github.com/asottile/yesqa
rev: v1.3.0
hooks:
- id: yesqa
exclude: docs/conf.py
additional_dependencies: &flake8_dependencies
- flake8-bugbear
- flake8-print

- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
exclude: docs/conf.py
additional_dependencies: *flake8_dependencies
- id: ruff
args: ["--fix", "--show-fixes"]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.961
rev: "v1.7.0"
hooks:
- id: mypy
files: src
files: src|tests
args: []
additional_dependencies:
- codetiming
- fasthep_logging
- pyhdfs
- pytest
- typer
- types-requests

- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
rev: "v2.2.6"
hooks:
- id: codespell

- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.8.0.4
rev: "v0.9.0.6"
hooks:
- id: shellcheck
args: ["--severity=error"]

- repo: local
hooks:
Expand All @@ -107,3 +81,15 @@ repos:
language: pygrep
entry: PyBind|Numpy|Cmake|CCache|Github|PyTest
exclude: .pre-commit-config.yaml

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.15
hooks:
- id: validate-pyproject

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.0
hooks:
- id: check-dependabot
- id: check-github-workflows
- id: check-readthedocs
18 changes: 10 additions & 8 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@
# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.11"
# You can also specify other tool versions:
# nodejs: "20"
# rust: "1.70"
# golang: "1.20"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# Include PDF and ePub
formats: all

python:
version: "3.10"
install:
- method: pip
path: .
extra_requirements:
- docs
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Example:
### xrootd config
```
# ensure cksum adler32 is included in the tpc directive, in order to caclulate by default on transfer
# ensure cksum adler32 is included in the tpc directive, in order to calculate by default on transfer
ofs.tpc cksum adler32 fcreds ?gsi =X509_USER_PROXY autorm xfr 40 pgm /etc/xrootd/xrdcp-tpc.sh

# add this line to trigger external checksum calculation. Would be overwritten by other xrootd.chksum lines
Expand Down
104 changes: 67 additions & 37 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
[build-system]
requires = ["flit_core >=3.4"]
build-backend = "flit_core.buildapi"
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"


[project]
name = "xrdsum"
authors = [
{ name = "Luke Kreczko", email = "kreczko@cern.ch" },
]
maintainers = [
{ name = "The GridPP Collaboration", email = "kreczko@cern.ch" },
]
authors = [{ name = "Luke Kreczko", email = "kreczko@cern.ch" }]
maintainers = [{ name = "The GridPP Collaboration", email = "kreczko@cern.ch" }]
license = { file = "LICENSE" }

description = "Package for retrieving and calculating checksums for XRootD"
Expand Down Expand Up @@ -44,21 +40,15 @@ dependencies = [
]

[project.optional-dependencies]
test = [
"pytest >=6",
]
dev = [
"pytest >=6",
]
test = ["pytest >=6"]
dev = ["pytest >=6"]
docs = [
"Sphinx>=4.0",
"myst_parser>=0.13",
"Sphinx>=7.0",
"myst_parser>=0.13",
"sphinx-book-theme>=0.1.0",
"sphinx_copybutton",
]
hdfs = [
"pyhdfs>=0.3.1",
]
hdfs = ["pyhdfs>=0.3.1"]
# cannot put it on pypi with this.
# we would need to move cephsum to pypi first.
# cephfs = [
Expand All @@ -68,15 +58,25 @@ hdfs = [
[project.urls]
homepage = "https://github.com/BristolComputing/xrdsum"

[tool.hatch]
version.source = "vcs"
build.hooks.vcs.version-file = "src/xrdsum/_version.py"

[tool.hatch.env.default]
features = ["test"]
scripts.test = "pytest {args}"

[tool.hatch.build.targets.wheel]
only-include = ["src/xrdsum", "scripts"]
packages = ["src/xrdsum"]


[tool.pytest.ini_options]
minversion = "6.0"
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
xfail_strict = true
filterwarnings = ["error"]
testpaths = [
"tests",
]
testpaths = ["tests"]


[tool.mypy]
Expand All @@ -101,31 +101,61 @@ strict_equality = true
show_error_codes = true

[[tool.mypy.overrides]]
module = [
"typer.*",
"xrdsum.*",
]
module = ["typer.*", "xrdsum.*"]
implicit_reexport = true

[tool.isort]
profile = "black"
known_third_party = ["typer", "click"]
[[tool.mypy.overrides]]
module = "cephsum.*"
ignore_missing_imports = true

[tool.ruff]
src = ["src"]

[tool.ruff.lint]
extend-select = [
"B", # flake8-bugbear
"I", # isort
"ARG", # flake8-unused-arguments
"C4", # flake8-comprehensions
"EM", # flake8-errmsg
"ICN", # flake8-import-conventions
"G", # flake8-logging-format
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PL", # pylint
"PT", # flake8-pytest-style
"PTH", # flake8-use-pathlib
"RET", # flake8-return
"RUF", # Ruff-specific
"SIM", # flake8-simplify
"T20", # flake8-print
"UP", # pyupgrade
"YTT", # flake8-2020
"EXE", # flake8-executable
"NPY", # NumPy specific rules
"PD", # pandas-vet
]
ignore = [
"PLR", # Design related pylint codes
]
isort.required-imports = ["from __future__ import annotations"]

[tool.ruff.lint.per-file-ignores]
"tests/**" = ["T20"]
"noxfile.py" = ["T20"]


[tool.pylint]
master.py-version = "3.9"
master.ignore-paths= ["src/xrdsum/_version.py"]
master.ignore-paths = ["src/xrdsum/_version.py"]
reports.output-format = "colorized"
similarities.ignore-imports = "yes"
messages_control.disable = [
"design",
"fixme",
"line-too-long",
"wrong-import-position",
"design",
"fixme",
"line-too-long",
"wrong-import-position",
]

[project.scripts]
xrdsum = "xrdsum.cli:main"

[tool.flit.external-data]
directory = "scripts"
17 changes: 11 additions & 6 deletions scripts/etc/xrootd/xrdcp-tpc.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
#!/bin/sh
#!/bin/bash

# from https://github.com/snafus/cephsum/blob/master/scripts/xrdcp-tpc.sh
#Original code
#/usr/bin/xrdcp --server -f $1 root://$XRDXROOTD_PROXY/$2

# Get the last two variables as SRC and DST, all others are assumed as additional arguments
OTHERARGS="${@:1:$#-2}"
DSTFILE="${@:$#:1}"
SRCFILE="${@:$#-1:1}"
# Collect all arguments except for the last two
OTHERARGS=("${@:1:$#-2}")

# Get the second-to-last argument
DSTFILE="${*: -2:1}"

/usr/bin/xrdcp $OTHERARGS --server -f $SRCFILE root://$XRDXROOTD_PROXY/$DSTFILE
# Get the last argument
SRCFILE="${*: -1}"

# Use the arguments in the xrdcp command
# Note: We use "${OTHERARGS[@]}" to correctly handle spaces in arguments
/usr/bin/xrdcp "${OTHERARGS[@]}" --server -f "$SRCFILE" "root://$XRDXROOTD_PROXY/$DSTFILE"
2 changes: 1 addition & 1 deletion src/xrdsum/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

from __future__ import annotations

__version__ = "2023.12.1"
from ._version import version as __version__

__all__ = ("__version__",)
4 changes: 4 additions & 0 deletions src/xrdsum/_version.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from __future__ import annotations

version: str
version_tuple: tuple[int, int, int] | tuple[int, int, int, str, str]
5 changes: 2 additions & 3 deletions src/xrdsum/backends/_cephfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@ class CephSettings:

def get_ceph_client(settings: CephSettings) -> Any:
"""Retrieving the CephFS client to execute operations on CephFS."""
import cephsum # pylint: disable=import-error
import cephsum # pylint: disable=import-error # type: ignore-imports

client = cephsum.cephtools.cluster_connect(
return cephsum.cephtools.cluster_connect(
conffile=settings.config_file,
keyring=settings.keyring,
name=settings.user,
)
return client


class CephFSBackend(XrdsumBackend):
Expand Down
Loading

0 comments on commit eafb9d6

Please sign in to comment.