Support PEP 420 -- Implicit Namespace Packages
See original GitHub issueAs Python 2 has been deprecated, we should move away from the pkg_resources
approach and use PEP 420 – Implicit Namespace Packages.
Importing pkg_resources
will add a 100ms~200ms delay to CLI’s loading time.
$ time python -c "import pkg_resources"
real 0m0.153s
user 0m0.137s
sys 0m0.016s
time python -X importtime -m azure.cli version -h 2>perf.log
tuna perf.log
This is discussed at https://github.com/pypa/setuptools/issues/510 which affects many projects but still doesn’t have a proper fix.
Moreover, on Linux, the wrapper ~/env38/bin/az
created by Easy Install also requires pkg_resources
:
#!/home/admin/env38/bin/python
# EASY-INSTALL-DEV-SCRIPT: 'azure-cli==2.5.1','az'
__requires__ = 'azure-cli==2.5.1'
__import__('pkg_resources').require('azure-cli==2.5.1')
__file__ = '/home/admin/azure-cli/src/azure-cli/az'
with open(__file__) as f:
exec(compile(f.read(), __file__, 'exec'))
This makes az
installed via azdev
even slower.
For comparison, directly run azure.cli
:
$ time python -m azure.cli version -h
real 0m0.261s
user 0m0.238s
sys 0m0.024s
Run the Easy Install wrapper:
$ time python ~/env38/bin/az version -h
real 0m0.822s
user 0m0.779s
sys 0m0.044s
python -X importtime ~/env38/bin/az version -h 2>perf.log
tuna perf.log
In our Linux release, we package our own wrapper src/azure-cli/az
, so it doesn’t suffer from the slowness of this Easy Install wrapper.
Issue Analytics
- State:
- Created 3 years ago
- Comments:19 (18 by maintainers)
Top Results From Across the Web
PEP 420 – Implicit Namespace Packages
Namespace packages are designed to support being split across multiple directories (and hence found via multiple sys.path entries). In this ...
Read more >PEP 420 - implicit namespace packages - O'Reilly
If you use and target only Python 3, then there is good news for you. PEP 420 (Implicit Namespace Packages) introduced a new...
Read more >Support for implicit namespace packages PEP 420 : PY-7156
Support for implicit namespace packages PEP 420 ; Included in builds, Not included in builds ; Available in, No available in ; Tester,...
Read more >pep 420 namespace_packages purpose in setup.py
As you can see, the sample packages using the implicit namespace packages don't use namespace_packages arg in their setup scripts (here is ...
Read more >flake8-no-pep420 - PyPI
A flake8 plugin to ban PEP-420 implicit namespace packages. Requirements. Python 3.7 to 3.11 supported. Installation. First, install with pip:
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, you can kill them now, their only purpose is Python 2, that you don’t handle anymore. Remove them all from everywhere.
@jiasli
azure\cli\__init__.py
,azure\cli\__init__.py
. This file shouldn’t exist.The debate we have with @zooba is solely about this line, and nothing else, the rest of the recommended guidelines still applies. Once everything else is fixed, and we’re down the decide this, we’ll settle the debate 😃. In the meantime, keep this line since it’s there, but there is many things to still fix it seems.