Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom pip install commands not running

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},
      ...) 
like image 681
Cisplatin Avatar asked Apr 18 '16 19:04

Cisplatin


People also ask

Why is my pip command not working?

A “pip: command not found” error occurs when you fail to properly install the package installer for Python (pip) needed to run Python on your computer. To fix it, you will either need to re-install Python and check the box to add Python to your PATH or install pip on your command line.

How do I run pip commands?

Ensure you can run pip from the command lineRun python get-pip.py . 2 This will install or upgrade pip. Additionally, it will install setuptools and wheel if they're not installed already. Be cautious if you're using a Python install that's managed by your operating system or another package manager.

How do you pip install using CMD?

Step 1: Download the get-pip.py (https://bootstrap.pypa.io/get-pip.py) file and store it in the same directory as python is installed. Step 2: Change the current path of the directory in the command line to the path of the directory where the above file exists. Step 4: Now wait through the installation process. Voila!


1 Answers

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

like image 90
kadrlica Avatar answered Sep 27 '22 20:09

kadrlica