@@ -4,8 +4,6 @@ import { certbot as logger } from "../logger.js";
44import errs from "./error.js" ;
55import utils from "./utils.js" ;
66
7- const CERTBOT_VERSION_REPLACEMENT = "$(certbot --version | grep -Eo '[0-9](\\.[0-9]+)+')" ;
8-
97/**
108 * Installs a cerbot plugin given the key for the object from
119 * ../certbot/dns-plugins.json
@@ -15,24 +13,32 @@ const CERTBOT_VERSION_REPLACEMENT = "$(certbot --version | grep -Eo '[0-9](\\.[0
1513 */
1614const installPlugin = async ( pluginKey ) => {
1715 if ( typeof dnsPlugins [ pluginKey ] === "undefined" ) {
18- // throw Error(`Certbot plugin ${pluginKey} not found`);
1916 throw new errs . ItemNotFoundError ( pluginKey ) ;
2017 }
2118
2219 const plugin = dnsPlugins [ pluginKey ] ;
2320 logger . start ( `Installing ${ pluginKey } ...` ) ;
2421
25- plugin . version = plugin . version . replace ( / { { certbot-v e r s i o n } } / g, CERTBOT_VERSION_REPLACEMENT ) ;
26- plugin . dependencies = plugin . dependencies . replace ( / { { certbot-v e r s i o n } } / g, CERTBOT_VERSION_REPLACEMENT ) ;
22+ plugin . version = plugin . version . replace ( / { { certbot-v e r s i o n } } / g, process . env . CERTBOT_VERSION ) ;
23+ plugin . dependencies = plugin . dependencies . replace ( / { { certbot-v e r s i o n } } / g, process . env . CERTBOT_VERSION ) ;
2724
28- // SETUPTOOLS_USE_DISTUTILS is required for certbot plugins to install correctly
29- // in new versions of Python
30- let env = Object . assign ( { } , process . env , { SETUPTOOLS_USE_DISTUTILS : "stdlib " } ) ;
25+ // SETUPTOOLS_USE_DISTUTILS=local uses setuptools' own bundled distutils.
26+ // "stdlib" breaks Python 3.13+ where distutils was removed from the standard library.
27+ let env = Object . assign ( { } , process . env , { SETUPTOOLS_USE_DISTUTILS : "local " } ) ;
3128 if ( typeof plugin . env === "object" ) {
3229 env = Object . assign ( env , plugin . env ) ;
3330 }
3431
35- const cmd = `. /opt/certbot/bin/activate && pip install --no-cache-dir ${ plugin . dependencies } ${ plugin . package_name } ${ plugin . version } && deactivate` ;
32+ const quotedDeps = plugin . dependencies . trim ( )
33+ ? plugin . dependencies
34+ . trim ( )
35+ . split ( / \s + / )
36+ . filter ( Boolean )
37+ . map ( ( d ) => `'${ d } '` )
38+ . join ( " " )
39+ : "" ;
40+
41+ const cmd = `. /opt/certbot/bin/activate && pip install --no-cache-dir ${ quotedDeps } '${ plugin . package_name } ${ plugin . version } ' && deactivate` ;
3642 return utils
3743 . exec ( cmd , { env } )
3844 . then ( ( result ) => {
@@ -73,14 +79,12 @@ const installPlugins = async (pluginKeys) => {
7379 } )
7480 . end ( ( ) => {
7581 if ( hasErrors ) {
76- reject (
77- new errs . CommandError ( "Some plugins failed to install. Please check the logs above" , 1 ) ,
78- ) ;
82+ reject ( new errs . CommandError ( "Some plugins failed to install. Please check the logs above" , 1 ) ) ;
7983 } else {
8084 resolve ( ) ;
8185 }
8286 } ) ;
8387 } ) ;
8488} ;
8589
86- export { installPlugins , installPlugin } ;
90+ export { installPlugin , installPlugins } ;
0 commit comments