diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5fe9e3a..402b2ef 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: trailing-whitespace args: [--markdown-linebreak-ext=md] @@ -8,7 +8,7 @@ repos: - id: check-yaml # ----- Python formatting ----- - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.3.4 + rev: v0.4.2 hooks: # Run ruff linter. - id: ruff @@ -19,12 +19,12 @@ repos: - id: ruff-format # ----- repo maintenance ----- - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks - rev: v2.12.0 + rev: v2.13.0 hooks: - id: pretty-format-yaml args: [--autofix, --indent, '2'] - repo: https://github.com/tox-dev/pyproject-fmt - rev: 1.7.0 + rev: 1.8.0 hooks: - id: pyproject-fmt - repo: https://github.com/abravalheri/validate-pyproject diff --git a/action.yml b/action.yml index 8b5b485..ac0d34c 100644 --- a/action.yml +++ b/action.yml @@ -41,7 +41,7 @@ runs: steps: - name: create environment file run: > - pip3 install tomli packaging pyyaml && + pip3 install tomli packaging pyyaml $PIP_OPTIONS && python3 $GITHUB_ACTION_PATH/pydeps2env/generate_environment.py ${{ inputs.files }} --output ${{ inputs.output }} --channels ${{ inputs.channels }} @@ -49,6 +49,8 @@ runs: --build_system ${{ inputs.build_system }} --pip ${{ inputs.pip }} shell: bash + env: + PIP_OPTIONS: ${{ runner.os == 'macOS' && '--break-system-packages' || '' }} - name: show environment file run: cat ${{ inputs.output }} shell: bash diff --git a/pydeps2env/environment.py b/pydeps2env/environment.py index bdee184..5b59460 100644 --- a/pydeps2env/environment.py +++ b/pydeps2env/environment.py @@ -5,12 +5,21 @@ from pathlib import Path from collections import defaultdict import configparser -import tomli as tomllib +import sys import yaml -import warnings from io import StringIO, BytesIO from warnings import warn +if sys.version_info < (3, 11): + import tomli as tomllib +else: + import tomllib + + +def clean_list(item: list, sort: bool = True) -> list: + """Remove duplicate entries from a list.""" + pass + def split_extras(filename: str) -> tuple[str, set]: """Split extras requirements indicated in [].""" @@ -264,7 +273,7 @@ def export( outfile.writelines("\n".join(deps)) else: if p.suffix not in [".yaml", ".yml"]: - warnings.warn( + warn( f"Unknown environment format `{p.suffix}`, generating conda yaml output." ) with open(p, "w") as outfile: diff --git a/pyproject.toml b/pyproject.toml index 2dc648f..d7aca76 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,7 +31,7 @@ dynamic = [ dependencies = [ "packaging", "pyyaml", - "tomli", + 'tomli; python_version < "3.11"', ] [project.optional-dependencies] test = [