Skip to content

Commit

Permalink
Add py312 support to template and drop pdm testing
Browse files Browse the repository at this point in the history
pdm cannot resolve different dependency versions for different python
versions, and there is no numpy version that can be simultaneously
resolved both to python 3.8 and python 3.12. So the only way to use
support pdm would be to raise the lower limit of our template app, or
have special pdm support.

Users can still use pdm if they wish, but they'll have to work out the
consequences themselves. pdm is removed from printed instructions and
testing
  • Loading branch information
pvandyken committed Jan 11, 2024
1 parent be03774 commit 9954f06
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 74 deletions.
80 changes: 37 additions & 43 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ style = "pep440"
bump = true

[tool.poetry-dynamic-versioning.substitution]
files = [
'snakebids/__init__.py',
]
files = ['snakebids/__init__.py']
patterns = [
"(^\\s+\"snakebids_version\":\\s*\")[^'\"]*(\")",
"(^__version__\\s*(?::.*?)?=\\s*['\"])[^'\"]*(['\"])",
Expand Down Expand Up @@ -66,7 +64,6 @@ scipy = [
pandas = [
{ version = "<=2.0.3", python = "<3.9" },
{ version = ">=2.1.1", python = ">=3.12" },

]
# minimum 8.2.0 to use post-copy mesages
copier = ">=8.2.0"
Expand Down Expand Up @@ -132,8 +129,8 @@ expr = "platform.python_version()"
args = [{ name = "container_id", positional = true, required = true }]
uses = { VERSION = "_get_version" }
cmd = """
docker build 'containers/${container_id}' \
--tag 'snakebids/${container_id}:${VERSION}' \
docker build "containers/${container_id}" \
--tag "snakebids/${container_id}:${VERSION}" \
--build-arg="PYTHON_VERSION=${VERSION}"
"""

Expand All @@ -143,18 +140,15 @@ markers = [
]

[tool.coverage.run]
omit = [
"snakebids/project_template/**",
"snakebids/tests/**",
]
omit = ["snakebids/project_template/**", "snakebids/tests/**"]

[tool.coverage.report]
exclude_lines = [
"pragma: not covered",
"@overload",
'class [a-zA-Z0-9_]+\([^)]*Protocol.*\)',
'if TYPE_CHECKING',
"def __dir__"
"def __dir__",
]

[tool.isort]
Expand All @@ -170,31 +164,31 @@ reportImportCycles = false

[tool.ruff]
select = [
"E", # pycodestyle error
"W", # pycodestyle warning
"F", # pyflakes
"N", # pep8-naming
"UP", # pyupgrade
"YTT", # flake8-2020
"S", # flake8-bandit
"BLE", # flake8-blind-except
"B", # flake8-bugbear
"A", # flake8-builtins
"COM", # flake8-commas
"C4", # flake8-comprehensions
"T10", # flake8-debugger
"EM", # flake8-errmsg
"FA", # flake8-future-annotations
"ISC", # flake8-implicit-str-concat
"ICN", # flake8-import-conventions
"G", # flake8-logging-format
"INP", # flake8-no-pep420
"PIE", # flake8-pie
"PT", # flake8-pytest-style
"RSE", # flake8-raise
"RET", # flake8-return
"SLF", # flake8-self
"SIM", # flake8-simplify
"E", # pycodestyle error
"W", # pycodestyle warning
"F", # pyflakes
"N", # pep8-naming
"UP", # pyupgrade
"YTT", # flake8-2020
"S", # flake8-bandit
"BLE", # flake8-blind-except
"B", # flake8-bugbear
"A", # flake8-builtins
"COM", # flake8-commas
"C4", # flake8-comprehensions
"T10", # flake8-debugger
"EM", # flake8-errmsg
"FA", # flake8-future-annotations
"ISC", # flake8-implicit-str-concat
"ICN", # flake8-import-conventions
"G", # flake8-logging-format
"INP", # flake8-no-pep420
"PIE", # flake8-pie
"PT", # flake8-pytest-style
"RSE", # flake8-raise
"RET", # flake8-return
"SLF", # flake8-self
"SIM", # flake8-simplify
# We use os.path a lot in "legitimate" ways, so this ruleset has too many
# false positives
# "PTH", # flake8-use-pathlib
Expand All @@ -210,11 +204,11 @@ select = [
]
ignore = [
"PLR0913",
"D105", # missing docstring in magic method
"D100", # Require docstring in public modules
"D104", # Require docstring in public packages
"S603", # Subprocess without shell equals true
"S607", # start-process-with-partial-path
"D105", # missing docstring in magic method
"D100", # Require docstring in public modules
"D104", # Require docstring in public packages
"S603", # Subprocess without shell equals true
"S607", # start-process-with-partial-path
# recommended ignores for ruff format
"W191",
"E111",
Expand All @@ -241,8 +235,8 @@ namespace-packages = ["snakebids/plugins"]
"snakebids/project_template/**" = ["N999"]
"snakebids/tests/**" = [
"D",
"S101", # assert
"S307", # Use of eval
"S101", # assert
"S307", # Use of eval
"SLF",
]

Expand Down
38 changes: 12 additions & 26 deletions snakebids/project_template/copier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ bids_version:
when: false

python_version:
default: ">=3.8,<3.12"
default: ">=3.8,<3.13"
when: false

snakebids_version:
Expand Down Expand Up @@ -96,27 +96,16 @@ _message_after_copy: >
$ cd {{ _copier_conf.dst_path }}
{% if build_system == "poetry" -%}
{{ Fore.BLUE }}2.{{ Fore.RESET }} Install dependencies.
{% if build_system == "poetry" %}
$ poetry install
{%- else -%}
{{ Fore.BLUE + "2." + Fore.RESET + """ Install dependencies. This may vary
depending on your tooling. The following are examples (the first example
should work on any python environment; the others require 3rd party tools):
""" | wordwrap(80)}}
* {{Fore.YELLOW}}Virtual Environment and setuptools:{{Fore.RESET}}
$ python -m venv .venv
$ source .venv/bin/activate
$ pip install .
* {{Fore.YELLOW}}Hatch:{{Fore.RESET}}
$ hatch env create
* {{Fore.YELLOW}}PDM:{{Fore.RESET}}
$ pdm install
{%- elif build_system == "hatch" %}
$ hatch env create
{%- else %}
$ python -m venv .venv
$ source .venv/bin/activate
$ pip install .
{%- endif %}
Expand All @@ -125,15 +114,12 @@ _message_after_copy: >
{% if build_system == "poetry" %}
$ poetry run {{ test_run_cmd }}
{%- else %}
* {{Fore.YELLOW}}Virtual Environment and setuptools:{{Fore.RESET}}
$ {{ test_run_cmd }}
{%- elif build_system == "hatch" %}
$ hatch env run -- {{ test_run_cmd }}
* {{Fore.YELLOW}}Hatch:{{Fore.RESET}}
$ hatch env run -- {{ test_run_cmd }}
{%- else %}
$ {{ test_run_cmd }}
* {{Fore.YELLOW}}PDM:{{Fore.RESET}}
$ pdm run {{ test_run_cmd }}
{%- endif %}
_jinja_extensions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ requires-python = "{{ python_version }}"
dependencies = [
"snakemake >= {{ snakemake_version }},<8",
"snakebids >= {{ snakebids_version }}",
{# Explicitly specify numpy version for py38 until snakebids 0.10.x to
work around specification bug causing numpys too high for py38 to be
locked by pdm -#}
"numpy <=1.24.4; python_version < \"3.9\"",
]

[project.scripts]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ classifiers = [
python = "{{ python_version }}"
snakemake = ">={{ snakemake_version }},<8"
snakebids = ">={{ snakebids_version }}"
pandas = [
{ version = "<=2.0.3", python = "<3.9" },
{ version = ">=2.1.1", python = ">=3.12" },
]

[tool.poetry.scripts]
{{ name_slug }} = "{{ name_slug }}.run:main"
Expand Down
2 changes: 1 addition & 1 deletion snakebids/tests/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def test_pyproject_correctly_formatted(
("setuptools", "setuptools"),
("poetry", "poetry"),
("hatch", "hatch"),
("flit", "pdm"),
("flit", "setuptools"),
],
)
def test_template_dry_runs_successfully(tmp_path: Path, build: BuildBackend, venv: str):
Expand Down

0 comments on commit 9954f06

Please sign in to comment.