Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

[wip] Improve Python 2 detection #775

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -5,3 +5,4 @@
npm-debug.log
*~
*.pyc
.python2-bin
4 changes: 2 additions & 2 deletions bin/python-interceptor.sh
Original file line number Diff line number Diff line change
@@ -34,9 +34,9 @@ case $1 in
ARGS+=("--format=safemake.py")
fi

exec python "${ARGS[@]}"
exec "${ATOM_APM_ORIGINAL_PYTHON:-python}" "${ARGS[@]}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could swear I've fixed this before...

;;
*)
exec python "$@"
exec "${ATOM_APM_ORIGINAL_PYTHON:-python}" "$@"
;;
esac
5,035 changes: 2,945 additions & 2,090 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@
"check-version": "node version.js"
},
"dependencies": {
"@atom/dowsing-rod": "^1.1.0",
"asar-require": "0.3.0",
"async": "~0.2.8",
"colors": "~0.6.1",
@@ -32,8 +33,8 @@
"keytar": "^4.0",
"mv": "2.0.0",
"ncp": "~0.5.1",
"npm": "3.10.10",
"node-gyp": "3.4.0",
"npm": "3.10.10",
"open": "0.0.4",
"plist": "git+https://github.com/nathansobo/node-plist.git",
"q": "~0.9.7",
7 changes: 7 additions & 0 deletions script/postinstall.js
Original file line number Diff line number Diff line change
@@ -10,3 +10,10 @@ if (process.platform.indexOf('win') === 0) {
var child = cp.spawn(script, [], { stdio: ['pipe', 'pipe', 'pipe'], shell: true })
child.stderr.pipe(process.stderr)
child.stdout.pipe(process.stdout)
child.on('error', err => {
console.error(err)
process.exit(1)
})
child.on('exit', code => {
process.exit(code !== null ? code : 1)
})
17 changes: 12 additions & 5 deletions src/dedupe.coffee
Original file line number Diff line number Diff line change
@@ -31,6 +31,12 @@ class Dedupe extends Command
"""
options.alias('h', 'help').describe('help', 'Print this usage message')

setPythonEnv: (callback) ->
options =
npmBin: require.resolve('npm/bin/npm-cli')
pythonBinFile: path.join(@atomDirectory, 'python2bin')
dowsingRod.setPythonEnv(options, process.env).then(callback)

installNode: (callback) ->
installNodeArgs = ['install']
installNodeArgs.push("--runtime=electron")
@@ -54,11 +60,12 @@ class Dedupe extends Command
proxy = npm.config.get('https-proxy') or npm.config.get('proxy') or env.HTTPS_PROXY or env.HTTP_PROXY
installNodeArgs.push("--proxy=#{proxy}") if proxy

@fork @atomNodeGypPath, installNodeArgs, {env, cwd: @atomDirectory}, (code, stderr='', stdout='') ->
if code is 0
callback()
else
callback("#{stdout}\n#{stderr}")
@setPythonEnv =>
@fork @atomNodeGypPath, installNodeArgs, {env, cwd: @atomDirectory}, (code, stderr='', stdout='') ->
if code is 0
callback()
else
callback("#{stdout}\n#{stderr}")

getVisualStudioFlags: ->
if vsVersion = config.getInstalledVisualStudioFlag()
13 changes: 11 additions & 2 deletions src/install.coffee
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ Git = require 'git-utils'
semver = require 'semver'
temp = require 'temp'
hostedGitInfo = require 'hosted-git-info'
dowsingRod = require '@atom/dowsing-rod'

config = require './apm'
Command = require './command'
@@ -607,6 +608,12 @@ class Install extends Command
catch err
callback(err)

setPythonEnv: (callback) ->
options =
npmBin: require.resolve('npm/bin/npm-cli')
pythonBinFile: path.join(@atomDirectory, 'python2bin')
dowsingRod.setPythonEnv(options, process.env).then(callback)

run: (options) ->
{callback} = options
options = @parseOptions(options.commandArgs)
@@ -616,8 +623,9 @@ class Install extends Command

if options.argv.check
config.loadNpm (error, @npm) =>
@loadInstalledAtomMetadata =>
@checkNativeBuildTools(callback)
@setPythonEnv =>
@loadInstalledAtomMetadata =>
@checkNativeBuildTools(callback)
return

@verbose = options.argv.verbose
@@ -658,6 +666,7 @@ class Install extends Command

commands = []
commands.push (callback) => config.loadNpm (error, @npm) => callback(error)
commands.push (callback) => @setPythonEnv -> callback()
commands.push (callback) => @loadInstalledAtomMetadata -> callback()
packageNames.forEach (packageName) ->
commands.push (callback) -> installPackage(packageName, callback)