Search code examples
pythongitpackagingpypi

Canonical workflow for python packaging and GitHub


I'm working on a solo project which I published to PyPi. Now that I've installed it with pip rather than using it from my git repo, what is the best-practice for continuing development ?

I've tried two approaches till now:

  1. The naivete: edit scripts in site-packages folder, test them, once finalized, copy to repo and push( and build, publish etc)
  2. The doppelganger: make a (sparse) repo to track the scripts in site packages, push whenever. Once ready to publish, go to the folder with the full repo, pull and then build>publish.

Now, 1. is too clunky, while 2. leaves me thoroughly unsatisfied. I was thinking of using bash tricks to streamline 2., but I thought that the sages here might have something much more streamlined, so I ask.

Thank You!


Solution

  • For development you will still want to get and edit source code from the git repository, not from PyPi.

    For example, if your git repository lived under .../src/myproject/, I would run pip install . inside myproject. This emulates an installation in the exact same way that pip install myproject=={version} would if it downloaded from PyPi. (copies the code to site-packages)

    Even better for development is pip install -e ., which sets a symbolic link from site-packages back to your source directory. So while it looks like your project is installed in your venv, it's actually just using the source code from your git repo folder.

    In general the downloads from PyPi are for users of your script, not contributors.

    Let me know in the comments if you want me to expand on any of this.