@@ -77,6 +77,54 @@ setup_miniconda () {
7777 echo " [SETUP] Successfully set up Miniconda at ${miniconda_prefix} "
7878}
7979
80+ __handle_pyopenssl_version_issue () {
81+ # NOTE: pyOpenSSL needs to be above a certain version for PyPI publishing to
82+ # work correctly.
83+ local env_name=" $1 "
84+
85+ # shellcheck disable=SC2155
86+ local env_prefix=$( env_name_or_prefix " ${env_name} " )
87+
88+ # The pyOpenSSL and cryptography packages versions need to line up for PyPI publishing to work
89+ # https://stackoverflow.com/questions/74981558/error-updating-python3-pip-attributeerror-module-lib-has-no-attribute-openss
90+ echo " [SETUP] Upgrading pyOpenSSL ..."
91+ # shellcheck disable=SC2086
92+ (exec_with_retries 3 conda run ${env_prefix} python -m pip install " pyOpenSSL>22.1.0" ) || return 1
93+
94+ # This test fails with load errors if the pyOpenSSL and cryptography package versions don't align
95+ echo " [SETUP] Testing pyOpenSSL import ..."
96+ (test_python_import_package " ${env_name} " OpenSSL) || return 1
97+
98+ }
99+
100+ __handle_libcrypt_header_issue () {
101+ # NOTE: <crypt.h> appears to be missing, especially in Python 3.8 and under,
102+ # which results in runtime errors when `torch.compile()` is called.
103+ local env_name=" $1 "
104+
105+ # shellcheck disable=SC2155
106+ local env_prefix=$( env_name_or_prefix " ${env_name} " )
107+
108+ # https://git.sr.ht/~andir/nixpkgs/commit/4ace88d63b14ef62f24d26c984775edc2ab1737c
109+ echo " [SETUP] Installing libxcrypt ..."
110+ # shellcheck disable=SC2086
111+ (exec_with_retries 3 conda install ${env_prefix} -c conda-forge -y libxcrypt) || return 1
112+
113+ # shellcheck disable=SC2155,SC2086
114+ local conda_prefix=$( conda run ${env_prefix} printenv CONDA_PREFIX)
115+ # shellcheck disable=SC2207,SC2086
116+ local python_version=($( conda run --no-capture-output ${env_prefix} python --version) )
117+ # shellcheck disable=SC2206
118+ local python_version_arr=(${python_version[1]// ./ } )
119+
120+ # Copy the header file from include/ to include/python3.X/
121+ # https://github.com/stanford-futuredata/ColBERT/issues/309
122+ echo " [SETUP] Copying <crypt.h> over ..."
123+ # shellcheck disable=SC2206
124+ local dst_file=" ${conda_prefix} /include/python${python_version_arr[0]} .${python_version_arr[1]} /crypt.h"
125+ print_exec cp " ${conda_prefix} /include/crypt.h" " ${dst_file} "
126+ }
127+
80128create_conda_environment () {
81129 local env_name=" $1 "
82130 local python_version=" $2 "
@@ -119,15 +167,11 @@ create_conda_environment () {
119167 # shellcheck disable=SC2086
120168 (exec_with_retries 3 conda run ${env_prefix} pip install --upgrade pip) || return 1
121169
122- # The pyOpenSSL and cryptography packages versions need to line up for PyPI publishing to work
123- # https://stackoverflow.com/questions/74981558/error-updating-python3-pip-attributeerror-module-lib-has-no-attribute-openss
124- echo " [SETUP] Upgrading pyOpenSSL ..."
125- # shellcheck disable=SC2086
126- (exec_with_retries 3 conda run ${env_prefix} python -m pip install " pyOpenSSL>22.1.0" ) || return 1
170+ # Handle pyOpenSSL version issue
171+ __handle_pyopenssl_version_issue " ${env_name} "
127172
128- # This test fails with load errors if the pyOpenSSL and cryptography package versions don't align
129- echo " [SETUP] Testing pyOpenSSL import ..."
130- (test_python_import_package " ${env_name} " OpenSSL) || return 1
173+ # Handle missing <crypt.h> issue
174+ __handle_libcrypt_header_issue " ${env_name} "
131175
132176 # shellcheck disable=SC2086
133177 echo " [SETUP] Installed Python version: $( conda run ${env_prefix} python --version) "
0 commit comments