mapepire-python 0.3.0__py3-none-any.whl → 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,17 +6,13 @@ from typing import Final, Optional
6
6
 
7
7
  logger = logging.getLogger(__name__)
8
8
 
9
- sspi = None
10
- gssapi = None
11
9
  PLATFORM = platform.system()
12
10
  TOKEN_PREFIX: Final = "_KERBEROSAUTH_"
13
11
 
14
-
15
- # For Windows SSPI token generation:
16
- if PLATFORM == "Windows":
17
- import sspi
18
- else:
19
- import gssapi
12
+ _KERBEROS_EXTRA_HINT = (
13
+ "Kerberos authentication requires the optional 'kerberos' extra. "
14
+ "Install it with: pip install mapepire-python[kerberos]"
15
+ )
20
16
 
21
17
 
22
18
  class KerberosTokenProvider:
@@ -62,6 +58,11 @@ class KerberosTokenProvider:
62
58
  return TOKEN_PREFIX + token_b64
63
59
 
64
60
  def _refresh_token_windows(self) -> str:
61
+ try:
62
+ import sspi
63
+ except ImportError as e:
64
+ raise ImportError(_KERBEROS_EXTRA_HINT) from e
65
+
65
66
  logger.debug("Generating Kerberos token via Windows SSPI for host=%s", self.host)
66
67
  target = f"krbsvr400/{self.host}"
67
68
  client = sspi.ClientAuth("Kerberos", targetspn=target)
@@ -76,6 +77,11 @@ class KerberosTokenProvider:
76
77
  return self._format_token(token)
77
78
 
78
79
  def _refresh_token_unix(self) -> str:
80
+ try:
81
+ import gssapi
82
+ except ImportError as e:
83
+ raise ImportError(_KERBEROS_EXTRA_HINT) from e
84
+
79
85
  logger.debug("Generating Kerberos token via GSSAPI for host=%s realm=%s", self.host, self.realm)
80
86
  os.environ["KRB5_CONFIG"] = self.krb5_path
81
87
  if self.ticket_cache:
@@ -52,6 +52,18 @@ class ServerTraceDest(Enum):
52
52
  FILE = "FILE"
53
53
  IN_MEM = "IN_MEM"
54
54
 
55
+ @classmethod
56
+ def _missing_(cls, value: object) -> "ServerTraceDest":
57
+ if isinstance(value, str):
58
+ v_upper = value.upper()
59
+ if v_upper in ("FILE", "IN_MEM"):
60
+ return cls(v_upper)
61
+ if v_upper == "UNKNOWN":
62
+ return cls.FILE
63
+ # If server returns a file path (e.g. /tmp/... on server 2.4.0) or other string, fallback to FILE
64
+ return cls.FILE
65
+ return cls.FILE
66
+
55
67
  class MessageType(Enum):
56
68
  CONNECT = "connect"
57
69
  SQL = "sql"
@@ -1,5 +1,5 @@
1
- _MAJOR = "0"
2
- _MINOR = "3"
1
+ _MAJOR = "1"
2
+ _MINOR = "0"
3
3
  # On main and in a nightly release the patch should be one ahead of the last
4
4
  # released build.
5
5
  _PATCH = "0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mapepire-python
3
- Version: 0.3.0
3
+ Version: 1.0.0
4
4
  Author-email: Adam Shedivy <adam.shedivy@ibm.com>, Irfan Sharif <IrfanSharif@ibm.com>
5
5
  License: Apache License
6
6
  Version 2.0, January 2004
@@ -219,11 +219,14 @@ License-File: LICENSE
219
219
  Requires-Dist: dataclasses-json>=0.6.4
220
220
  Requires-Dist: websockets>=14.0
221
221
  Requires-Dist: pep249abc
222
+ Provides-Extra: kerberos
223
+ Requires-Dist: gssapi; sys_platform != "win32" and extra == "kerberos"
224
+ Requires-Dist: pywin32; sys_platform == "win32" and extra == "kerberos"
222
225
  Provides-Extra: dev
223
- Requires-Dist: ruff; extra == "dev"
224
- Requires-Dist: mypy<1.20,>=1.0; extra == "dev"
226
+ Requires-Dist: ruff<0.16,>=0.15; extra == "dev"
227
+ Requires-Dist: mypy<2.4,>=1.0; extra == "dev"
225
228
  Requires-Dist: black<27.0,>=24.3.0; extra == "dev"
226
- Requires-Dist: isort<6.2,>=5.12; extra == "dev"
229
+ Requires-Dist: isort<8.1,>=5.12; extra == "dev"
227
230
  Requires-Dist: pytest>=9.0.3; extra == "dev"
228
231
  Requires-Dist: pep249abc; extra == "dev"
229
232
  Requires-Dist: pytest-asyncio; extra == "dev"
@@ -236,8 +239,6 @@ Requires-Dist: packaging; extra == "dev"
236
239
  Requires-Dist: pre-commit; extra == "dev"
237
240
  Requires-Dist: python-dotenv; extra == "dev"
238
241
  Requires-Dist: pytest-env; extra == "dev"
239
- Requires-Dist: gssapi; extra == "dev"
240
- Requires-Dist: pywin32; sys_platform == "win32" and extra == "dev"
241
242
  Dynamic: license-file
242
243
 
243
244
  # mapepire-python
@@ -261,6 +262,7 @@ Dynamic: license-file
261
262
  - [Overview](#overview)
262
263
  - [Setup](#setup)
263
264
  - [Install with `pip`](#install-with-pip)
265
+ - [Optional: Kerberos authentication support](#optional-kerberos-authentication-support)
264
266
  - [Server Component Setup](#server-component-setup)
265
267
  - [Quick Start](#quick-start)
266
268
  - [Other Connection options](#other-connection-options)
@@ -332,6 +334,23 @@ Dynamic: license-file
332
334
  pip install mapepire-python
333
335
  ```
334
336
 
337
+ #### Optional: Kerberos authentication support
338
+
339
+ Kerberos authentication (see [Authenticating with Kerberos](#11-authenticating-with-kerberos)) requires the optional `kerberos` extra, which pulls in `gssapi` on Linux/macOS or `pywin32` on Windows:
340
+
341
+ ```bash
342
+ pip install mapepire-python[kerberos]
343
+ ```
344
+
345
+ On Linux, building `gssapi` also requires Kerberos development headers to be available, e.g.:
346
+
347
+ ```bash
348
+ sudo apt install libkrb5-dev # Debian/Ubuntu
349
+ sudo dnf install krb5-devel # Fedora/RHEL
350
+ ```
351
+
352
+ If you don't use Kerberos authentication, you don't need this extra — the base `pip install mapepire-python` has no Kerberos dependencies.
353
+
335
354
  ### Server Component Setup
336
355
  To use mapire-python, you will need to have the Mapepire Server Component running on your IBM i server. Follow these instructions to set up the server component: [Mapepire Server Installation](https://mapepire-ibmi.github.io/guides/sysadmin/)
337
356
 
@@ -404,6 +423,9 @@ job = SQLJob(creds)
404
423
  ### 1.1 Authenticating with Kerberos
405
424
  If your IBM i is configured to support Kerberos authentication, you can authenticate using Kerberos instead of passing a plain-text password to the `DaemonServer` Object.
406
425
 
426
+ > [!NOTE]
427
+ > Kerberos support requires the `kerberos` extra: `pip install mapepire-python[kerberos]`. See [Optional: Kerberos authentication support](#optional-kerberos-authentication-support).
428
+
407
429
  #### 1.1.1 Windows
408
430
 
409
431
  If your Windows machine is part of a Kerberos realm and supports SSPI authentication, you can authenticate by creating the `DaemonServer` as shown below:
@@ -486,12 +508,14 @@ First create a `mapepire.ini` file in the root of your project with the followin
486
508
 
487
509
  ```ini title=mapepire.ini
488
510
  [mapepire]
489
- SERVER="SERVER"
490
- PORT="PORT"
491
- USER="USER"
492
- PASSWORD="PASSWORD"
511
+ host=SERVER
512
+ port=PORT
513
+ user=USER
514
+ password=PASSWORD
493
515
  ```
494
516
 
517
+ > **Note:** The keys must match the `DaemonServer` fields (`host`, `port`, `user`, `password`), and values must **not** be quoted — write `host=myhost`, not `host="myhost"`.
518
+
495
519
  Then you can create a `SQLJob` object by passing the path to the `.ini` file which will handle the connection details
496
520
 
497
521
 
@@ -573,7 +597,7 @@ logging.getLogger("mapepire_python").setLevel(logging.DEBUG)
573
597
 
574
598
  # Usage
575
599
 
576
- Depending on your setup and use case, you can choose the most convenient way to configure the connection details. The following usage examples are compatible with all three connection options detailed above. For simplicity, we assume there is a `mapepire.ini` file in the root of the project with the connection details.
600
+ Depending on your setup and use case, you can choose the most convenient way to configure the connection details. The following usage examples are compatible with all four connection options detailed above. For simplicity, we assume there is a `mapepire.ini` file in the root of the project with the connection details.
577
601
 
578
602
 
579
603
  There are four main ways to run queries using `mapepire-python`:
@@ -1,16 +1,16 @@
1
1
  mapepire_python/__init__.py,sha256=Zefd0EuqhUkFbeCcP5tdZRL7NhCSFTP0-3dEyFFnaW4,1937
2
2
  mapepire_python/async_base_job.py,sha256=maTbQ4QRFo4lp5U-0J8rOR4LOczNVazz9LuTFJ-096s,8120
3
3
  mapepire_python/base_job.py,sha256=SGoiE2J8L9GjU0m0UvwEsfme7MEv0WpdAyQnakEib3Y,3048
4
- mapepire_python/data_types.py,sha256=mW72PHBuZd9U48-_T5-pw4qdMmDiiUurhQSz-UqBdnA,14103
4
+ mapepire_python/data_types.py,sha256=JzvfwEb034ztAkWc5hbD3_Dc4ja5bWVbZkuam1JI1s4,14565
5
5
  mapepire_python/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  mapepire_python/query_manager.py,sha256=XgdQr10XZYgL2lYBGjLoO3WgS6lVsVDQIX9MUNYVnmg,2259
7
7
  mapepire_python/ssl.py,sha256=ERCbmz3tvKM2WULsCNgDQJe1CMEmCMVqiQU5ZSOFntc,849
8
- mapepire_python/version.py,sha256=xcW8D79i531rGr55bvU6-UK6xhit1fj384tgJxmhE6g,407
8
+ mapepire_python/version.py,sha256=VRCININAwmTEgaQ1hE7mniiHco4w8fOJFdhS-O1CG0w,407
9
9
  mapepire_python/websocket.py,sha256=mGZVaaFVe_7ZvL0M4pArh4nzUhF1okrF4nI42DsFjc4,2765
10
10
  mapepire_python/asyncio/__init__.py,sha256=GuuLvYhXJOathaIe5aCI-fBh0eN4-IhRzgKzj0bNtfI,1375
11
11
  mapepire_python/asyncio/connection.py,sha256=oeSdnJG3MwKUyAekhFxP0-NPq8rgP0C8D7-1JffMaJs,3582
12
12
  mapepire_python/asyncio/cursor.py,sha256=nAPxnSqtBBRFzUSjbGxj5CcazYHVh2Tt9A4t94zkGMQ,5225
13
- mapepire_python/authentication/kerberosTokenProvider.py,sha256=3_s29Xpo74RsSFRY18g73cwPyNp33HTU_T_WltImPHQ,4168
13
+ mapepire_python/authentication/kerberosTokenProvider.py,sha256=FSVvAIP0wKYc-_CciRtmmxFXjQQCrqj71UQdA4crb54,4459
14
14
  mapepire_python/client/__init__.py,sha256=UyTf722DdQIlkm_kDvd8NXCkuX794aGOD7AIL3arzio,58
15
15
  mapepire_python/client/async_sql_job.py,sha256=h_Zgok3gVffQt_EnUBLp9DgqrEeoUNJpr_JaEdK8UX0,392
16
16
  mapepire_python/client/query.py,sha256=neeWw9MyZ2miClzcSLzG0ZFtFbFMTbu-ftByUb6CCRY,7685
@@ -26,8 +26,8 @@ mapepire_python/pool/async_websocket_client.py,sha256=xfYsunSPj4Kk91lZz-Rlpf1oWY
26
26
  mapepire_python/pool/pool_client.py,sha256=XQ4DcgDDFJ4DD8w7n1q64UAEvj0KW9a82FUn-ea9n70,6394
27
27
  mapepire_python/pool/pool_job.py,sha256=JJNOqsOBENJgdRE16bxfJHxYFTDYoFSWprVYq1mKqX4,1028
28
28
  mapepire_python/pool/pool_query.py,sha256=V2lJPFdxfmMXm8jSAaL0-jAE-v_Nt1YrkfvCIHol67g,6309
29
- mapepire_python-0.3.0.dist-info/licenses/LICENSE,sha256=YvuKOpYh3COIF0yqq-nCMXtpS7mh1GyYvPVlW2j1G-M,11359
30
- mapepire_python-0.3.0.dist-info/METADATA,sha256=rgby1fiUdDZyMfswl-jX3ma5c7mTuKTkaFzNgZuCm3E,39226
31
- mapepire_python-0.3.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
32
- mapepire_python-0.3.0.dist-info/top_level.txt,sha256=J41xe6UH-ueP4KTS1BB3U-6FVTSca56t_Uxwa13Uwkw,16
33
- mapepire_python-0.3.0.dist-info/RECORD,,
29
+ mapepire_python-1.0.0.dist-info/licenses/LICENSE,sha256=YvuKOpYh3COIF0yqq-nCMXtpS7mh1GyYvPVlW2j1G-M,11359
30
+ mapepire_python-1.0.0.dist-info/METADATA,sha256=C0lv6trPjP-E20L1iJmma34xMM7b0Q5cSrVR-ns9B8s,40402
31
+ mapepire_python-1.0.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
32
+ mapepire_python-1.0.0.dist-info/top_level.txt,sha256=J41xe6UH-ueP4KTS1BB3U-6FVTSca56t_Uxwa13Uwkw,16
33
+ mapepire_python-1.0.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (83.0.0)
2
+ Generator: setuptools (84.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5