rasbt / pyprind

PyPrind - Python Progress Indicator Utility
BSD 3-Clause "New" or "Revised" License
547 stars 65 forks source link

psutil dependency missing on PyPi #31

Closed akors closed 8 years ago

akors commented 8 years ago

Hi!

First of all, thanks for this amazing module! It looks really nice and is simple to use :)

Second, I usually install this with Pip (because why not?), but unfortunately, when I use it, psutil is always missing. When I install that too, it works fine. I believe you should specify this as a dependency. I am no Pip expert, so I don't know how, unfortunately.

rasbt commented 8 years ago

Hi, Alexander, thanks for the note and suggestion. I didn't want to make psutil a "hard" dependency since it is only required if you are running pyprind with monitor=True. I thought that not everyone wants to install psutil, but yeah, I'd be curious to hear what others think about this. If the majority of people uses it and there's no issue installing psutil on different platforms, I could add it as a dependency in the next version.

Right now, if you like to install both, you could run

pip install psutil pyprind

Hope that helps!

akors commented 8 years ago

Thanks, when having both psutil and pyprind installed, everything works.

I don't really know what the convention is for optional pip dependencies. A little suggestion would be something along the lines of

try:
    import psutil
except ImportError:
    psutil = None

class ProgBar:
    def __init__(self, ...):
        if monitor and not psutil:
            raise ValueError('psutil package is required when using the `monitor` option.')
akors commented 8 years ago

Or maybe not even raising an exception, but just ignoring the option and just issue a warning like "Ignoring monitor=True because psutil is not installed".

BrandonHeinrich commented 8 years ago

akors, I think your first suggestion is most pragmatic. If you only need psutil for the monitor option, then it would be fine to not have it as a dependency. But if they are trying to use a feature that isn't installed, having that be an error, and pointing out exactly how to fix it seems the most helpful.

rasbt commented 8 years ago

I agree with you both @akors and @BrandonHeinrich : I don't want to enforce psutils as a dependency to install pyprind, but I agree that an appropriate error message should be raised if psutils is not installed. I have just added a few lines and packaged it as v2.9.8.

Thanks for the comments and suggestions, I really appreciate it!