3

today I attempted to remove a file after my package (a python wheel) was installed via pip with the -t --target option. Post-install script with Python setuptools I am subclassing install in my setup.py like this:

class PostInstallCommand(install):
    """Post-installation for installation mode."""
    def run(self):
        install.run(self)
        # here I am using 
        p = os.path.join(self.install_libbase,"myPackage/folder/removeThisPyc.pyc")
        if os.path.isfile(p):
            os.unlink(p)
        #there is also self.install_platlib and
        #self.install_purelib which seem to be used by pip distutil scheme 
        #Have not tested those yet

when running

python setup.py install

this works the file is removed upon install. But through

pip install path-to-my-wheel.whl

this does not work and the file is still there.

pip install -t /target/dir path-to-my-wheel.whl

does not work either... So question is, what is pip doing with distutils and or setuptools and how can make this work? Another thing I noticed is that pip does not seem to be printing anything, I am printing in my setup.py in verbose mode? Is there away to see the full output from python instead of the "pip" only stuff?

Shawn Mehan
  • 4,513
  • 9
  • 31
  • 51

1 Answers1

0

Reading educates: http://pythonwheels.com/ 2. Avoids arbitrary code execution for installation. (Avoids setup.py) As I am using wheels and wheels wont execute the setup.py, my concept of doing this is rubbish. https://github.com/pypa/packaging-problems/issues/64

I guess this is between deployment and installation, though I would obviously count my little change to installation...

Is there a way to avoid pyc file creation upon a pip install whl ?