Hi, I’m working on a project where I need to develop a Python package that acts as a server that can dynamically start Docker containers and install a client within them. So i need access to the source code of the client somewhere in the package.
Just cloning the client’s Git repository or using pre-built wheels for installation is not possible, because this could lead to version mismatches between the client and the server if i am currently working on the package. I don’t want to have to push my code everytime i do a change to the client.
I was thinking of adding the sdist/wheel/tarball of the package directly as a package data file, so the server can copy it to the client and install it. But i don’t know if i can do that, I believe that scripting within pip install commands or pyproject.toml files is not supported now, as it was with setup.py.
My project structure is like this so far :
pyproject.toml
src
client
server
Also, in an ideal world, if i am working in editing mode (pip install -e), the client source code would be also dynamically updated, and i wouldn’t have to reinstall everytime i run the code and start a new container.
Let’s say i am working on my code, so i am ahead of my branch pushed somewhere with git. Now i want to test it or debug it.
First i install the package
I start the main code
I launch a new docker container, connect to it
Now i want to install a server on it
Since my codebase contain both the server and client, i want my package to be able to install itself inside the docker container, and start in server mode
I can call pip from inside the docker container, but on what ? I don’t want to use a remote repo, i want to have the code that i modified locally and installed. How do i define at installation time where to store a copy of the source code of the package so i can copy it inside the docker later and perform the installation again at runtime ?
Thanks for the answers. Initially i wanted to install using pip+wheels, to let it manage the python path and the dependencies. But i ended up just copying the source code of the module with this function and copy with docker cp, and i use the code without installation.