BUG?: Editable installs (pip -e)

From within the attached demo folder, run

pip install -e toml

which installs a toml.egg-link (in site-packes ) pointing to your source folder. In your python console you can successfully import toml

→ but in TD the import fails. I guess TDs importer doesn’t correctly read the egg.link files.

1 Like

bumping this as its becoming a showstopper for my current project

I do not really understand the issue with

but in td you cant (you need to append project.folder to sys.path) but that defeats the purpose

Do that on init. You can then use the importlib module to actualy import the module after appending the project folder to the sys path. Put all of that in the init of your extension to do that on startup (check if project folder is already in sys.path to not overdo it) and you are good to go.

I might have oversimplified the example.

In a real world scenario the (python) dependencies you are simultaneously developing for a certain (TD) project are spread across multiple folders outside of the project folder. And as these are source/git folders, their code (the actual package) is likely in a subfolder.

So we would need to append all those (sub)folders to sys path, which is a bad workflow and introduces too much potential for errors (and I couldn’t do it in an extensions init as in some cases the import needs to happen before extensions are initialized)

Pythons already existing solution to this is editable installs, where a link file is created in site-packages (pointing to the dependency source folder) and you only need to make sure that your venv/site-packages is in your pythonpath.

I would suggest to build a custom importer for that situation using the importlib module:


Thats basicly what I’m doing with TD PIP (only also calling PIP too).
But maybe im also totaly missunderstanding your problem :wink: