0

This question also asks, what I'm looking for but it's quite old and there hasn't been Poetry yet.

In the documentation I didn't find a way to tell Poetry to create packages which upon installation distribute/create files outside the site-packages folder (except tool.poetry.scripts, which creates executables in ~/.local/bin).

How do I make pip install .. <my-package> create e.g. ~/.local/share/applications/my-package.desktop with Poetry?

frans
  • 8,868
  • 11
  • 58
  • 132
  • Not possible in modern Python - your problem is a subset of [this problem](https://stackoverflow.com/questions/40588634/how-to-install-data-files-to-absolute-path) and wheels natively [do not support this](https://github.com/pypa/packaging-problems/issues/576), and by extension Poetry does not support this ([a lengthy related discussion](https://github.com/python-poetry/poetry/issues/890)). – metatoaster Jul 10 '23 at 07:12
  • 1
    I believe that's correctly out of scope for Python packages; sounds like you want to build an OS install package (like a *.deb or *.rpm ). – ckhan Jul 10 '23 at 10:05
  • That's not totally true - `pip install ` _can_ create executable scripts inside the selected `bin` folder, e.g. `~/.local/bin`, which is more than just making a Python package available. And it's actually quite close to also putting something inside `~/.local/share/applications` I guess – frans Jul 10 '23 at 13:20
  • The `~/.local/bin` is the only exception but even then this being moved towards as a discouraged practice, as even with the usage of the `--user` flag for `pip` is going to trigger a warning to use virtualenvs instead (see [PEP-0668](https://peps.python.org/pep-0668/#marking-an-interpreter-as-using-an-external-package-manager)). Putting a executable in `bin` is absolutely critical and standardized, while Python packaging authority has had a lengthy discussion on insisting they are staying out of this space for all paths outside the standard Python paths. (Please read those discussions). – metatoaster Jul 11 '23 at 06:09
  • Also, do realize that Python also run on Windows - Windows do not have the `/usr/share` equivalent at the same location, instead there are a variety of paths - as this part is not standardized across operating systems, while the various `bin/` paths are standardized and accessible via the `PATH` environment variable, you will not find this support within Python - use another tool to make distributable packages of your software, or heck, make your own version (and contribute to the problem of having too many Python packaging solutions that don't work). – metatoaster Jul 11 '23 at 06:15
  • If you _insist_ on needing this, just create a function in your program that would unpack the included data files (packaged with the final `.whl` file under the `dist-info`) into your desired locations. – metatoaster Jul 11 '23 at 06:20

0 Answers0