Skip to content

PYTHON_ARGCOMPLETE_OK not working when calling subprocess #520

@64rl0

Description

@64rl0

I have an entry point in my project_root/scripts however what that script is doing is running a subprocess to run the script with the correct python interpreter and its dependencies like:

project_root/scripts/my-cli.py

def main():
    # Determine the base path at runtime
    this_path = os.path.dirname(os.path.abspath(__file__))
    root_path = os.path.join(this_path, '..')

    # Locate the Python interpreter in the bundled venv
    venv_python = os.path.join(root_path, 'build_venv/bin/python3')

    # Path to main script
    main_script = os.path.join(root_path, 'entrypoint.py')

    # Check if the bundled interpreter exists
    if not os.path.exists(venv_python):
        print("Python interpreter not found. Please create it.")
        sys.exit(1)

    # Run the main script with the bundled interpreter
    command = [venv_python, main_script] + sys.argv[1:]
    result = subprocess.run(command)

    return result.returncode

if I place the # PYTHON_ARGCOMPLETE_OK in the project_root/scripts/my-cli.py then the completion is not working

however if i place it on the entrypoint.py that is called by the subprocess here above then it works perfectly

obviously I cannot call entrypoint.py directly from my zsh because I don't always have the correct venv activated.

Is there a work around for this to work?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions