2

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
udoyhasan
  • 1,527
  • 5
  • 19

1 Answers1

2

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 ....

faemmi
  • 201
  • 1
  • 4
  • Do I also need to add the **`*.egg-info`** folder that is under the src folder to the git? – udoyhasan Sep 02 '21 at 13:10
  • 1
    No, typically there are also a few other files in Python projects you do not want to keep, e.g. IDE files such as `.idea/`/`.vscode`, Python-specific files such as `*.egg-info/`, `__pycache__/`, and `*.pyc`. I also recommed you to set up a global gitignore file (see e.g. [here](https://stackoverflow.com/questions/7335420/global-git-ignore)) to avoid that you push any such files to any other repo you ever work on. – faemmi Sep 02 '21 at 14:19