lib/configure.js
function checkExecPath (execPath, errorCallback) {
    this.log.verbose(`- executing "${execPath}" to get version`)
    this.run(execPath, this.argsVersion, false, function (err, version) {
      // Possible outcomes:
      // - Error: executable can not be run (likely meaning the command wasn't
      //   a Python executable and the previous command produced gibberish)
      // - Gibberish: somehow the last command produced an executable path,
      //   this will fail when verifying the version
      // - Version of the Python executable
      if (err) {
        this.addLog(`- "${execPath}" could not be run`)
        return errorCallback(err)
      }
      this.addLog(`- version is "${version}"`)

      const range = semver.Range(this.semverRange)
      var valid = false
      try {
        valid = range.test(version)
      } catch (err) {
        this.log.silly('range.test() threw:\n%s', err.stack)
        this.addLog(`- "${execPath}" does not have a valid version`)
        this.addLog('- is it a Python executable?')
        return errorCallback(err)
      }

      if (!valid) {
        this.addLog(`- version is ${version} - should be ${this.semverRange}`)
        this.addLog('- THIS VERSION OF PYTHON IS NOT SUPPORTED')
        return errorCallback(new Error(
          `Found unsupported Python version ${version}`))
      }
      this.succeed(execPath, version)
    }.bind(this))
  }
function checkExecPath (execPath, errorCallback) {
    this.log.verbose(`- executing "${execPath}" to get version`)
    this.run(execPath, this.argsVersion, false, function (err, version) {
      // Possible outcomes:
      // - Error: executable can not be run (likely meaning the command wasn't
      //   a Python executable and the previous command produced gibberish)
      // - Gibberish: somehow the last command produced an executable path,
      //   this will fail when verifying the version
      // - Version of the Python executable
      if (err) {
        this.addLog(`- "${execPath}" could not be run`)
        return errorCallback(err)
      }
      this.addLog(`- version is "${version}"`)

      const range = semver.Range(this.semverRange)
      var valid = false
      try {
        valid = range.test(version)
      } catch (err) {
        this.log.silly('range.test() threw:\n%s', err.stack)
        this.addLog(`- "${execPath}" does not have a valid version`)
        this.addLog('- is it a Python executable?')
        return errorCallback(err)
      }

      if (!valid) {
        this.addLog(`- version is ${version} - should be ${this.semverRange}`)
        this.addLog('- THIS VERSION OF PYTHON IS NOT SUPPORTED')
        return errorCallback(new Error(
          `Found unsupported Python version ${version}`))
      }
      this.succeed(execPath, version)
    }.bind(this))
  }
function checkExecPath ( execPath , errorCallback ) { this . log . verbose ( ` ${ execPath } ` ) this . run ( execPath , this . argsVersion , false , function ( err , version ) { // Possible outcomes: // - Error: executable can not be run (likely meaning the command wasn't //   a Python executable and the previous command produced gibberish) // - Gibberish: somehow the last command produced an executable path, //   this will fail when verifying the version // - Version of the Python executable if ( err ) { this . addLog ( ` ${ execPath } ` ) return errorCallback ( err ) } this . addLog ( ` ${ version } ` ) const range = semver . Range ( this . semverRange ) var valid = false try { valid = range . test ( version ) } catch ( err ) { this . log . silly ( 'range.test() threw:\n%s' , err . stack ) this . addLog ( ` ${ execPath } ` ) this . addLog ( '- is it a Python executable?' ) return errorCallback ( err ) } if ( ! valid ) { this . addLog ( ` ${ version } ${ this . semverRange } ` ) this . addLog ( '- THIS VERSION OF PYTHON IS NOT SUPPORTED' ) return errorCallback ( new Error ( ` ${ version } ` ) ) } this . succeed ( execPath , version ) } . bind ( this ) ) }
Check if a Python executable is the correct version to use. Will exit the Python finder on success.
Check if a Python executable is the correct version to use . Will exit the Python finder on success .