If you can ensure that
- the package is always installed from a source distribution, not a binary wheel, and
- the user uses the
-v
option for pip install
,
you can output text in your setup.py
script.
The setup.py
is almost a regular Python script.
Just use the print()
function at the end of your setup.py
file.
In this example the file structure is somedir/setup.py
, somedir/test/
and test/__init__.py
.
Simple solution
from setuptools import setup
print("Started!")
setup(name='testing',
version='0.1',
description='The simplest setup in the world',
classifiers=[
'Development Status :: 3 - Alpha',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.0',
],
keywords='setup',
author='someone',
author_email='someone@example.com',
license='MIT',
packages=['test'],
entry_points={
},
zip_safe=False)
print("Finished!")
Started!
running install
running bdist_egg
running egg_info
writing testing.egg-info/PKG-INFO
...
...
...
Processing dependencies for testing==0.1
Finished processing
dependencies for testing==0.1
Finished!
Using setuptools.command.install
solution
Also, you can subclass the setuptools.command.install
command. Check the difference when you change the order of install.run(self)
and os.system("cat testing.egg-info/PKG-INFO")
in a clean setup.
from setuptools import setup
from setuptools.command.install import install
import os
class PostInstallCommand(install):
"""Post-installation for installation mode."""
def run(self):
install.run(self)
os.system("cat testing.egg-info/PKG-INFO")
setup(name='testing',
version='0.1',
description='The simplest setup in the world',
classifiers=[
'Development Status :: 3 - Alpha',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.0',
],
keywords='setup',
author='someone',
author_email='someone@example.com',
license='MIT',
packages=['test'],
entry_points={
},
cmdclass={
'install': PostInstallCommand,
},
zip_safe=False)