0
# Python Module
1
2
Core Python module interface for jupyterlab-visualpython, providing extension discovery and version management for JupyterLab integration.
3
4
## Capabilities
5
6
### Extension Discovery
7
8
Provides JupyterLab with extension path information for proper installation and loading.
9
10
```python { .api }
11
def _jupyter_labextension_paths() -> List[Dict[str, str]];
12
```
13
14
**Description**: Returns a list containing extension path configuration for JupyterLab extension discovery. Called automatically by JupyterLab during extension loading process.
15
16
**Returns**:
17
- `List[Dict[str, str]]`: List with single dictionary containing:
18
- `'src'`: Source path to extension assets
19
- `'dest'`: Destination identifier for extension
20
21
**Usage Example**:
22
23
```python
24
import visualpython
25
26
# Called automatically by JupyterLab
27
paths = visualpython._jupyter_labextension_paths()
28
# Returns: [{'src': 'labextension', 'dest': 'jupyterlab-visualpython'}]
29
```
30
31
### Version Information
32
33
Module version identifier following semantic versioning.
34
35
```python { .api }
36
__version__: str
37
```
38
39
**Description**: String constant containing the current version of the visualpython module.
40
41
**Value**: `"0.1.0"`
42
43
**Usage Example**:
44
45
```python
46
import visualpython
47
48
print(f"Visual Python version: {visualpython.__version__}")
49
# Output: Visual Python version: 0.1.0
50
```
51
52
## Module Structure
53
54
### Import Behavior
55
56
The module attempts to import version information from `_version.py` and falls back to "dev" if unavailable:
57
58
```python
59
try:
60
from ._version import __version__
61
except ImportError:
62
import warnings
63
warnings.warn("Could not determine version", UserWarning)
64
__version__ = "dev"
65
```
66
67
### Module Files
68
69
- **`__init__.py`**: Main module file with public API
70
- **`_version.py`**: Version definition file
71
72
## Installation Integration
73
74
The module integrates with pip and JupyterLab through:
75
76
1. **Pip Installation**: Package installed via `pip install jupyterlab-visualpython`
77
2. **Extension Discovery**: JupyterLab calls `_jupyter_labextension_paths()` to locate extension
78
3. **Asset Loading**: Extension assets loaded from specified paths
79
4. **UI Integration**: Visual Python interface becomes available in JupyterLab
80
81
## Error Handling
82
83
The module handles version import failures gracefully by:
84
- Catching `ImportError` when `_version.py` is unavailable
85
- Issuing a warning about version determination failure
86
- Falling back to "dev" version identifier
87
- Continuing normal operation despite version import issues