astrofrog / psrecord

Record the CPU and memory activity of a process :chart_with_upwards_trend:

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"pip install psrecord" doesn't work if psutil is not already installed

dhandy2013 opened this issue · comments

In the (normal) situation where psutil is not already installed, "pip install psrecord" fails with this error:

$ pip install psrecord
Collecting psrecord
  Downloading psrecord-1.0.tar.gz (55kB)
    100% |████████████████████████████████| 61kB 1.2MB/s 
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-2BWXB5/psrecord/setup.py", line 34, in <module>
        from psrecord import __version__
      File "psrecord/__init__.py", line 25, in <module>
        from .main import main
      File "psrecord/main.py", line 29, in <module>
        import psutil
    ImportError: No module named psutil

As the stack trace shows, this is because your setup.py file imports the psrecord package in order to get __version__ which is defined in __init__.py. This fails because the psrecord __init__.py also imports psrecord.main, which imports psutil. So it does no good for your setup.py file to say install_requires=['psutil'] because your setup.py script crashes before it reaches that point.

This is a very common pitfall. You need a different method of defining the version in your setup.py file. This webpage documents 7 different ways to do it: https://packaging.python.org/guides/single-sourcing-package-version/

yes, please add a requirements.txt file!

@dhandy2013 @tonythomas01 - sorry for the delay in fixing this. I've released psrecord 1.1 which should fix this.