Search code examples
pythongitmodulepipgitignore

What files need to be uploaded or added to the git repository if I'm making a pip module


I recently made an open-source pip module and I and to publish it is PyPI. I know on the PyPI, I can directly publish the modules dist/* folder using twine but I also want to publish this module on GitHub, Gitlab & My own organization's official git repo. So, I was wondering which files should I add to the git repository?

My project structure

src Folder: This is the main folder of my file that I codded my python modules.

So on the git repository should I upload:

  1. All the files (No venv folder)
  2. dist Folder, src Folder, .gitinore, LICENSE, README.md, setup.py
  3. Option (2) without the src Folder
  4. Option (2) without the dist Folder

Solution

  • You only need to include the src folder, .gitinore, LICENSE, README.md, and setup.py. Ideally you always want to re-build before publishing to Pypi, so you do not need the dist folder.

    However, I recommend using the dependency management tool poetry, which uses a pyproject.toml instead of the setup.py. It's much more human-readable and easier to manage than the old-fashioned setup.py.

    poetry also allows publishing your package to Pypi with a single command poetry publish --build ....