PY-77993 drop legacy pkg_resources-style namespace package declarations

(cherry picked from commit 953ecce0b4f80ecd176f3f867aeed90324e8420e)

IJ-MR-166981

GitOrigin-RevId: a7522b79c0fec5d363453d0875b9529b7f232e3b
This commit is contained in:
Pavel Karateev
2025-06-28 10:00:46 +00:00
committed by intellij-monorepo-bot
parent 720a59914d
commit 2be955b18f
8 changed files with 51 additions and 72 deletions
@@ -1,5 +1,2 @@
try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
@@ -1,5 +1,2 @@
try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
@@ -0,0 +1,24 @@
import os
import pytest
@pytest.fixture
def with_my_extensions(monkeypatch):
my_extensions_path = os.path.join(os.path.dirname(__file__), "my_extensions")
monkeypatch.syspath_prepend(my_extensions_path)
def test_could_load_extensions(with_my_extensions):
from _pydevd_bundle.pydevd_extension_utils import ExtensionManager
em = ExtensionManager()
em._load_modules()
expected_modules = [
'pydevd_plugins.extensions.pydevd_plugin_test_events',
'pydevd_plugins.extensions.pydevd_plugin_test_exttype',
'pydevd_plugins.extensions.types.pydevd_plugin_numpy_types',
'pydevd_plugins.extensions.types.pydevd_plugins_django_form_str',
]
assert [m.__name__ for m in em.loaded_extensions] == expected_modules
@@ -1,5 +1,2 @@
try:
__import__('pkg_resources').declare_namespace(__name__)
except:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
@@ -1,25 +1,25 @@
Extensions allow extending the debugger without modifying the debugger code. This is implemented with explicit namespace
packages.
Extensions allow extending the debugger without modifying the debugger code.
This is implemented with explicit namespace packages.
To implement your own extension:
To implement your own extension ...
1. Ensure that the root folder of your extension is in sys.path (add it to PYTHONPATH)
1. Ensure that the root folder of your extension is in `sys.path` (add it to `PYTHONPATH`)
2. Ensure that your module follows the directory structure below
3. The ``__init__.py`` files inside the pydevd_plugin and extension folder must contain the preamble below,
and nothing else.
Preamble:
3. The `__init__.py` files inside the pydevd_plugin and extension folder must contain the preamble below,
and nothing else
4. Your plugin name inside the extensions folder must start with `pydevd_plugin`
5. Implement one or more of the abstract base classes defined in `_pydevd_bundle.pydevd_extension_api`,
this can be done by either inheriting from them or registering with the abstract base class
# Preamble
```python
try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
```
4. Your plugin name inside the extensions folder must start with `"pydevd_plugin"`
5. Implement one or more of the abstract base classes defined in `_pydevd_bundle.pydevd_extension_api`. This can be done
by either inheriting from them or registering with the abstract base class.
# Directory Structure
* Directory structure:
```
|-- root_directory-> must be on python path
| |-- pydevd_plugins
@@ -27,4 +27,4 @@ by either inheriting from them or registering with the abstract base class.
| | |-- extensions
| | | |-- __init__.py -> must contain preamble
| | | |-- pydevd_plugin_plugin_name.py
```
```
@@ -1,5 +1,2 @@
try:
__import__('pkg_resources').declare_namespace(__name__)
except:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
@@ -1,30 +0,0 @@
Extensions allow extending the debugger without modifying the debugger code. This is implemented with explicit namespace
packages.
To implement your own extension:
1. Ensure that the root folder of your extension is in sys.path (add it to PYTHONPATH)
2. Ensure that your module follows the directory structure below
3. The ``__init__.py`` files inside the pydevd_plugin and extension folder must contain the preamble below,
and nothing else.
Preamble:
```python
try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
```
4. Your plugin name inside the extensions folder must start with `"pydevd_plugin"`
5. Implement one or more of the abstract base classes defined in `_pydevd_bundle.pydevd_extension_api`. This can be done
by either inheriting from them or registering with the abstract base class.
* Directory structure:
```
|-- root_directory-> must be on python path
| |-- pydevd_plugins
| | |-- __init__.py -> must contain preamble
| | |-- extensions
| | | |-- __init__.py -> must contain preamble
| | | |-- pydevd_plugin_plugin_name.py
```
@@ -1,5 +1,2 @@
try:
__import__('pkg_resources').declare_namespace(__name__)
except:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)