zewelor / bt-mqtt-gateway

A simple Python script which provides a Bluetooth to MQTT gateway, easily extensible via custom workers. See https://github.com/zewelor/bt-mqtt-gateway/wiki for more information.
MIT License
548 stars 116 forks source link

Replace requirements installation at runtime with requirement verification #185

Closed cybe closed 3 years ago

cybe commented 4 years ago

Description

  1. Removes installation of configured requirements via pips deprecated API at runtime all together.
  2. Verifies configured requirements on startup and prints a nice error message in case any requirements aren't met.

This might break existing setups, because the implementation now exits unconditionally when requirements are not met. Are there other conditions, where this could break something? How about Docker?

Fixes #184

Example for a fully fledged configuration:

13:00:16 Starting
13:00:16 Error: unsatisfied requirements:
13:00:16   The 'miflora' distribution was not found and is required by the application
13:00:16   The 'python-eq3bt==0.1.11' distribution was not found and is required by the application
13:00:16   The 'bluepy' distribution was not found and is required by the application
13:00:16   The 'ruuvitag_sensor' distribution was not found and is required by the application
13:00:16   The 'mithermometer==0.1.4' distribution was not found and is required by the application
13:00:16   The 'python-smartgadget' distribution was not found and is required by the application
13:00:16   The 'linakdpgbt' distribution was not found and is required by the application
13:00:16 You may install those with pip: python -m pip install git+https://github.com/open-homeautomation/miflora.git@ebda66d1f4ba71bc0b98f8383280e59302b40fc8#egg=miflora python-eq3bt==0.1.11 bluepy ruuvitag_sensor mithermometer==0.1.4 pyserial python-smartgadget git+https://github.com/zewelor/linak_bt_desk.git@aa9412f98b3044be34c70e89d02721e6813ea731#egg=linakdpgbt

Type of change

zewelor commented 3 years ago

@cybe Thanks for PR. Do you consider it ready ? I like the idea, it seems less hacky and easier to maintain. Also I think it would be best to move into docker as main run method, so missing requirements should be less common.

cybe commented 3 years ago

It's ready. The latest force push also adds support for older versions of setuptools (different exception type when parsing eggs).

zewelor commented 3 years ago

Ok great ! Docker should have all requirements preinstalled, on image build, so we don't have to worry about it. https://github.com/zewelor/bt-mqtt-gateway/blob/master/Dockerfile#L17