Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update package installation files and development environment #248

Merged
merged 45 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
bb5370f
Included explanation (with source) for why setup() is to be kept as-is.
Apr 4, 2024
16eaa73
Updated 'extras_require' section to include dependency options for cl…
Apr 4, 2024
f6ee2ed
Ported over settings from setup.cfg, allowing pyproject.toml to be us…
Apr 4, 2024
012fe1a
Added entry to search pyproject.toml file for version number and repl…
Apr 4, 2024
3f11daa
Ported flake8 entries from setup.cfg to pyproject.toml for completene…
tieneupin Apr 4, 2024
aa0f43b
Updated repos to latest stable versions (with links to where to find …
tieneupin Apr 4, 2024
6f6eaa5
Added Flake8-pyproject as a Flake8 dependency in the pre-commit-confi…
tieneupin Apr 5, 2024
2d670b8
Merge branch 'main' into setup-update
tieneupin Apr 5, 2024
a207ac8
Additional comments about potentially using Ruff as a long-term bridg…
tieneupin Apr 5, 2024
08b0188
Included link to documentation for .yaml formatting, and explanation …
tieneupin Apr 5, 2024
e600c7c
Addressed potential error identified by mypy: TransportManager could …
tieneupin Apr 5, 2024
59ce6d2
Addressed potential error found by mypy: Module murfey.client.tui has…
tieneupin Apr 5, 2024
ff3440d
Snapshot of environment before testing Ruff with pre-commit.
tieneupin Apr 5, 2024
86d834c
Modified settings to test ruff with.
tieneupin Apr 5, 2024
f47b950
Updated black and ruff settings in pre-commit-config and pyproject.to…
tieneupin Apr 8, 2024
d5e4a08
Reverted pre-commit settings to pre-ruff ones.
tieneupin Apr 8, 2024
2019169
Added key to disable non-error messages for MyPy checks.
tieneupin Apr 8, 2024
4da2677
Merge branch 'main' of github.com:DiamondLightSource/python-murfey in…
tieneupin Apr 8, 2024
6a51ea9
Mutiple files defining MyPy configuration settings. Standardised MyPy…
tieneupin Apr 8, 2024
c619b36
Updated pre-commit settings to install missing library stubs, ignore …
tieneupin Apr 8, 2024
0fa8dfa
Added more pre-commit hooks, improved printed messages.
tieneupin Apr 8, 2024
e56ca73
Install a stomp-py version below the most recent to stop workflows pi…
d-j-hatton Apr 8, 2024
7254b37
Try to avoid CodeQL complaint of mixed implicit and explicit returns …
d-j-hatton Apr 8, 2024
a7166a5
Updated installation requirements. stomp-py 8.1.1 breaks the package.…
tieneupin Apr 8, 2024
1e20821
Fixed type hinting syntax, using Python 3.9-comptable variant.
tieneupin Apr 8, 2024
7f6759c
Phased out setup.cfg now that pyproject.toml has been tested and conf…
tieneupin Apr 8, 2024
b6ef64e
Merged collaborative changes to branch.
tieneupin Apr 8, 2024
c2eab66
Reverted deletion of setup.cfg.
tieneupin Apr 8, 2024
db74639
Need flake8-pyproject for toml support
d-j-hatton Apr 8, 2024
8708441
Remove old setup files
d-j-hatton Apr 8, 2024
1d46b63
setup.py is back
d-j-hatton Apr 8, 2024
f2b8a21
Missing await
d-j-hatton Apr 8, 2024
6744e33
Updated comments to reflect current state of project.
tieneupin Apr 8, 2024
c5f98bd
Removed bump2version's search for setup.cfg, since we have committed …
tieneupin Apr 8, 2024
a68934a
Added pre-commit hook to restructure pyproject.toml file, along with …
tieneupin Apr 8, 2024
26b67a4
Disabled pyproject-fmt pre-commit hook. Formatting was too harsh, and…
tieneupin Apr 9, 2024
055df00
Moved 'werkzeug' to mandatory dependencies list, as it was found in b…
tieneupin Apr 9, 2024
f49eeb9
Re-enabled pyproject-fmt after experimenting with other TOML formatte…
tieneupin Apr 9, 2024
291b057
Merged changes from main branch. Bumped to version 0.11.8
tieneupin Apr 9, 2024
6e12353
Removed setup.cfg that was added after merge.
tieneupin Apr 9, 2024
a9b009b
Snapshot of environment before testing Prettier formatter.
tieneupin Apr 10, 2024
ace3b10
Rearranged order of pre-commit hooks. Tidied up comments and formatting.
tieneupin Apr 10, 2024
5bcb28f
Formatted files using Prettier pre-commit hook.
tieneupin Apr 10, 2024
3f47ff0
Merged recent updates from main branch.
tieneupin Apr 17, 2024
dd2825e
Removed setup.cfg introduced by merge.
tieneupin Apr 17, 2024
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: 4 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ replace = version = {new_version}
[bumpversion:file:src/murfey/__init__.py]
search = __version__ = "{current_version}"
replace = __version__ = "{new_version}"

[bumpversion:file:pyproject.toml]
search = version = "{current_version}"
replace = version = "{new_version}"
58 changes: 42 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# YAML formatting specifications: https://yaml.org/spec/1.2.2/

repos:
# Syntax validation and some basic sanity checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
#rev: v4.0.1
rev: v4.5.0 # Format depends entirely on how version tag is formatted on the repo (with 'v', without it, etc.)
hooks:
- id: check-merge-conflict
- id: check-ast
Expand All @@ -12,9 +15,30 @@ repos:
- id: check-yaml
args: [--allow-multiple-documents]

# Automatically sort imports
# Automatic source code formatting
- repo: https://github.com/psf/black
#rev: 22.3.0
rev: 24.3.0
hooks:
- id: black
args: [--safe, --quiet]

# Ruff for linting and formatting
# Ruff can replace isort and flake8 (https://docs.astral.sh/ruff/linter/)
# - repo: https://github.com/astral-sh/ruff-pre-commit
# rev: v0.3.5
# hooks:
# # Ruff linter
# - id: ruff
# args: [--fix]
# # Ruff formatter
# - id: ruff-format
# types_or: [python]

# # Automatically sort imports
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
#rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
args: [
Expand All @@ -29,24 +53,26 @@ repos:
'--rm', 'from __future__ import with_statement', # -2.6
]

# Automatic source code formatting
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
args: [--safe, --quiet]

# Linting
# # Linting
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
# Release history: https://flake8.pycqa.org/en/latest/release-notes/index.html
#rev: 4.0.1
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies: ['flake8-comprehensions==3.8.0']
# Added Flake8-pyproject plugin for .toml compatibility
# flake8-comprehensions URL: https://github.com/adamchainz/flake8-comprehensions
#additional_dependencies: ['flake8-comprehensions==3.8.0']
additional_dependencies: [
"Flake8-pyproject==1.2.3",
'flake8-comprehensions==3.14.0'
]

# Type checking
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.910
#rev: v0.910
rev: v1.9.0
hooks:
- id: mypy
files: 'src/.*\.py$'
additional_dependencies: [ types-requests ]
files: '(src|tests)/.*\.py$' # Single quote critical due to escape character '\' used in RegEx search string (see YAML - 7.3 Flow Scalar Styles)
additional_dependencies: [types-requests]
255 changes: 255 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,156 @@
requires = ["setuptools >= 40.6.0", "wheel"]
build-backend = "setuptools.build_meta"

# TEP 2024-04-03
[project]
name = "murfey"
authors = []
maintainers = []
description = "Client-Server architecture hauling Cryo-EM data"
readme = "README.md"
requires-python = ">=3.9"
keywords = [""]
license = {file = "LICENSE"}
classifiers = [
"Development Status :: 3 - Alpha",
"Environment :: Console",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dependencies = [
"pydantic",
"requests",
"rich",
]
version = "0.11.5"
#dynamic = ["version"] # Clashes with version variable immediately above

[project.urls]
Bug-Tracker = "https://github.com/DiamondLightSource/python-murfey/issues"
Documentation = "https://github.com/DiamondLightSource/python-murfey"
GitHub = "https://github.com/DiamondLightSource/python-murfey"


# TEP 2024-04-03
[project.optional-dependencies]
client = [
"procrunner",
"textual==0.42.0",
"websocket-client",
"werkzeug",
"xmltodict",
]
server = [
"mysql-connector-python<=8.0.29",
"fastapi>=0.101",
"cryptography",
"importlib_resources; python_version<'3.9'",
"ispyb",
"jinja2",
"packaging",
"numpy",
"sqlmodel",
"pillow",
"prometheus_client",
"uvicorn[standard]",
"werkzeug",
"zocalo",
]
developer = [
"pytest",
"pre-commit",
"bump2version",
]

# TEP 2024-04-03
[project.scripts]
# Where there are "." in the variable name, enclose with inverted commas
murfey = "murfey.client:run"
"murfey.server" = "murfey.server:run"
"murfey.simulate" = "murfey.cli.dummy:run"
"murfey.transfer" = "murfey.cli.transfer:run"
"murfey.db_sql" = "murfey.cli.murfey_db_sql:run"
"murfey.sessions" = "murfey.cli.db_sessions:run"
"murfey.generate_password" = "murfey.cli.generate_db_password:run"
"murfey.generate_key" = "murfey.cli.generate_crypto_key:run"
"murfey.decrypt_password" = "murfey.cli.decrypt_db_password:run"
"murfey.create_db" = "murfey.cli.create_db:run"
"murfey.spa_inject" = "murfey.cli.inject_spa_processing:run"
"murfey.spa_ispyb_entries" = "murfey.cli.spa_ispyb_messages:run"

# TEP 2024-04-03
[tool.setuptools]
package-dir = {"" = "src"}
include-package-data = true
zip-safe = false

# TEP 2024-04-03
#[tool.setuptools.packages]
#find = {} # This option leads to pip searching for stuff in "tests"

# TEP 2024-04-03
[tool.setuptools.packages.find]
where = ["src"]

# TEP 2024-04-03
[tool.setuptools.package-data]
"murfey.client.tui" = ["*.css"]

# TEP 2024-04-04
# Flake8-pyproject allows .toml settings to be read into Flake8
# Flake8-pyproject: https://pypi.org/project/Flake8-pyproject/
[tool.flake8]
select = [
"C4",
"E401",
"E711",
"E712",
"E713",
"E714",
"E721",
"E722",
"E901",
"F401",
"F402",
"F403",
"F405",
"F541",
"F631",
"F632",
"F633",
"F811",
"F812",
"F821",
"F822",
"F841",
"F901",
"W191",
"W291",
"W292",
"W293",
"W602",
"W603",
"W604",
"W605",
"W606",
]
ignore = [
# "E203",
# "E266",
# "E501",
"W503"
]
max-line-length = "88"
# Also worth investigating Ruff's compatibility with Flake8 for use with pyproject.toml
# Suggested by VSCode's auto-fill, so should be pretty popular
# Ruff: https://github.com/astral-sh/ruff

[tool.isort]
profile = "black"

Expand All @@ -10,3 +160,108 @@ addopts = "-ra"

[tool.mypy]
mypy_path = "src"
disable_error_code = "annotation-unchecked" # Disables non-error messages thrown up by mypy

[tool.ruff]
include = [
"pyproject.toml",
"setup.cfg",
"setup.py",
"src/**/*.py",
"tests/**/*.py"
]
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".ipynb_checkpoints",
".mypy_cache",
".nox",
".pants.d",
".pyenv",
".pytest_cache",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
".vscode",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"site-packages",
"venv",
]

# Same as Black.
line-length = 88
indent-width = 4

# Assume Python 3.8
target-version = "py38"

[tool.ruff.lint]
# Currently, not all Flake8 rule coes are implemented in Ruff
# A mix of the two need to be used for the rule codes currently desired
select = [
"C4",
"E401",
"E711",
"E712",
"E713",
"E714",
"E721",
"E722",
# "E901",
"F401",
"F402",
"F403",
"F405",
"F541",
"F631",
"F632",
"F633",
"F811",
# "F812",
"F821",
"F822",
"F841",
"F901",
"W191",
"W291",
"W292",
"W293",
# "W602",
# "W603",
# "W604",
"W605",
# "W606",
]
ignore = [
"E203",
"E266",
"E501",
# "W503"
]

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[tool.ruff.format]
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"
docstring-code-format = false
docstring-code-line-length = "dynamic"
Loading