ApeWorX / ape

The smart contract development tool for Pythonistas, Data Scientists, and Security Professionals
https://apeworx.io
Apache License 2.0
880 stars 132 forks source link

Scripting system fails for CLI-based scripts when a package named `scripts` is installed #2012

Open antazoey opened 5 months ago

antazoey commented 5 months ago

Environment information

no plugins.

$ ape --version

0.7.16.dev4+ge91bc152d.d20240416

no config

What went wrong?

When python package scripts is installed (or any python package named scripts), ape cannot run CLI (clickbased scripts, the ones that define acli`.

steps to repro:

  1. make a cli script (repro.py):
import click

@click.command()
def cli():
    print("Won't see this.")
  1. install any python package named scripts (note: there is one on pypi, but i dont know what it is so be careful lol)
pip install scripts
  1. try running the cli script:
ape run repro

fails like:

ERROR: Exception while parsing script: scripts/repro.py
        ImportError: No module named scripts.repro
        (Use `--verbosity DEBUG` to see full stack-trace)
ERROR: Exception while parsing script: scripts/repro.py
        ImportError: No module named scripts.repro
Usage: ape run [OPTIONS] COMMAND [ARGS]...
Try 'ape run -h' for help.

Error: No such command 'repro'.

How can it be fixed?

I don't know yet

More info

this is currently blocking us from upgrading web3.py for some reason, because py-evm is mistakenly exporting their scripts folder as a python package. I have told the about it and I think they'll fix it, but it highlighted this bug independently in ape.

it might be a clue that the main based scripts still work!

also would like to investigate why the log appears twice

linear[bot] commented 5 months ago

APE-1728 Scripting system fails for CLI-based scripts when a package named `scripts` is installed