I am developing a PyQt5 app and making it available via pip install
now that pip in python3 can install pyqt5 as dependence. I made an entry point to launch my package, and told setup.py that it's a gui_scripts.
What I would like to do now, is after the person typing pip install package
, and the installation is finished, display a message to the person telling that you can now type package
in the terminal to load the application. What's the correct way of doing that? Or should I not do this?
Just use the print() function at the end of your setup.py file.
For installing packages in “editable” mode (pip install --editable), pip will invoke setup.py develop , which will use setuptools' mechanisms to perform an editable/development installation.
Use of Setup.py It primarily serves two purposes: It includes choices and metadata about the program, such as the package name, version, author, license, minimal dependencies, entry points, data files, and so on. Secondly, it serves as the command line interface via which packaging commands may be executed.
If you can ensure that
-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
.
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='[email protected]',
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!
setuptools.command.install
solutionAlso, 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='[email protected]',
license='MIT',
packages=['test'],
entry_points={
},
cmdclass={
'install': PostInstallCommand,
},
zip_safe=False)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With