Skip to content

Commit 6d1cc06

Browse files
committed
move argon2-cffi to optional [password] dependency for Python 3.13
a temporary measure, to allow installation on free-threaded Python while CFFI is unsupported When PEP 780 lands, we can move this to a free-threaded condition, instead of a version one - big downside: `pip install jupyterlab` is incomplete on Python 3.13 if you have a password set - upside: 3.13t installation is _possible_, where it wasn't before
1 parent e12feb9 commit 6d1cc06

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

.github/workflows/python-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ jobs:
2828
python-version: "3.10"
2929
- os: ubuntu-latest
3030
python-version: "3.12"
31+
- os: ubuntu-latest
32+
python-version: "3.13t"
3133
steps:
3234
- name: Checkout
3335
uses: actions/checkout@v4

jupyter_server/auth/security.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ def passwd(passphrase=None, algorithm="argon2"):
5959
raise ValueError(msg)
6060

6161
if algorithm == "argon2":
62-
import argon2
62+
try:
63+
import argon2
64+
except ModuleNotFoundError:
65+
raise ImportError(
66+
"argon2 password hashing requires argon2-cffi package. `pip install 'jupyter-server[password]'` for support."
67+
) from None
6368

6469
ph = argon2.PasswordHasher(
6570
memory_cost=10240,
@@ -105,6 +110,12 @@ def passwd_check(hashed_passphrase, passphrase):
105110
True
106111
"""
107112
if hashed_passphrase.startswith("argon2:"):
113+
try:
114+
import argon2
115+
except ModuleNotFoundError:
116+
raise ImportError(
117+
"argon2 password hashing requires argon2-cffi package. `pip install 'jupyter-server[password]'` for support."
118+
) from None
108119
import argon2
109120
import argon2.exceptions
110121

pyproject.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ classifiers = [
2424
requires-python = ">=3.9"
2525
dependencies = [
2626
"anyio>=3.1.0",
27-
"argon2-cffi>=21.1",
27+
# argon2-cffi unavailable for free-threaded Python
28+
# make it optional for Python >= 3.13 until PEP 780
29+
# lets us limit it to the actually affected builds
30+
"argon2-cffi>=21.1; python_version < '3.13'",
2831
"jinja2>=3.0.3",
2932
"jupyter_client>=7.4.4",
3033
"jupyter_core>=4.12,!=5.0.*",
@@ -52,6 +55,9 @@ Source = "https://github.com/jupyter-server/jupyter_server"
5255
Tracker = "https://github.com/jupyter-server/jupyter_server/issues"
5356

5457
[project.optional-dependencies]
58+
password = [
59+
"argon2-cffi>=21.1",
60+
]
5561
test = [
5662
"ipykernel",
5763
"pytest-console-scripts",

0 commit comments

Comments
 (0)