0

I am currently developing a python module, say my_package, which contains some image processing algorithms. It contains a setup.py for a convenient installation. Now I want to add a gui to the package so that users can try the algorithms and play with parameters. The gui will use Qt from the PySide2 package. Are there best practices for the package / directory structure for modules with both algorithms and gui?

At first I wanted to create submodules my_package.core and my_package.gui. However, since users can only install my_package as a whole, this will add the PySide2 dependency to all users, even if they just want to use the algorithms without the gui. Is it better if I create two separate packages my_package and my_package_gui, both with their own setup.py? Or will this be confusing?

pschill
  • 5,055
  • 1
  • 21
  • 42
  • Possible duplicate of [Optional dependencies in distutils / pip](https://stackoverflow.com/questions/6237946/optional-dependencies-in-distutils-pip) – bruno desthuilliers Dec 20 '18 at 09:05
  • Yes that may be a good solution. In my case, does this mean that users may choose between `pip install my_package`, which just installs the algorithms, and `pip install "my_package[gui]"`, which also installs `PySide2` and a GUI script? – pschill Dec 20 '18 at 09:25
  • Yes, that's the point. cf the doc here https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies for more details. – bruno desthuilliers Dec 20 '18 at 09:27
  • Now you can of course also have two totally distinct packages for the core and the gui and make the core a dependency of the gui. At this point which solution is "best" is mostly a matter of context, opinions and personal tastes ;-) – bruno desthuilliers Dec 20 '18 at 09:29
  • Well, that's kind of the point of my question :) Which one is a better practice? Two distinct packages or a single package with optional dependency? Do pip users know about optional dependencies? I have been using it for quite a while and this is the first time I heard about them. – pschill Dec 20 '18 at 09:32
  • I'm afraid that " Which one is a better practice" falls under the "primarily opinion based" category ;-) – bruno desthuilliers Dec 20 '18 at 10:00
  • wrt/ "pip users (knowing about) extra features", it's your responsability as the package maintainer to clearly document it in the readme / package description / documentation. And you'll have the same issue with two distinct packages actually (you'll need to document the existence of the "gui" package in the "core" one else your users won't know there's a gui too). IOW it doesn't really make a difference... – bruno desthuilliers Dec 20 '18 at 10:04

0 Answers0