brianhealey / pyamplipi

Python API for interacting with the AmpliPi Multizone Audio Controller
MIT License
3 stars 4 forks source link

install dependencies should get listed in the setup.py #6

Closed marc-portier closed 1 year ago

marc-portier commented 2 years ago

after pip install pyamplipi one can not just start using the library without also including its dependencies:

even a simple from pyamplipi.amplipi import AmpliPi yields an error (in that case: missing dependency aiohttp)

most straightforward approach would be to have the setup.py take over the dependencies from the requirements.txt file (or using a tool like poetry to handle it)

linknum23 commented 2 years ago

I can easily add this as a PR if it helps.

marc-portier commented 2 years ago

Quickly jotting down some boilerplate code to be added to setup.py to handle this

def required(sfx=''):
    """ Load the requirements from the requirements.txt file"""
    reqs = []
    try:
        with open(f"requirements{sfx}.txt") as f:
            reqs = [ln.strip() for ln in f.readlines() if not ln.startswith('-') and not ln.startswith('#') and ln.strip() != '']
    finally:
        return reqs

requirements = required()
requirements_dev = required('-dev')

setup ( 
    name = 'pyamplipi', 
    ....,
    install_requires=requirements,
    extras_require={'dev' : requirements_dev}, 
    ....
)

With this:

Note: It also allows for separated dependencies during development (like stuff needed for tests, doc generating....) --> through pip install -e .[dev]

I would be cracking up a PR along these lines one of these days.

Unless people prefer the road via poetry which is more impactful on the code base, but arguably even more feature-complete yet easier/more elegant to manage (as all of that is deferred to the external tool)

marc-portier commented 1 year ago

kind request to reopen -- since the applied merge is now missing the return reqs as mentioned in the comments on the PR #10