pcdshub / happi

Heuristic Access to Positions of Photon Instruments
https://pcdshub.github.io/happi/master
Other
13 stars 29 forks source link

GUI / BLD: Make separate happi-qt sub-package? #340

Open tangkong opened 1 year ago

tangkong commented 1 year ago

Expected Behavior

We might want to consider having a happi[core] and happi[qt] , once we start to accrue significant qt elements.

Current Behavior

Qt widgets and their dependencies are grouped with the core code.

Possible Solution

optional dependencies install instructions

Context

246

Your Environment

pcds-5.8.0

untzag commented 1 year ago

You might already be doing this, but please consider using qtpy abstraction layer. As a pyside2 user I often get bitten by people expecting pyqt to be installed. Whatever works best for you!

klauer commented 1 year ago

https://github.com/pcdshub/happi/blob/63051eaa90ee34769de70d85d3115fc35c52133f/happi/qt/model.py#L5

tangkong commented 10 months ago

Dumping some notes so I can find them whenever we decide to do this. Adding sub-packages would be simple if we only used PIP, but conda feedstocks get a bit more confusing.

Pip

For pip, we can simply define the extra dependencies in pyproject.toml and install via pip install happi[qt] (link as above). This is rather clean and simple.

Conda

Conda does not have an analogous mechanism. Instead a recipe can specify additional "outputs", which lead to the creation of "metapackages". This is what matplotlib does with matplotlib-base (matplotlib example recipe)

package:
  name: my_package

requirements:
  host: 
   - python
  run:
    - my_package-the_subpackage1
    - my_package-the_subpackage2

outputs:
  - name: my_package.the_subpackage1
    requirements:
      - some-dep
    script: some_build_script.sh
  - name: my_package.the_subpackage2
    requirements:
      - some-other-dep
    script: some_other_build_script.sh

This seems to create multiple conda install-able packages from one recipe, both sourced from the same feedstock. Screenshot 2024-01-04 at 9 58 46 AM

It'd be great to have the same package names, but I think conda disallows brackets in package names. So we'd have to do something like conda install happi-qt

ZLLentz commented 10 months ago

I think happi (installs all the py files) and happi-qt (adds qtpy dependency and maybe pyqt in run_constrained) makes a lot of sense for the conda recipe. This is probably the pattern we should follow in general for packages that have optional widget components, i.e. there are qt elements provided but they aren't the main focus of the library.

tangkong commented 2 months ago

I should revisit this, now that we have a working example of this in lightpath https://github.com/conda-forge/lightpath-feedstock/blob/main/recipe/meta.yaml