distributable:
  # url format changed in v0.2.1
  url: https://github.com/AntonOsika/gpt-engineer/archive/refs/tags/{{version.tag}}.tar.gz
  strip-components: 1

versions:
  github: AntonOsika/gpt-engineer
  strip: /v\./ # 0.2.4 onwards are tagged as `v.0.2.4` which is not machine parsable as a version

display-name: GPT Engineer

dependencies:
  pkgx.sh: ^1

entrypoint: pkgx ./entrypoint.sh

build:
  dependencies:
    python.org: ~3.11
    python-poetry.org: ^1.7
  script:
    # https://github.com/AntonOsika/gpt-engineer/issues/204
    - run: patch -p1 < props/main.py.patch
      if: =0.0.3

    - run: |
        bkpyvenv stage --engine=poetry {{prefix}} {{version}}
        poetry install
        bkpyvenv seal --engine=poetry {{prefix}} gpte gpt-engineer
      if: '>=0.2.6'

    - run: |
        bkpyvenv stage --engine=poetry {{prefix}} {{version}}
        poetry install --with=experimental
        bkpyvenv seal --engine=poetry {{prefix}} gpte gpt-engineer
      if: '>=0.2.1<0.2.6'

    - run: |
        bkpyvenv stage {{prefix}} {{version}}
        {{prefix}}/venv/bin/pip install .
        bkpyvenv seal {{prefix}} gpte gpt-engineer
      if: '<0.2.1'

    # https://github.com/AntonOsika/gpt-engineer/issues/204
    - run: cp -a identity {{prefix}}
      if: =0.0.3

provides:
  - bin/gpte # only after roughly 0.2.1
  - bin/gpt-engineer

test:
  qa-required: true
  # can’t easily do more without an Open AI key
  script:
    - gpte --help
    - gpt-engineer --help
