Skip to content

Commit

Permalink
Build and test with openssl 1.1 on windows
Browse files Browse the repository at this point in the history
Porting to openssl 1.1 by Matthew Brett, from the psycopg2-wheel repos.
  • Loading branch information
dvarrazzo committed Apr 10, 2019
1 parent 5e01c47 commit 72fe91c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 19 deletions.
24 changes: 8 additions & 16 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ environment:
- {PYVER: "34", PYTHON_ARCH: "32"}
- {PYVER: "34", PYTHON_ARCH: "64"}

OPENSSL_VERSION: "1_0_2r"
OPENSSL_VERSION: "1_1_1b"
POSTGRES_VERSION: "11_2"

PSYCOPG2_TESTDB: psycopg2_test
Expand Down Expand Up @@ -135,11 +135,9 @@ install:
If ($env:PYTHON_ARCH -Match "32" ) {
$env:VCVARS_PLATFORM="x86"
$env:TARGET="VC-WIN32"
$env:DO="do_ms"
} Else {
$env:VCVARS_PLATFORM="amd64"
$env:TARGET="VC-WIN64A"
$env:DO="do_win64a"
$env:CPU="AMD64"
}
# Download OpenSSL source
Expand All @@ -148,22 +146,12 @@ install:
curl -fsSL -o OpenSSL_%OPENSSL_VERSION%.zip https://github.com/openssl/openssl/archive/OpenSSL_%OPENSSL_VERSION%.zip
)

# To use OpenSSL >= 1.1.0, both libpq and psycopg build environments have
# to support the new library names. Below are commands to build OpenSSL
# 1.1.0:
# - mkdir _build
# - cd _build
# - perl ..\Configure %TARGET% no-asm no-shared --prefix=%BASE_DIR%\openssl --openssldir=%BASE_DIR%\openssl
# - nmake build_libs install_dev
- IF NOT EXIST %OPENSSLTOP%\lib\ssleay32.lib (
- IF NOT EXIST %OPENSSLTOP%\lib\libssl.lib (
CD %BUILD_DIR% &&
7z x C:\Others\OpenSSL_%OPENSSL_VERSION%.zip &&
CD openssl-OpenSSL_%OPENSSL_VERSION% &&
perl Configure %TARGET% no-asm no-shared no-zlib --prefix=%OPENSSLTOP% --openssldir=%OPENSSLTOP% &&
CALL ms\%DO% &&
nmake -f ms\nt.mak init headers lib &&
COPY inc32\openssl\*.h %OPENSSLTOP%\include\openssl &&
COPY out32\*.lib %OPENSSLTOP%\lib &&
nmake build_libs install_dev &&
CD %BASE_DIR% &&
RMDIR /S /Q %BUILD_DIR%\openssl-OpenSSL_%OPENSSL_VERSION%
)
Expand All @@ -190,12 +178,16 @@ install:
# Copy over built libraries
# Prepare local include directory for building from
# Build pg_config in place
# Note patch for OpenSSL 1.1 configuration. See:
# https://www.postgresql-archive.org/Compile-psql-9-6-with-SSL-Version-1-1-0-td6054118.html
# NOTE: Cannot set and use the same variable inside an IF
- SET PGBUILD=%BUILD_DIR%\postgres-REL_%POSTGRES_VERSION%
- IF NOT EXIST %PGTOP%\lib\libpq.lib (
CD %BUILD_DIR% &&
7z x C:\Others\postgres-REL_%POSTGRES_VERSION%.zip &&
CD postgres-REL_%POSTGRES_VERSION%\src\tools\msvc &&
CD postgres-REL_%POSTGRES_VERSION% &&
patch -p1 < %APPVEYOR_BUILD_FOLDER%\scripts\win_openssl_11.patch &&
CD src\tools\msvc &&
ECHO $config-^>{ldap} = 0; > config.pl &&
ECHO $config-^>{openssl} = "%OPENSSLTOP:\=\\%"; >> config.pl &&
ECHO.>> config.pl &&
Expand Down
2 changes: 1 addition & 1 deletion scripts/appveyor.cache_rebuild
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ To invalidate the cache, update this file and check it into git.
Currently used modules built in the cache:

OpenSSL
Version: 1.0.2r
Version: 1.1.1b

PostgreSQL
Version: 11.2
Expand Down
20 changes: 20 additions & 0 deletions scripts/win_openssl_11.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/src/include/pg_config.h.win32 b/src/include/pg_config.h.win32
index dfd6972383..72d1259ffb 100644
--- a/src/include/pg_config.h.win32
+++ b/src/include/pg_config.h.win32
@@ -74,12 +74,15 @@

/* Define to 1 if you have the `ASN1_STRING_get0_data' function. */
/* #undef HAVE_ASN1_STRING_GET0_DATA */
+#define HAVE_ASN1_STRING_GET0_DATA 1

/* Define to 1 if you have the `BIO_get_data' function. */
/* #undef HAVE_BIO_GET_DATA */
+#define HAVE_BIO_GET_DATA 1

/* Define to 1 if you have the `BIO_meth_new' function. */
/* #undef HAVE_BIO_METH_NEW */
+#define HAVE_BIO_METH_NEW 1

/* Define to 1 if you have the `cbrt' function. */
//#define HAVE_CBRT 1
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,8 @@ def finalize_win32(self):
self.library_dirs.append(os.path.join(path, "ms"))
break
if self.have_ssl:
self.libraries.append("libeay32")
self.libraries.append("ssleay32")
self.libraries.append("libcrypto")
self.libraries.append("libssl")
self.libraries.append("crypt32")
self.libraries.append("user32")
self.libraries.append("gdi32")
Expand Down

0 comments on commit 72fe91c

Please sign in to comment.