From 72fe91c02ef06f8de5a1090f66c7da614941ed7d Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Wed, 10 Apr 2019 23:46:05 +0100 Subject: [PATCH 1/2] Build and test with openssl 1.1 on windows Porting to openssl 1.1 by Matthew Brett, from the psycopg2-wheel repos. --- .appveyor.yml | 24 ++++++++---------------- scripts/appveyor.cache_rebuild | 2 +- scripts/win_openssl_11.patch | 20 ++++++++++++++++++++ setup.py | 4 ++-- 4 files changed, 31 insertions(+), 19 deletions(-) create mode 100644 scripts/win_openssl_11.patch diff --git a/.appveyor.yml b/.appveyor.yml index 54a71ab5..81515e40 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -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 @@ -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 @@ -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% ) @@ -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 && diff --git a/scripts/appveyor.cache_rebuild b/scripts/appveyor.cache_rebuild index 28cd082c..c09e36d0 100644 --- a/scripts/appveyor.cache_rebuild +++ b/scripts/appveyor.cache_rebuild @@ -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 diff --git a/scripts/win_openssl_11.patch b/scripts/win_openssl_11.patch new file mode 100644 index 00000000..57d0bd81 --- /dev/null +++ b/scripts/win_openssl_11.patch @@ -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 diff --git a/setup.py b/setup.py index 660d0c9a..d5eac11d 100644 --- a/setup.py +++ b/setup.py @@ -366,8 +366,8 @@ For further information please check the 'doc/src/install.rst' file (also at 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") From 26b61e809fffffc4f7c27ebde546f91902dfea80 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Thu, 11 Apr 2019 01:42:54 +0100 Subject: [PATCH 2/2] Mention building openssl 1.1 on windows in news file Close #836. --- NEWS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/NEWS b/NEWS index 49beb151..797359b0 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,13 @@ Current release --------------- +What's new in psycopg 2.8.2 +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- Window packages built with openssl 1.1.1b. Should fix concurrency problems + (:ticket:`#836`). + + What's new in psycopg 2.8.1 ^^^^^^^^^^^^^^^^^^^^^^^^^^^