7

I'm trying to run some pre-installation commands for a pip library I'm writing. My setup file looks like:

from setuptools import setup                                                        

from setuptools.command.install import install                                      

class CustomInstall(install):                                                       
    def run(self):                                                                  
        install.run(self)                                                           
        print "TEST"                                                           

setup(                                                                              
      ...                                      
      cmdclass={'install': CustomInstall},
      ...) 

Based on Run custom task when call `pip install`.

However, pip installing is not printing "TEST". Is there something wrong I'm doing here? How can I get this setup.py file to actually print?

UPDATE: The following, FYI, does raise an Attribute error:

from setuptools import setup                                                        

from setuptools.command.install import install                                      

class CustomInstall(install):                                                       
    def run(self):                                                                  
        install.run(self)                                                           
        raise AttributeError                                                        

setup(                                                                              
      ...                                      
      cmdclass={'install': CustomInstall},
      ...) 
Community
  • 1
  • 1
Cisplatin
  • 2,860
  • 3
  • 36
  • 56
  • I answered this here: https://stackoverflow.com/questions/15853058/run-custom-task-when-call-pip-install/69366096#69366096 – Mihai.Mehe Sep 28 '21 at 17:29

1 Answers1

1

I've run into a similar issue with a custom install class that prints to sys.stdout. In my case, the custom command is actually run, but it appears that the output is being filtered by pip.

I believe that this is discussed in some detail here: https://github.com/pypa/pip/issues/2732#issuecomment-97119093

kadrlica
  • 322
  • 3
  • 15