0
# Azure NSPKG
1
2
Microsoft Azure namespace package for Python 2.7 that provides namespace package functionality for Azure SDK components. This is an internal infrastructure package that enables other Azure SDK packages to extend the `azure` namespace using Python's `pkgutil.extend_path` mechanism.
3
4
## Package Information
5
6
- **Package Name**: azure-nspkg
7
- **Package Type**: pypi
8
- **Language**: Python
9
- **Installation**: `pip install azure-nspkg`
10
- **Python Compatibility**: Python 2.7 only (Python 3+ uses PEP420 namespace packages)
11
12
## Core Imports
13
14
```python
15
import azure
16
```
17
18
## Basic Usage
19
20
The azure-nspkg package is not intended for direct usage by end users. It serves as infrastructure for other Azure SDK packages to extend the `azure` namespace. When installed, it allows packages like `azure-storage`, `azure-keyvault`, etc. to be imported as submodules of the `azure` namespace.
21
22
```python
23
# After installing azure-nspkg and other Azure packages:
24
# from azure.storage import BlobService # (if azure-storage is installed)
25
# from azure.keyvault import KeyVaultClient # (if azure-keyvault is installed)
26
```
27
28
## Architecture
29
30
The package uses Python's namespace package mechanism:
31
32
- **Namespace Extension**: Uses `pkgutil.extend_path(__path__, __name__)` to enable namespace package functionality
33
- **Conditional Installation**: Only installs the `azure` package on Python 2.7; Python 3+ relies on PEP420 implicit namespace packages
34
- **Compatibility Protection**: Prevents installation alongside incompatible azure v0.x packages that used different namespace mechanisms
35
36
## Capabilities
37
38
### Namespace Package Extension
39
40
Provides the foundational namespace package functionality that allows multiple Azure SDK packages to coexist under the `azure` namespace.
41
42
```python { .api }
43
# azure/__init__.py content:
44
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
45
```
46
47
### Version Compatibility Checking
48
49
The setup process includes compatibility validation to prevent conflicts with older azure packages that used incompatible namespace mechanisms.
50
51
```python { .api }
52
# Compatibility check logic (from setup.py):
53
try:
54
import azure
55
try:
56
ver = azure.__version__ # Only exists in incompatible v0.x
57
raise Exception(
58
'This package is incompatible with azure=={}. '.format(ver) +
59
'Uninstall it with "pip uninstall azure".'
60
)
61
except AttributeError:
62
pass # Compatible, no __version__ attribute
63
except ImportError:
64
pass # No existing azure package, safe to install
65
```
66
67
## Installation Behavior
68
69
### Python 2.7
70
- Installs the `azure` namespace package module
71
- Enables namespace functionality for other Azure SDK packages
72
- Provides backward compatibility with existing Python 2.7 code
73
74
### Python 3.x
75
- Installs an empty package to satisfy dependencies
76
- Does not provide actual namespace functionality (relies on PEP420)
77
- Prevents package server compatibility issues with `python_requires`
78
79
## Package Metadata
80
81
```python { .api }
82
# Package configuration:
83
name = 'azure-nspkg'
84
version = '3.0.2'
85
description = 'Microsoft Azure Namespace Package [Internal]'
86
author = 'Microsoft Corporation'
87
license = 'MIT License'
88
zip_safe = False
89
packages = ['azure'] # Python 2.7 only, empty list for Python 3.x
90
```
91
92
## Dependencies
93
94
- **Runtime Dependencies**: None (uses only Python standard library)
95
- **Build Dependencies**: setuptools
96
97
## Notes
98
99
- This package is intended for internal use by the Azure SDK ecosystem
100
- Not designed for direct end-user consumption
101
- Essential for Azure SDK packages to work together on Python 2.7
102
- Python 3.x installations use this package only to satisfy dependency requirements