Skip to content Skip to sidebar Skip to footer

Difference Between Pip3 And `python3 Setup.py Install` Regarding Cmdclass Argument

I tried to configure my package such that a script is executed on the installation process. Therefore, I inherited from setuptools.command install and created my custom class Actio

Solution 1:

pip calls your setup.py but it redirects stdout/stderr. To test setup.py under pip write to a file in a fixed location:

classActionOnInstall(install):
    defrun(self):
        print("Call install.run(self) works!", file=open('/tmp/debug.log', 'w'))
        install.run(self)

Look into /tmp/debug.log after pip install .

Solution 2:

pip does run python setup.py install when installing your package - it does not change the way your setup.py feel is executed.

The reason you don't see any output is, as @phd mentioned, that pip by default hides all the output from running the setup.py file since most of the information printed when running python setup.py install is not useful to most users.

You can see this hidden output, along with everything else pip does, by passing the "--verbose" option to pip install:

$ pip install --verbose ./foo
Processing ./foo
Running setup.py (path:/private/var/folders/4d/bt0_xfx56bjfmmt2bv3r5_qh0000gn/T/pip-ti0o0gtu-build/setup.py) egg_info for package from file:///Users/pradyunsg/.venvwrap/venvs/t
mp-c0ebb35987c76ad/foo
    Running command python setup.py egg_info
    running egg_info
    creating pip-egg-info/foo.egg-info
    writing pip-egg-info/foo.egg-info/PKG-INFO
    writing dependency_links to pip-egg-info/foo.egg-info/dependency_links.txt
    writing top-level names to pip-egg-info/foo.egg-info/top_level.txt
    writing manifest file 'pip-egg-info/foo.egg-info/SOURCES.txt'
    reading manifest file 'pip-egg-info/foo.egg-info/SOURCES.txt'
    writing manifest file 'pip-egg-info/foo.egg-info/SOURCES.txt'
Source in /private/var/folders/4d/bt0_xfx56bjfmmt2bv3r5_qh0000gn/T/pip-ti0o0gtu-build has version 0.0.0, which satisfies requirement foo==0.0.0 from file:///Users/pradyunsg/.ve
nvwrap/venvs/tmp-c0ebb35987c76ad/foo
Could not parse version from link: file:///Users/pradyunsg/.venvwrap/venvs/tmp-c0ebb35987c76ad/foo
Installing collected packages: foo
Running setup.py install for foo ...     Running command /Users/pradyunsg/.venvwrap/venvs/tmp-c0ebb35987c76ad/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/privat
e/var/folders/4d/bt0_xfx56bjfmmt2bv3r5_qh0000gn/T/pip-ti0o0gtu-build/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(comp
ile(code, __file__, 'exec'))" install --record /var/folders/4d/bt0_xfx56bjfmmt2bv3r5_qh0000gn/T/pip-cetn8xa9-record/install-record.txt --single-version-externally-managed --compi
le --install-headers /Users/pradyunsg/.venvwrap/venvs/tmp-c0ebb35987c76ad/bin/../include/site/python3.6/foo
    running install
    Call install.run(self) works!
    running build
    running install_egg_info
    running egg_info
    creating foo.egg-info
    writing foo.egg-info/PKG-INFO
    writing dependency_links to foo.egg-info/dependency_links.txt
    writing top-level names to foo.egg-info/top_level.txt
    writing manifest file 'foo.egg-info/SOURCES.txt'
    reading manifest file 'foo.egg-info/SOURCES.txt'
    writing manifest file 'foo.egg-info/SOURCES.txt'
    Copying foo.egg-info to /Users/pradyunsg/.venvwrap/venvs/tmp-c0ebb35987c76ad/lib/python3.6/site-packages/foo-0.0.0-py3.6.egg-info
    running install_scripts
    writing list of installed files to '/var/folders/4d/bt0_xfx56bjfmmt2bv3r5_qh0000gn/T/pip-cetn8xa9-record/install-record.txt'done
Removing sourcein /private/var/folders/4d/bt0_xfx56bjfmmt2bv3r5_qh0000gn/T/pip-ti0o0gtu-build
Successfully installed foo-0.0.0
Cleaning up...

Post a Comment for "Difference Between Pip3 And `python3 Setup.py Install` Regarding Cmdclass Argument"