wagtail / wagtail/wagtail-cli

Delegation resolution when wagtail-cli is installed as a tool?

Open
#4 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
5
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Problem statement

Currently - if I install the wagtail-cli as a tool via

uv tool install wagtail-cli

I think I am not able to use the wt command delegation in my project, because it will find that manage.py is a file, but it will try to execute it with the python from the tools environment, which need not have django installed.

https://github.com/wagtail/wagtail-cli/blob/190d1bee2dad91f79336c3efe68ddbab7f14989d/src/wagtail_cli/cli/main.py#L193-L203

Similarly for wt --help (which runs its own delegation detection)

https://github.com/wagtail/wagtail-cli/blob/190d1bee2dad91f79336c3efe68ddbab7f14989d/src/wagtail_cli/cli/main.py#L227-L237

Proposed solution

Could check whether django is available in the current environment before passing to manage.py or try to execute the manage.py file directly so it can use the python from the files shebang, but maybe that isn't cross-platform?

Alternative solutions

No response

Additional context

No response

Working on this

Contribute to the discussion to help this move forward. Explain your use cases, discuss possible solutions, research how to adapt existing code, or compatibility concerns.

Once others agree with the proposed changes, anyone can contribute to this. View our contributing guidelines. Add a comment to the issue to explain what approach you are taking.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the delegation logic in src/wagtail_cli/cli/main.py at lines 193-203 and 227-237, then reproduce the behavior after installing wagtail-cli with uv tool install. Compare normal delegation with wt --help and determine how the project environment should be selected when manage.py is present. Done means delegation no longer tries to run manage.py with the tool environment's Python.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.