Skip to content

Commit

Permalink
Merge pull request #3 from wwPDB/hatch
Browse files Browse the repository at this point in the history
Convert to using hatch for build tool
  • Loading branch information
epeisach authored Mar 2, 2025
2 parents ff09239 + aea2bf4 commit 6df7e1b
Show file tree
Hide file tree
Showing 196 changed files with 1,319 additions and 1,048 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "wwpdb/mock-data"]
path = wwpdb/mock-data
url = ../py-onedep_mock_data.git
2 changes: 2 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:
parameters: {tox: 'lint_pylint', python: '3.10', os: 'linux'}
- template: azure-template-tox-job.yml
parameters: {tox: 'test_coverage', python: '3.10', os: 'linux'}
- template: azure-template-tox-job.yml
parameters: {tox: 'mypy', python: '3.10', os: 'linux'}
#
- template: azure-template-tox-job.yml
parameters: {tox: 'py310', python: '3.10', os: 'linux'}
Expand Down
9 changes: 1 addition & 8 deletions azure-template-publish-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ jobs:
- download: current
artifact: ${{ format('sw_{0}_{1}', parameters.tox, parameters.os) }}

- download: current
artifact: ${{ format('sw_u_{0}_{1}', parameters.tox, parameters.os) }}
#
- script: ls -lR $(Pipeline.Workspace)/${{ format('sw_{0}_{1}', parameters.tox, parameters.os) }}
displayName: "Listing of downloaded artifacts"
Expand All @@ -57,11 +55,6 @@ jobs:
secureFile: 'PYPIRC-AZURE'

- ${{ if startsWith(parameters.os, 'linux') }}:
- script: twine upload --verbose --skip-existing -r pypi --config-file $(pypicred.secureFilePath) $(Pipeline.Workspace)/${{ format('sw_u_{0}_{1}', parameters.tox, parameters.os) }}/*
displayName: "Linux upload sdist and source wheel to PyPi ..."
continueOnError: true
#
- ${{ if startsWith(parameters.os, 'macos') }}:
- script: twine upload --verbose --skip-existing -r pypi --config-file $(pypicred.secureFilePath) $(Pipeline.Workspace)/${{ format('sw_{0}_{1}', parameters.tox, parameters.os) }}/*
displayName: "Mac upload sdist and binary wheel to PyPi ..."
displayName: "Linux upload sdist and source wheel to PyPi ..."
continueOnError: true
16 changes: 4 additions & 12 deletions azure-template-tox-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,23 +182,15 @@ jobs:
# Build artifacts if this is a test target (i.e. labeled as py##)
#
- ${{ if startsWith(parameters.tox, 'py') }}:
- script: pip install --upgrade pip twine setuptools wheel
- script: pip install --upgrade pip twine build wheel
displayName: "Acquire build tools"
- script: python setup.py sdist --dist-dir "$(System.DefaultWorkingDirectory)/dist"
displayName: "Build source dist"
- script: python setup.py bdist_wheel --dist-dir "$(System.DefaultWorkingDirectory)/dist"
displayName: "Build wheel"
#
- script: python setup.py sdist --dist-dir "$(System.DefaultWorkingDirectory)/udist"
displayName: "Build source dist"
- script: python -m build --outdir "$(System.DefaultWorkingDirectory)/dist"
displayName: "Build source distributions"
#
# Check the install artifacts
- script: ls -lR "$(System.DefaultWorkingDirectory)/dist" "$(System.DefaultWorkingDirectory)/udist"
- script: ls -lR "$(System.DefaultWorkingDirectory)/dist"
displayName: "Listing of installed software"
#
- publish: $(System.DefaultWorkingDirectory)/dist
artifact: ${{ format('sw_{0}_{1}', parameters.tox, parameters.os) }}
#
- publish: $(System.DefaultWorkingDirectory)/udist
artifact: ${{ format('sw_u_{0}_{1}', parameters.tox, parameters.os) }}
#
174 changes: 174 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "wwpdb.utils.oe-util"
dynamic = ["version"]
description = "wwPDB workflow engine utils"
readme = "README.md"
license = "Apache-2.0"
authors = [
{ name = "Ezra Peisach", email = "[email protected]" },
]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Natural Language :: English",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
]
dependencies = [
"mmcif.utils",
"OpenEye-toolkits ; python_version >= '3'",
"OpenEye-toolkits-python2.7-ucs2-linux-x64 == 2016.6.1; python_version == '2.7' and sys_platform=='linux2'",
"wwpdb.utils.cc_dict_util >= 0.2",
]

requires-python = ">=3.6"

# https://hatch.pypa.io/latest/how-to/environment/dependency-resolution/
[project.optional-dependencies]
dev = [
"check-manifest",
]
test = [
"coverage",
]

[project.scripts]

[project.urls]
Homepage = "https://github.com/rcsb/py-wwpdb_apps_wf_engine_utils"

[tool.hatch.version]
path = "wwpdb/utils/oe_util/__init__.py"

[tool.hatch.build.targets.sdist]
include = [
"/wwpdb",
]

exclude = ["/wwpdb/mock-data", "/wwpdb/utils/oe_util/Archive"]

[tool.hatch.build.targets.wheel]
packages = ["wwpdb"]

exclude = ["/wwpdb/mock-data", "/wwpdb/utils/oe_util/Archive"]

#=================================== Ruff basics =============================#
[tool.ruff]

line-length = 120 # 120 is hatch's default via 'hatch init'
include = [
"*.py", # Source
"pyproject.toml", # This file (RUF rules only)
"*.ipynb", # Jupyter notebooks
]

exclude = ["Archive"]

#
#=================================== Ruff lint ==============================#

[tool.ruff.lint]

#
# ------------------------- Ruff misc. options ----------------------
preview = true
explicit-preview-rules = true

ignore = [
"C402", # Unnecessary generator (rewrite as a `dict` comprehension)
"EXE001", # Shebang is present but file is not executabl
"FBT002", # Boolean default positional argument in function definition
"FBT001", # Boolean-typed positional argument in function definition
"FURB113", # Use `stPL.extend(...)` instead of repeatedly calling `stPL.append()`
"INP001", # File `xx` is part of an implicit namespace package. Add an `__init__.py
"N801", # Class name `markdownTests` should use CapWords convention
"N802", # Function name should be lowercase
"N803", # Argument name should be lowercase
"N806", # in function should be lowercase
"N815", # Caiable... in class shope should not be mixedCase
"N816", # Variable in global scope should not be mixedCase
"N999", # Invalid module name,
"PERF401", # Use a list comprehension to create a transformed list
"PERF403", # Use a dictionary comprehension instead of a for-loop
"PLR1714", # Consider merging multiple comparisons
"PLR2004", # Magic value used in comparison, consider replacing
"PLR6201", # Use a `set` literal when testing for membership
"PLR6301", # Method `` could be a function, class method, or static method
"PLW1514", # `open` in text mode without explicit `encoding` argument
"PT009", # Use a regular `assert` instead of unittest-style `assertGreater`
"RET504", # Unnecessary assignment to `X` before `return` statement
"RUF100", # RUF REMOVES FLAKE8 noqa!
"S110", # `try`-`except`-`pass` detected, consider logging the exception
"SIM102", # Use a single `if` statement instead of nested `if` statements
"SIM103", # Return the condition directly
"SIM108", # Use ternary operator
"SIM115", # Use context handler for opening files
"TRY300", # Consider moving this statement to an `else` block
"TRY400", # Use `logging.exception` instead of `logging.error`
"TRY401", # Redundant exception object included in `logging.exception` call
"UP008", # Use `super()` instead of `super(__class__, self)`
"UP031" # Use format specifiers instead of percent format
]

# -------------------- default environment scripts ------------------
[tool.hatch.envs.default]
skip-install = true
dependencies = ["mypy", "ruff >=0.6.9", "wwpdb.utils.testing", "OpenEye-toolkits~=2022.1.1"]

[tool.hatch.envs.default.env-vars]
PIP_EXTRA_INDEX_URL = "https://pypi.anaconda.org/OpenEye/simple"


[tool.hatch.envs.default.scripts]

# 'format' formats and fixes issues but does not complain
format = [
"ruff format",
"ruff check --fix-only",
]

# 'format-python' just excludes Prettier
format-python = ["ruff format", "ruff check --fix-only"]

# 'check' only checks but never fixes
check = ["ruff check --no-fix .", "mypy --non-interactive --install-types -p wwpdb -p tests"]

# only checks with ruff (mypy has a lot of false positives)
check-ruff = "ruff check --no-fix . {args}"

# to complement 'check-ruff'
check-mypy = "mypy --non-interactive --install-types wwpdb tests {args}"

# only check security via Bandit; we require these rules to pass
check-security = "ruff check --select S --no-fix ."

# ----------------------- testing environment ----------------
[tool.hatch.envs.hatch-test]
dependencies = ["tox"]

[tool.hatch.envs.hatch-test.scripts]
run = ["tox"]


# ------------------------- Mypy disable ---------
[[tool.mypy.overrides]]
module = ["wwpdb.*", "openeye.*", "mmcif_utils.*", "mmcif.*"]
ignore_missing_imports = true

[tool.mypy]
exclude = [
"test-output",
]

# ------------------------ ruff disable until typing added
[tool.ruff.lint.per-file-ignores]
"awwpdb/utils/config/ConfigInfoData.py" = ["RUF012"] # typing.ClassVar
"wwpdb/utils/config/ConfigInfoData.py" = ["SLF001", "RUF012", "F401"] # Private member access, should use typing.ClassVar, do not remove unused imports

7 changes: 0 additions & 7 deletions setup.cfg

This file was deleted.

75 changes: 0 additions & 75 deletions setup.py

This file was deleted.

File renamed without changes.
Loading

0 comments on commit 6df7e1b

Please sign in to comment.