Installing a local anvil app as a package on a python virtual environment?

Suppose that I want to install a local clone of an anvil app (e.g. anvil_extras) on a conda/venv environment. How could I go about doing this?

To give some context - I have an Anvil app that I have cloned locally so that I can work on it with VSCode. However, I get a lot of “import could not be resolved” warnings from Pylance for dependencies such as anvil_extras and other anvil apps. So I would like to install these as packages on a conda env (such that VSCode recognizes the imports and the imports would work for things like unit tests).

What I’ve tried (not working):

  1. Adding a minimal setup.py to the dependency’s root folder and running pip install -e . from the terminal. Also tried a plain pip install .
  2. Only specifying the /client_code directory as the installation folder instead of the root folder.
  3. Playing around with the options and parameters to pip install
  4. Using an src/ layout
    ├── src
    │ └── mypackage
    │ ├── __init__.py
    │ └── client_code/
    │ └── server_code/
    ├── setup.py
    └── setup.cfg

But nothing seems to work… the app appears to get installed as a package and is present when calling pip list, however the package name is not recognized when I try to import it (e.g., in a jupyter notebook) and produces a ModuleNotFoundError. And the MissingImports warnings from Pylance are still there. I am of course selecting the interpreter of the correct environment in jupyter/VSCode.

I am certain that I cannot be the first person facing this issue, yet I could not find another forum topic concerning this.

Am I missing something obvious?

1 Like