Skip to content

move argon2-cffi to optional [password] dependency for Python 3.13 #1520

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:
python-version: "3.10"
- os: ubuntu-latest
python-version: "3.12"
- os: ubuntu-latest
python-version: "3.13t"
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
11 changes: 10 additions & 1 deletion jupyter_server/auth/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ def passwd(passphrase=None, algorithm="argon2"):
raise ValueError(msg)

if algorithm == "argon2":
import argon2
try:
import argon2
except ModuleNotFoundError:
msg = "argon2 password hashing requires argon2-cffi package. `pip install 'jupyter-server[password]'` for support."
raise ImportError(msg) from None

ph = argon2.PasswordHasher(
memory_cost=10240,
Expand Down Expand Up @@ -105,6 +109,11 @@ def passwd_check(hashed_passphrase, passphrase):
True
"""
if hashed_passphrase.startswith("argon2:"):
try:
import argon2
except ModuleNotFoundError:
msg = "argon2 password hashing requires argon2-cffi package. `pip install 'jupyter-server[password]'` for support."
raise ImportError(msg) from None
import argon2
import argon2.exceptions

Expand Down
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ classifiers = [
requires-python = ">=3.9"
dependencies = [
"anyio>=3.1.0",
"argon2-cffi>=21.1",
# argon2-cffi unavailable for free-threaded Python
# make it optional for Python >= 3.13 until PEP 780
# lets us limit it to the actually affected builds
"argon2-cffi>=21.1; python_version < '3.13'",
"jinja2>=3.0.3",
"jupyter_client>=7.4.4",
"jupyter_core>=4.12,!=5.0.*",
Expand Down Expand Up @@ -52,6 +55,9 @@ Source = "https://github.com/jupyter-server/jupyter_server"
Tracker = "https://github.com/jupyter-server/jupyter_server/issues"

[project.optional-dependencies]
password = [
"argon2-cffi>=21.1",
]
test = [
"ipykernel",
"pytest-console-scripts",
Expand Down
Loading