r/linuxquestions • u/mohamedibrahim456 • 1h ago
How can I package and install my Python application as a `.deb` package?
I have a project directory named `pkgmate`. I want to package the entire project so that installing a new version updates all of its files, including the application code and data files. I also want to be able to launch the application from the terminal using either `pkgmate` or `builder`.
The project is currently organized like this:
```text
pkgmate/
├── assets/
├── core/
├── data/
│ ├── builder.py (execuatble)
│ ├── builder_core.py
│ ├── graphics.json
│ ├── multimedia.json
│ ├── programming.json
│ └── sys/
├── package_managers/
├── tests/
├── ui/
├── pkgmate.py(execuatble)
└── README.md
```
What is the recommended way to structure the `.deb` package so that all required project files are installed and updated together? How should I define the command-line entry points so that both `pkgmate` and `builder` work after installation?
And how to update the package next time i want to update?
I tried to search about that but i actually have no idea what to search plus ai ain't much help
1
u/dasisteinanderer 45m ago
firs thing you should do is re-structure you program to be a python package https://packaging.python.org/en/latest/tutorials/packaging-projects/
you probably want a pyproject.toml file at the project root, which should contain "[project.scripts]" which are generated by your python build system and serve as binaries (actually, python scripts) that jump into specified points in your python package.
then, you need to create the "debian" directory within the project, and fill it with the respective data, see https://wiki.debian.org/action/show/Python/LibraryStyleGuide?action=show&redirect=Python%2FPackaging
this is all a bit fiddly, but you can look at what other packages have done