How to install dev version of requirement in HA running in Docker?

I’m a Microsoft developer, fairly new to HA and Docker and I want to make a few experimental changes to a custom component. One of the changes is actually to one of its requirements, so I want to install a development version of the requirement as it says in the middle paragraph here: https://developers.home-assistant.io/docs/creating_integration_manifest/#custom-requirements-during-development--testing.

Is there a way to do ‘pip install -e ./requirementname’ and ‘hass --skip-pip’ when running HA supervised in Docker?

If not, what sort of environment do I need to set up to do this?

Would it be possible to modify the manifest.json file of the custom component so HA would install the development version of that requirement? That might not work with locally installed requirements, but since you can refer to a (public) git repository (as outlined in the last paragraph of the documentation you link to), you may be able to work around that limitation.

Thanks for your reply, that’s a good idea. I’ve tried to do that but I think I’m missing something as I’m not seeing a simple code change that I make. I’d be really grateful for your help if you have a minute as I’ve been struggling with this for hours!

This is what I’ve done;

  1. Taken a copy of the requirement and put it in my own repository (I don’t want to interfere with the original)
  2. Changed one of the .info log messages in the requirement to add my initials, so that I will be able to see from the HA log that it’s picking up my version
  3. Changed the pyproject.toml for the requirement to point to my repository & home page (not sure if this is necessary?)
  4. Changed the manifest.json in the custom component to point to my respository as per that last paragraph, as follows:
    “requirements”: [“git+https://github.com/MirandaPoth/[email protected]#nhc2-coco==5.5.6”]
    (The original requirement is at v1.3.3 so the 5.5.6 is my attempt to stop it picking up the original one - not sure if this is right …)
  5. Changed the REQUIREMENTS= line in the init py of the custom component to the same as previous step.

HA starts fine but I don’t see my initials in the log message. I believe I’ve got the right log message.

What am I doing wrong?

When I try to install from that URL, I see this:

$ pip install 'git+https://github.com/MirandaPoth/[email protected]#nhc2-coco==5.5.6'
Collecting git+https://github.com/MirandaPoth/[email protected]#nhc2-coco==5.5.6
  Cloning https://github.com/MirandaPoth/nhc2-coco-mp.git (to revision master) to /private/tmp/pip-req-build-bfv6717n
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Building wheels for collected packages: UNKNOWN
  Building wheel for UNKNOWN (PEP 517) ... done
  Created wheel for UNKNOWN: filename=UNKNOWN-0.0.0-py3-none-any.whl size=1784 sha256=059f78209a0243a17e71a80537ad9cf8b59a065383fd6a178adbcadf25c3b62b
  Stored in directory: /private/tmp/pip-ephem-wheel-cache-iy5tuohz/wheels/51/7f/b9/13ea5d0685a2f39b4c21bc37715ef5a3824bcf3be515d20fb4
Successfully built UNKNOWN
Installing collected packages: UNKNOWN
Successfully installed UNKNOWN-0.0.0

It looks like the pyproject.toml file is meant for a specific dependency manager/packager called Poetry, which HA is not using hence the “UNKNOWN” (which is causing your modified package to not get picked up, because it’s not installed with the right name).

I guess you need to configure the package so setuptools can install it (more info here).

1 Like

YES!!! That’s it. Thank you so much! I am so grateful.

So for others similarly perplexed by this, this is the setup.py file I needed:

from setuptools import setup, find_packages
setup(name='nhc2-coco',
      version='0.1',
      packages = find_packages(),
      package_data={'nhc2_coco': ['coco_ca.pem']},
      include_package_data=True
      )

It didn’t work at first because of the missing data file. The file specified is required in the same folder as the code, the bottom two lines makes it include it in the package.

Thanks again @robertklep!

1 Like