When I install pip
(e.g. with venv
), the <venv>/bin/pip
is the following:
#!"<venv>/bin/python"
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())
Their corresponding entry point is defined as "pip=pip._internal:main"
.
When I install my app
(e.g. with venv
and pip install -e .
), the <venv>/bin/app
is the following:
#!"<venv>/bin/python"
# EASY-INSTALL-ENTRY-SCRIPT: 'app','console_scripts','app'
__requires__ = 'app'
import re
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(
load_entry_point('app', 'console_scripts', 'app')()
)
My corresponding entry point is defined as 'app=app:main'
.
Why there is such a difference? I would like to avoid usage of pkg_resources
in the generated script in the same way as pip
does. How to achieve that?
I had to dig through pip source code to make an educated guess here.
The "simple" console script is generated when whatever you install is installed through a wheel. So you could make sure it's generated this way by making a wheel out of your package and installing the wheel.