--- a/Modules/_hashopenssl.c
+++ b/Modules/_hashopenssl.c
@@ -48,7 +48,9 @@
 #define PY_OPENSSL_HAS_SCRYPT 1
 #define PY_OPENSSL_HAS_SHA3 1
 #define PY_OPENSSL_HAS_SHAKE 1
+#ifndef OPENSSL_NO_BLAKE2
 #define PY_OPENSSL_HAS_BLAKE2 1
+#endif
 
 #if OPENSSL_VERSION_NUMBER >= 0x30000000L
 #define PY_EVP_MD EVP_MD
