mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Allow installation of prebuilt libvips binary from filesystem (#3196)
This commit is contained in:
parent
75e5afcd42
commit
66a3ce5e55
@ -118,6 +118,8 @@ Building from source requires:
|
|||||||
|
|
||||||
This is an advanced approach that most people will not require.
|
This is an advanced approach that most people will not require.
|
||||||
|
|
||||||
|
### Prebuilt sharp binaries
|
||||||
|
|
||||||
To install the prebuilt sharp binaries from a custom URL,
|
To install the prebuilt sharp binaries from a custom URL,
|
||||||
set the `sharp_binary_host` npm config option
|
set the `sharp_binary_host` npm config option
|
||||||
or the `npm_config_sharp_binary_host` environment variable.
|
or the `npm_config_sharp_binary_host` environment variable.
|
||||||
@ -126,10 +128,16 @@ To install the prebuilt sharp binaries from a directory on the local filesystem,
|
|||||||
set the `sharp_local_prebuilds` npm config option
|
set the `sharp_local_prebuilds` npm config option
|
||||||
or the `npm_config_sharp_local_prebuilds` environment variable.
|
or the `npm_config_sharp_local_prebuilds` environment variable.
|
||||||
|
|
||||||
|
### Prebuilt libvips binaries
|
||||||
|
|
||||||
To install the prebuilt libvips binaries from a custom URL,
|
To install the prebuilt libvips binaries from a custom URL,
|
||||||
set the `sharp_libvips_binary_host` npm config option
|
set the `sharp_libvips_binary_host` npm config option
|
||||||
or the `npm_config_sharp_libvips_binary_host` environment variable.
|
or the `npm_config_sharp_libvips_binary_host` environment variable.
|
||||||
|
|
||||||
|
To install the prebuilt libvips binaries from a directory on the local filesystem,
|
||||||
|
set the `sharp_libvips_local_prebuilds` npm config option
|
||||||
|
or the `npm_config_sharp_libvips_local_prebuilds` environment variable.
|
||||||
|
|
||||||
The version subpath and file name are appended to these.
|
The version subpath and file name are appended to these.
|
||||||
For example, if `sharp_libvips_binary_host` is set to `https://hostname/path`
|
For example, if `sharp_libvips_binary_host` is set to `https://hostname/path`
|
||||||
and the libvips version is `1.2.3` then the resultant URL will be
|
and the libvips version is `1.2.3` then the resultant URL will be
|
||||||
|
@ -35,6 +35,7 @@ const hasSharpPrebuild = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
const { minimumLibvipsVersion, minimumLibvipsVersionLabelled } = libvips;
|
const { minimumLibvipsVersion, minimumLibvipsVersionLabelled } = libvips;
|
||||||
|
const localLibvipsDir = process.env.npm_config_sharp_libvips_local_prebuilds || '';
|
||||||
const distHost = process.env.npm_config_sharp_libvips_binary_host || 'https://github.com/lovell/sharp-libvips/releases/download';
|
const distHost = process.env.npm_config_sharp_libvips_binary_host || 'https://github.com/lovell/sharp-libvips/releases/download';
|
||||||
const distBaseUrl = process.env.npm_config_sharp_dist_base_url || process.env.SHARP_DIST_BASE_URL || `${distHost}/v${minimumLibvipsVersionLabelled}/`;
|
const distBaseUrl = process.env.npm_config_sharp_dist_base_url || process.env.SHARP_DIST_BASE_URL || `${distHost}/v${minimumLibvipsVersionLabelled}/`;
|
||||||
const installationForced = !!(process.env.npm_config_sharp_install_force || process.env.SHARP_INSTALL_FORCE);
|
const installationForced = !!(process.env.npm_config_sharp_install_force || process.env.SHARP_INSTALL_FORCE);
|
||||||
@ -156,6 +157,11 @@ try {
|
|||||||
if (fs.existsSync(tarPathCache)) {
|
if (fs.existsSync(tarPathCache)) {
|
||||||
libvips.log(`Using cached ${tarPathCache}`);
|
libvips.log(`Using cached ${tarPathCache}`);
|
||||||
extractTarball(tarPathCache, platformAndArch);
|
extractTarball(tarPathCache, platformAndArch);
|
||||||
|
} else if (localLibvipsDir) {
|
||||||
|
// If localLibvipsDir is given try to use binaries from local directory
|
||||||
|
const tarPathLocal = path.join(path.resolve(localLibvipsDir), `v${minimumLibvipsVersionLabelled}`, tarFilename);
|
||||||
|
libvips.log(`Using local libvips from ${tarPathLocal}`);
|
||||||
|
extractTarball(tarPathLocal, platformAndArch);
|
||||||
} else {
|
} else {
|
||||||
const url = distBaseUrl + tarFilename;
|
const url = distBaseUrl + tarFilename;
|
||||||
libvips.log(`Downloading ${url}`);
|
libvips.log(`Downloading ${url}`);
|
||||||
|
@ -82,7 +82,8 @@
|
|||||||
"Joris Dugué <zaruike10@gmail.com>",
|
"Joris Dugué <zaruike10@gmail.com>",
|
||||||
"Chris Banks <christopher.bradley.banks@gmail.com>",
|
"Chris Banks <christopher.bradley.banks@gmail.com>",
|
||||||
"Ompal Singh <ompal.hitm09@gmail.com>",
|
"Ompal Singh <ompal.hitm09@gmail.com>",
|
||||||
"Brodan <christopher.hranj@gmail.com"
|
"Brodan <christopher.hranj@gmail.com",
|
||||||
|
"Ankur Parihar <ankur.github@gmail.com>"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"install": "(node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)",
|
"install": "(node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user