diff --git a/.github/workflows/_check-pip-compile-sync.yml b/.github/workflows/_check-pip-compile-sync.yml index ebcf27d..e58e4ef 100644 --- a/.github/workflows/_check-pip-compile-sync.yml +++ b/.github/workflows/_check-pip-compile-sync.yml @@ -19,7 +19,4 @@ jobs: - uses: actions/checkout@v4 - uses: deargen/workflows/actions/check-pip-compile@master with: - cwd: python-projector - pyproject-toml-file: pyproject.toml - requirements-in-dir: deps - requirements-out-dir: deps/lock + project-dir: python-projector diff --git a/.github/workflows/_deploy.yml b/.github/workflows/_deploy.yml index 45f9a83..3d0ec1c 100644 --- a/.github/workflows/_deploy.yml +++ b/.github/workflows/_deploy.yml @@ -35,5 +35,6 @@ jobs: - uses: deargen/workflows/actions/setup-python-and-uv@master - name: Build and upload to PyPI run: | + cd python-projector uv build --sdist uv publish diff --git a/README.md b/README.md index cd4ac0f..31f64a3 100644 --- a/README.md +++ b/README.md @@ -23,17 +23,17 @@ jobs: uses: deargen/workflows/.github/workflows/check-ruff.yml@master with: check-type: format - ruff-version-file: deps/lock/x86_64-manylinux_2_28/requirements_dev.txt + # ruff-version-file: deps/lock/x86_64-manylinux_2_28/requirements_dev.txt ruff-isort: uses: deargen/workflows/.github/workflows/check-ruff.yml@master with: check-type: isort - ruff-version-file: deps/lock/x86_64-manylinux_2_28/requirements_dev.txt + # ruff-version-file: deps/lock/x86_64-manylinux_2_28/requirements_dev.txt ruff-lint: uses: deargen/workflows/.github/workflows/check-ruff.yml@master with: check-type: lint - ruff-version-file: deps/lock/x86_64-manylinux_2_28/requirements_dev.txt + # ruff-version-file: deps/lock/x86_64-manylinux_2_28/requirements_dev.txt ``` ### Style checking for changed files only @@ -52,17 +52,17 @@ jobs: uses: deargen/workflows/.github/workflows/check-ruff-only-changed.yml@master with: check-type: format - ruff-version-file: deps/lock/x86_64-manylinux_2_28/requirements_dev.txt + # ruff-version-file: deps/lock/x86_64-manylinux_2_28/requirements_dev.txt ruff-isort-on-changes: uses: deargen/workflows/.github/workflows/check-ruff-only-changed.yml@master with: check-type: isort - ruff-version-file: deps/lock/x86_64-manylinux_2_28/requirements_dev.txt + # ruff-version-file: deps/lock/x86_64-manylinux_2_28/requirements_dev.txt ruff-lint-on-changes: uses: deargen/workflows/.github/workflows/check-ruff-only-changed.yml@master with: check-type: lint - ruff-version-file: deps/lock/x86_64-manylinux_2_28/requirements_dev.txt + # ruff-version-file: deps/lock/x86_64-manylinux_2_28/requirements_dev.txt ``` @@ -87,7 +87,7 @@ jobs: with: ruff-select: ${{ github.event.inputs.ruff-select }} ruff-ignore: ${{ github.event.inputs.ruff-ignore }} - ruff-version-file: deps/lock/x86_64-manylinux_2_28/requirements_dev.txt + # ruff-version-file: deps/lock/x86_64-manylinux_2_28/requirements_dev.txt ``` ## Cargo clippy and fmt checking for Rust projects @@ -117,6 +117,8 @@ jobs: ## Compiling requirements.txt (generate locked versions) +This uses `projector pip-compile` command thus requires configuring `pyproject.toml` file accordingly. See [python-projector](python-projector) for more information. + ### Check uv pip compile ```yaml @@ -135,11 +137,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: deargen/workflows/actions/check-pip-compile@master - with: - pyproject-toml-file: pyproject.toml - requirements-in-dir: deps - requirements-out-dir: deps/lock - python-platforms: x86_64-manylinux_2_28,aarch64-apple-darwin,x86_64-apple-darwin ``` ### Apply uv pip compile @@ -156,11 +153,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: deargen/workflows/actions/apply-pip-compile@master - with: - pyproject-toml-file: pyproject.toml - requirements-in-dir: deps - requirements-out-dir: deps/lock - python-platforms: x86_64-manylinux_2_28,aarch64-apple-darwin,x86_64-apple-darwin ``` ## mkdocs build diff --git a/actions/apply-pip-compile/action.yml b/actions/apply-pip-compile/action.yml index e58180a..e5569ff 100644 --- a/actions/apply-pip-compile/action.yml +++ b/actions/apply-pip-compile/action.yml @@ -3,36 +3,50 @@ description: Freeze dependencies using uv pip compile author: Kiyoon Kim inputs: + project-dir: + description: Directory to search pyproject.toml. Default is the root directory. + required: false pyproject-toml-file: description: Path to pyproject.toml file for getting the minimum python version - required: true - default: pyproject.toml + required: false + deprecationMessage: Use project-dir instead. It will read the pyproject.toml file in the directory. requirements-in-dir: description: Directory to search all requirements*.in files - required: true - default: deps + required: false + deprecationMessage: Use project-dir instead. It will read the configuration in pyproject.toml. requirements-out-dir: description: Directory to save compiled requirements*.txt files - required: true - default: deps/lock + required: false + deprecationMessage: Use project-dir instead. It will read the configuration in pyproject.toml. python-platforms: description: Platforms to support (comma-separated) - required: true - default: x86_64-manylinux_2_28,aarch64-apple-darwin,x86_64-apple-darwin,x86_64-pc-windows-msvc - cwd: - description: 'The directory to run uv (and the whole script) in' required: false + deprecationMessage: Use project-dir instead. It will read the configuration in pyproject.toml. runs: using: 'composite' steps: - - shell: bash + - name: Check deprecated inputs + shell: bash run: | - if [[ -n "${{ inputs.cwd }}" ]]; then - cd "${{ inputs.cwd }}" + if [[ -n "${{ inputs.pyproject-toml-file }}" ]]; then + echo "The input 'pyproject-toml-file' is deprecated." >> "$GITHUB_STEP_SUMMARY" fi - echo "min_python_version=$(python3 ${{ github.action_path }}/../../scripts/get_min_python_version.py "${{ inputs.pyproject-toml-file }}")" >> "$GITHUB_OUTPUT" - pip3 install uv --break-system-packages + if [[ -n "${{ inputs.requirements-in-dir }}" ]]; then + echo "The input 'requirements-in-dir' is deprecated." >> "$GITHUB_STEP_SUMMARY" + fi + if [[ -n "${{ inputs.requirements-out-dir }}" ]]; then + echo "The input 'requirements-out-dir' is deprecated." >> "$GITHUB_STEP_SUMMARY" + fi + if [[ -n "${{ inputs.python-platforms }}" ]]; then + echo "The input 'python-platforms' is deprecated." >> "$GITHUB_STEP_SUMMARY" + fi + - name: Install uv + uses: astral-sh/setup-uv@v4 + - shell: bash + run: | + uv tool install ${{ github.action_path }}/../../python-projector + echo "min_python_version=$(projector get-min-python-version ${{ inputs.project-dir }})" >> "$GITHUB_OUTPUT" id: get-python-version - name: Set up Python uses: actions/setup-python@v5 @@ -42,14 +56,18 @@ runs: name: Run uv pip compile and push run: | # set +e # Do not exit shell on failure - if [[ -n "${{ inputs.cwd }}" ]]; then - cd "${{ inputs.cwd }}" + if [[ -n "${{ inputs.project-dir }}" ]]; then + projector pip-compile ${{ inputs.project-dir }} + elif [[ -z "${{ inputs.requirements-in-dir }}" ]]; then + projector pip-compile + else + # deprecated inputs + bash ${{ github.action_path }}/../../scripts/compile_requirements.sh \ + "${{ inputs.requirements-in-dir }}" \ + "${{ inputs.requirements-out-dir }}" \ + "${{ steps.get-python-version.outputs.min_python_version }}" \ + "${{ inputs.python-platforms }}" fi - bash ${{ github.action_path }}/../../scripts/compile_requirements.sh \ - "${{ inputs.requirements-in-dir }}" \ - "${{ inputs.requirements-out-dir }}" \ - "${{ steps.get-python-version.outputs.min_python_version }}" \ - "${{ inputs.python-platforms }}" git config user.name github-actions[bot] git config user.email github-actions[bot]@users.noreply.github.com git add . diff --git a/actions/check-pip-compile/action.yml b/actions/check-pip-compile/action.yml index 505fa4e..c048573 100644 --- a/actions/check-pip-compile/action.yml +++ b/actions/check-pip-compile/action.yml @@ -3,36 +3,50 @@ description: Detect changes in requirements*.in files that are not compiled yet author: Kiyoon Kim inputs: + project-dir: + description: Directory to search pyproject.toml. Default is the root directory. + required: false pyproject-toml-file: description: Path to pyproject.toml file for getting the minimum python version - required: true - default: pyproject.toml + required: false + deprecationMessage: Use project-dir instead. It will read the pyproject.toml file in the directory. requirements-in-dir: description: Directory to search all requirements*.in files - required: true - default: deps + required: false + deprecationMessage: Use project-dir instead. It will read the configuration in pyproject.toml. requirements-out-dir: description: Directory to save compiled requirements*.txt files - required: true - default: deps/lock + required: false + deprecationMessage: Use project-dir instead. It will read the configuration in pyproject.toml. python-platforms: description: Platforms to support (comma-separated) - required: true - default: x86_64-manylinux_2_28,aarch64-apple-darwin,x86_64-apple-darwin,x86_64-pc-windows-msvc - cwd: - description: 'The directory to run uv (and the whole script) in' required: false + deprecationMessage: Use project-dir instead. It will read the configuration in pyproject.toml. runs: using: 'composite' steps: - - shell: bash + - name: Check deprecated inputs + shell: bash run: | - if [[ -n "${{ inputs.cwd }}" ]]; then - cd "${{ inputs.cwd }}" + if [[ -n "${{ inputs.pyproject-toml-file }}" ]]; then + echo "The input 'pyproject-toml-file' is deprecated." >> "$GITHUB_STEP_SUMMARY" + fi + if [[ -n "${{ inputs.requirements-in-dir }}" ]]; then + echo "The input 'requirements-in-dir' is deprecated." >> "$GITHUB_STEP_SUMMARY" fi - echo "min_python_version=$(python3 ${{ github.action_path }}/../../scripts/get_min_python_version.py "${{ inputs.pyproject-toml-file }}")" >> "$GITHUB_OUTPUT" - pip3 install uv --break-system-packages + if [[ -n "${{ inputs.requirements-out-dir }}" ]]; then + echo "The input 'requirements-out-dir' is deprecated." >> "$GITHUB_STEP_SUMMARY" + fi + if [[ -n "${{ inputs.python-platforms }}" ]]; then + echo "The input 'python-platforms' is deprecated." >> "$GITHUB_STEP_SUMMARY" + fi + - name: Install uv + uses: astral-sh/setup-uv@v4 + - shell: bash + run: | + uv tool install ${{ github.action_path }}/../../python-projector + echo "min_python_version=$(projector get-min-python-version ${{ inputs.project-dir }})" >> "$GITHUB_OUTPUT" id: get-python-version - name: Set up Python uses: actions/setup-python@v5 @@ -43,15 +57,18 @@ runs: run: | set +e # Do not exit shell on failure - if [[ -n "${{ inputs.cwd }}" ]]; then - cd "${{ inputs.cwd }}" + if [[ -n "${{ inputs.project-dir }}" ]]; then + out=$(projector pip-compile ${{ inputs.project-dir }} 2> _stderr.txt) + elif [[ -z "${{ inputs.requirements-in-dir }}" ]]; then + out=$(projector pip-compile 2> _stderr.txt) + else + # deprecated inputs + out=$(bash ${{ github.action_path }}/../../scripts/compile_requirements.sh \ + "${{ inputs.requirements-in-dir }}" \ + "${{ inputs.requirements-out-dir }}" \ + "${{ steps.get-python-version.outputs.min_python_version }}" \ + "${{ inputs.python-platforms }}" 2> _stderr.txt) fi - - out=$(bash ${{ github.action_path }}/../../scripts/compile_requirements.sh \ - "${{ inputs.requirements-in-dir }}" \ - "${{ inputs.requirements-out-dir }}" \ - "${{ steps.get-python-version.outputs.min_python_version }}" \ - "${{ inputs.python-platforms }}" 2> _stderr.txt) exit_code=$? err=$(<_stderr.txt) diff --git a/python-projector/pyproject.toml b/python-projector/pyproject.toml index 63fede7..2683b1d 100644 --- a/python-projector/pyproject.toml +++ b/python-projector/pyproject.toml @@ -19,11 +19,13 @@ authors = [ ] readme = "README.md" license = { file = "LICENSE" } -requires-python = ">=3.13,<4" +requires-python = ">=3.11,<4" classifiers = [ "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python", "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "License :: OSI Approved :: Apache Software License", ] @@ -42,7 +44,7 @@ license-files = [] dependencies = {file = ["deps/requirements.in"]} [tool.setuptools.package-data] -python_projector = ["template.env"] # CHANGE (name of the importing module name) +python_projector = ["shell/*.sh"] # CHANGE (name of the importing module name) [tool.setuptools.packages.find] where = ["src"] @@ -72,7 +74,7 @@ typeCheckingMode = "standard" useLibraryCodeForTypes = true autoImportCompletions = true -pythonVersion = "3.13" +pythonVersion = "3.11" # pythonPlatform = "Linux" reportDuplicateImport = true diff --git a/python-projector/src/python_projector/cli/main.py b/python-projector/src/python_projector/cli/main.py index e000db0..f783da0 100644 --- a/python-projector/src/python_projector/cli/main.py +++ b/python-projector/src/python_projector/cli/main.py @@ -7,10 +7,7 @@ from pathlib import Path from typing import Annotated -import rich import typer -from rich.prompt import Prompt -from rich.syntax import Syntax app = typer.Typer( no_args_is_help=True, context_settings={"help_option_names": ["-h", "--help"]}