diff --git a/conf/requirements.txt b/conf/requirements.txt index 0dc21dbf..77152c96 100644 --- a/conf/requirements.txt +++ b/conf/requirements.txt @@ -23,4 +23,4 @@ python-socketio==5.18.1 segno==1.6.6 websockify==0.13.0 whitenoise==6.12.0 -crypt-r>=3.13.0; python_version >= "3.13" +crypt-r>=3.13.0; python_version >= "3.11" diff --git a/instances/views.py b/instances/views.py index 199401bf..f2f92a38 100755 --- a/instances/views.py +++ b/instances/views.py @@ -1,7 +1,3 @@ -try: - import crypt_r as crypt -except ImportError: - import crypt import difflib import functools import hashlib @@ -11,10 +7,17 @@ import os import re import secrets import socket +import sys import subprocess import time from ipaddress import ip_address +# the stdlib crypt is deprecated from Python 3.11 and gone in 3.13: crypt_r is the same module +if sys.version_info >= (3, 11): + import crypt_r as crypt +else: + import crypt + from accounts.models import UserInstance, UserSSHKey from admin.decorators import superuser_only from appsettings.models import AppSettings