Open Freed-Wu opened 1 year ago
It's not encouraged because if one package want to attach some files, install them in /usr/lib/python3.11/site-packages/package_name/a_file
is better than /usr/XXX/YYY/ZZZ/a_file
. However, we must put these files outside /usr/lib/python3.11
. I think discourage is different from forbidding.
What is your opinion about this dirty trial? :smile:
This is a dirty experimental trial. It may not satisfy code style, etc.
I want to use this branch to demo and discuss the issue about can we add a setuptool entry point to generate shell completion scripts during building python package not after installing python package.
An example project is https://github.com/Freed-Wu/requirements-language-server/tree/fbc2a773d3c4de7bf442fd5096f7916592717e27.
It has a script:
pyproject.toml
:requirements_language_server.__main__:main
have usedshtab
: After installing this package, users userequirements-language-server --print-completion XXsh
can generate completion scripts forXXsh
. Then users can move these scripts to correct path to make them work.I hope an out-of-box experiences. That is during building package, shell completion scripts will be generated (we assume they are generated in
sdist/
) and packaged to python wheel. Users install the compiled wheel will get them to be installed in correct paths.shtab
to build requires:pyproject.toml
:tool.setuptools.data-files
to make them are packaged to python wheel.pyproject.toml
:That's all.
Then
pip install --user dist/requirements_language_server-*-py3-none-any.whl
will get:~/.local/lib/python3.10/site-packages/requirements_language_server
~/.local/share/bash-completion/completions/requirements_language_server
~/.local/share/zsh/site-functions/_requirements_language_server
Or without
--user
:/usr/lib/python3.10/site-packages/requirements_language_server
/usr/share/bash-completion/completions/requirements_language_server
/usr/share/zsh/site-functions/_requirements_language_server
bash-completion and
zsh
will search completion scripts in these directories.Pro:
Con:
requirements_language_server.__main__:main
must sourcerequirements_language_server/__main__.py
. Ifrequirements_language_server/__main__.py
orrequirements_language_server/__init__.py
has aimport XXX
butXXX
is not declared in. Perhaps we should disable this feature by default, only enable it when user addenable-setuptools-entry-point = true
inpyproject.toml
?import XXX
will fail.It's only my 2c. I just throw a bad thought to attract good ideas. :smile:
PS: In fact, this thought is the continuation of the thought https://github.com/huggingface/huggingface_hub/pull/1207#issuecomment-1779536093.