no ‘pkg_resources’ entry pip and console scripts?… here is a solution to the problem.
no ‘pkg_resources’ entry pip and console scripts?
When I install pip (e.g. venv
),
<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 pip is defined as “pip=pip._internal:main"
When I install my app (e.g. venv and
pip install -e.
), <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 pip is defined as ‘app=app:main'
Why is there such a difference? I want to avoid using pkg_resources
in the generated script in the same way as pip
. How to achieve this?
Solution
I had to dig deep into the pip source code to make an educated guess here.
A “simple” console script is generated when you install anything on wheels. So, you can make sure it is generated this way by making a wheel from your bag and installing the wheel.