From ef6b1232b43882503b6fb58e4249148f9435ce50 Mon Sep 17 00:00:00 2001 From: yunnysunny Date: Sat, 4 Jul 2020 23:08:11 +0800 Subject: [PATCH 1/4] Read the download url of librdkafka from Windows environment variable --- README.md | 3 ++- deps/windows-install.py | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 484e345b..e2cdddf8 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,8 @@ Using Alpine Linux? Check out the [docs](https://github.com/Blizzard/node-rdkafk Windows build **is not** compiled from `librdkafka` source but it is rather linked against appropriate version of static binary that gets downloaded from [librdkafka.redist NuGet package](https://www.nuget.org/packages/librdkafka.redist/) during installation. Requirements: - * [node-gyp for Windows](https://github.com/nodejs/node-gyp#on-windows) (the easies way to get it: `npm install --global --production windows-build-tools`, if your node version is 6.x or below, pleasse use `npm install --global --production windows-build-tools@3.1.0`) + * [node-gyp for Windows](https://github.com/nodejs/node-gyp#on-windows) (the easies way to get it: `npm install --global --production windows-build-tools`. + * The setting of environment variable of `DOWNLOAD_BASE_URL_LIB_RDKAFKA` is optional. If you set it, the builder will download the library of `librdkafka` from `${DOWNLOAD_BASE_URL_LIB_RDKAFKA}librdkafka.redist.${librdkafka-version-from-package.json}.nupkg`. **Note:** I _still_ do not recommend using `node-rdkafka` in production on Windows. This feature was in high demand and is provided to help develop, but we do not test against Windows, and windows support may lag behind Linux/Mac support because those platforms are the ones used to develop this library. Contributors are welcome if any Windows issues are found :) diff --git a/deps/windows-install.py b/deps/windows-install.py index 16f9c1b5..c7781938 100644 --- a/deps/windows-install.py +++ b/deps/windows-install.py @@ -1,6 +1,7 @@ librdkafkaVersion = '' # read librdkafka version from package.json import json +import os with open('../package.json') as f: librdkafkaVersion = json.load(f)['librdkafka'] librdkafkaWinSufix = '7' if librdkafkaVersion == '0.11.5' else ''; @@ -10,7 +11,10 @@ buildReleaseDir = 'Release' # alternative: 'https://api.nuget.org/v3-flatcontainer/librdkafka.redist/{}/librdkafka.redist.{}.nupkg'.format(librdkafkaVersion, librdkafkaVersion) -librdkafkaNugetUrl = 'https://www.nuget.org/api/v2/package/librdkafka.redist/{}'.format(librdkafkaVersion) +env_dist = os.environ +downloadBaseUrl = env_dist['DOWNLOAD_BASE_URL_LIB_RDKAFKA'] if 'DOWNLOAD_BASE_URL_LIB_RDKAFKA' in env_dist else 'https://globalcdn.nuget.org/packages/' +librdkafkaNugetUrl = downloadBaseUrl + 'librdkafka.redist.{}.nupkg'.format(librdkafkaVersion) +print 'download librdkafka form ' + librdkafkaNugetUrl outputDir = 'librdkafka.redist' outputFile = outputDir + '.zip' dllPath = outputDir + '/runtimes/win{}-x64/native'.format(librdkafkaWinSufix) From 69ded1b7a6bb8ef73374150a470e751f99383089 Mon Sep 17 00:00:00 2001 From: yunnysunny Date: Mon, 17 Aug 2020 21:20:51 +0800 Subject: [PATCH 2/4] Change the name of DOWNLOAD_BASE_URL_LIB_RDKAFKA to BUILD_LIBRDKAFKA --- README.md | 2 +- deps/windows-install.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e2cdddf8..9d8caf77 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ Windows build **is not** compiled from `librdkafka` source but it is rather link Requirements: * [node-gyp for Windows](https://github.com/nodejs/node-gyp#on-windows) (the easies way to get it: `npm install --global --production windows-build-tools`. - * The setting of environment variable of `DOWNLOAD_BASE_URL_LIB_RDKAFKA` is optional. If you set it, the builder will download the library of `librdkafka` from `${DOWNLOAD_BASE_URL_LIB_RDKAFKA}librdkafka.redist.${librdkafka-version-from-package.json}.nupkg`. + * The setting of environment variable of `BUILD_LIBRDKAFKA` is optional. If you set it, the builder will download the library of `librdkafka` from `${BUILD_LIBRDKAFKA}librdkafka.redist.${librdkafka-version-from-package.json}.nupkg`. **Note:** I _still_ do not recommend using `node-rdkafka` in production on Windows. This feature was in high demand and is provided to help develop, but we do not test against Windows, and windows support may lag behind Linux/Mac support because those platforms are the ones used to develop this library. Contributors are welcome if any Windows issues are found :) diff --git a/deps/windows-install.py b/deps/windows-install.py index c7781938..45606afa 100644 --- a/deps/windows-install.py +++ b/deps/windows-install.py @@ -12,7 +12,7 @@ # alternative: 'https://api.nuget.org/v3-flatcontainer/librdkafka.redist/{}/librdkafka.redist.{}.nupkg'.format(librdkafkaVersion, librdkafkaVersion) env_dist = os.environ -downloadBaseUrl = env_dist['DOWNLOAD_BASE_URL_LIB_RDKAFKA'] if 'DOWNLOAD_BASE_URL_LIB_RDKAFKA' in env_dist else 'https://globalcdn.nuget.org/packages/' +downloadBaseUrl = env_dist['BUILD_LIBRDKAFKA'] if 'BUILD_LIBRDKAFKA' in env_dist else 'https://globalcdn.nuget.org/packages/' librdkafkaNugetUrl = downloadBaseUrl + 'librdkafka.redist.{}.nupkg'.format(librdkafkaVersion) print 'download librdkafka form ' + librdkafkaNugetUrl outputDir = 'librdkafka.redist' From fd8a0e26ce6bfb99585f67862f1301a273af8764 Mon Sep 17 00:00:00 2001 From: yunnysunny Date: Mon, 31 Aug 2020 14:12:27 +0800 Subject: [PATCH 3/4] Rename the env name of BUILD_LIBRDKAFKA to NODE_RDKAFKA_NUGET_BASE_URL in windows-install.py --- README.md | 1 - deps/windows-install.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 9d8caf77..62ced124 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,6 @@ Windows build **is not** compiled from `librdkafka` source but it is rather link Requirements: * [node-gyp for Windows](https://github.com/nodejs/node-gyp#on-windows) (the easies way to get it: `npm install --global --production windows-build-tools`. - * The setting of environment variable of `BUILD_LIBRDKAFKA` is optional. If you set it, the builder will download the library of `librdkafka` from `${BUILD_LIBRDKAFKA}librdkafka.redist.${librdkafka-version-from-package.json}.nupkg`. **Note:** I _still_ do not recommend using `node-rdkafka` in production on Windows. This feature was in high demand and is provided to help develop, but we do not test against Windows, and windows support may lag behind Linux/Mac support because those platforms are the ones used to develop this library. Contributors are welcome if any Windows issues are found :) diff --git a/deps/windows-install.py b/deps/windows-install.py index 45606afa..e5c212e1 100644 --- a/deps/windows-install.py +++ b/deps/windows-install.py @@ -12,7 +12,7 @@ # alternative: 'https://api.nuget.org/v3-flatcontainer/librdkafka.redist/{}/librdkafka.redist.{}.nupkg'.format(librdkafkaVersion, librdkafkaVersion) env_dist = os.environ -downloadBaseUrl = env_dist['BUILD_LIBRDKAFKA'] if 'BUILD_LIBRDKAFKA' in env_dist else 'https://globalcdn.nuget.org/packages/' +downloadBaseUrl = env_dist['NODE_RDKAFKA_NUGET_BASE_URL'] if 'NODE_RDKAFKA_NUGET_BASE_URL' in env_dist else 'https://globalcdn.nuget.org/packages/' librdkafkaNugetUrl = downloadBaseUrl + 'librdkafka.redist.{}.nupkg'.format(librdkafkaVersion) print 'download librdkafka form ' + librdkafkaNugetUrl outputDir = 'librdkafka.redist' From e6fd8f817ec770a37727d96bf503cba6c9966bee Mon Sep 17 00:00:00 2001 From: yunnysunny Date: Wed, 2 Sep 2020 19:22:01 +0800 Subject: [PATCH 4/4] Recovery readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 62ced124..484e345b 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ Using Alpine Linux? Check out the [docs](https://github.com/Blizzard/node-rdkafk Windows build **is not** compiled from `librdkafka` source but it is rather linked against appropriate version of static binary that gets downloaded from [librdkafka.redist NuGet package](https://www.nuget.org/packages/librdkafka.redist/) during installation. Requirements: - * [node-gyp for Windows](https://github.com/nodejs/node-gyp#on-windows) (the easies way to get it: `npm install --global --production windows-build-tools`. + * [node-gyp for Windows](https://github.com/nodejs/node-gyp#on-windows) (the easies way to get it: `npm install --global --production windows-build-tools`, if your node version is 6.x or below, pleasse use `npm install --global --production windows-build-tools@3.1.0`) **Note:** I _still_ do not recommend using `node-rdkafka` in production on Windows. This feature was in high demand and is provided to help develop, but we do not test against Windows, and windows support may lag behind Linux/Mac support because those platforms are the ones used to develop this library. Contributors are welcome if any Windows issues are found :)