1

We are develop our projects with poetry. In one of which we implement qr-code decoding. As the pip package site states zbar needs to be installed on the system.

Is it somehow possible that poetry/pip installs the zbar dependency, while installing our package?

MaKaNu
  • 762
  • 8
  • 25

1 Answers1

1

Unfortunately not. poetry is essentially a wrapper of pip and can only manage Python dependencies from PyPi.

You could consider something like Nix for this use case: https://github.com/NixOS/nix#nix

Or you could consider a Makefile that runs the appropriate brew or apt-get-equivalent based on the operating system.

KyleKing
  • 129
  • 4
  • 11
  • Sounds like the `Makefile` is the only correct approach for the project this question originated from, since it was started as multiplattform. As far as I remember I removed my zbar dependency and used something else. Is `pip` able to handle `Makefiles` if I publish my package? – MaKaNu Dec 17 '22 at 17:39
  • I'm not sure if I understand your follow-up question. You can configure your package to run arbitrary code on install like this https://github.com/KyleKing/not-on-pypi/blob/47c2e91cc676b9d6634e2387944d5fb9d4eb5495/setup.py#L40-L65, which can be combined with Makefiles like this: https://stackoverflow.com/a/45349660/3219667. There are a number of packages that rely on install scripts – KyleKing Dec 17 '22 at 18:43
  • Typically, the Makefile would be just for developers working on the package, like from this Python package template: https://github.com/TezRomacH/python-package-template (then seen: `{{ cookiecutter.project_name.lower().replace(' ', '_').replace('-', '_') }}/Makefile`) – KyleKing Dec 17 '22 at 18:43
  • This is the thing yes. I did not worked completely through your examples but seems going into right direction. So yes to concrete my follow-up question: So since I publish with package with poetry I wandered how to inform `pip` with `poetry` that a dependency like `zbar` needs to be installed. The audience of my package is visual datasience, which is in my experience not always that techsafe, so I wanted the install process kind of easy. – MaKaNu Dec 18 '22 at 11:06
  • 1
    Oh, I see. I haven't tested it, but I think you can use [the "scripts" section for poetry to run the post-install logic](https://python-poetry.org/docs/pyproject/#scripts) – KyleKing Dec 18 '22 at 19:28