Skip to content

Using Python 3 for code bash script#141749

Closed
fishcharlie wants to merge 1 commit intomicrosoft:mainfrom
fishcharlie:issue141738
Closed

Using Python 3 for code bash script#141749
fishcharlie wants to merge 1 commit intomicrosoft:mainfrom
fishcharlie:issue141738

Conversation

@fishcharlie
Copy link
Copy Markdown

General

This PR changes the code bash script to use python3 instead of python.

Few questions that I don't know the answers to:

  • How will this impact existing users? Will they need to rerun the install bash script? Should this be a process that happens automatically on app launch or something?
  • Python 3 no longer comes bundled with macOS 12.3, instead it's bundled with the Xcode Developer Tools. Apple recommends bundling Python 3 directly within your application if it is required. Is this something we should consider? Or is it a safe assumption that all VS Code users will have Xcode Developer Tools installed?

This PR fixes #141738

@timsutton
Copy link
Copy Markdown

Python 3 no longer comes bundled with macOS 12.3

It never did: Python3 was always only installed via either Command-Line Developer Tools or Xcode. What is going away in 12.3 is the Python 2 framework and its executables one could always find in /usr/bin.

Apple recommends bundling Python 3 directly within your application if it is required.

That seems like a complicated dependency to pull in if it isn't otherwise needed, especially for a multi-platform project.

Or is it a safe assumption that all VS Code users will have Xcode Developer Tools installed?

Homebrew does currently install Command-Line Tools automatically during its installation, however I'm not sure it's a reasonable assumption that all VSCode users on macOS have or use Homebrew.

Zsh does have a shorthand for realpath, however /bin/zsh is present on macOS only starting with Catalina (10.15). A couple options I might propose:

  1. Replace the python usage with something written only with existing bash 3.2 builtins.
  2. Shell out to /usr/bin/perl to use some form of realpath, since Perl is still a thing bundled in macOS. Apple still depends on Perl in some core OS tools, and shared tooling baked into many of their installer packages. So, it seems less likely to be going away in the immediate future.

@haykam821
Copy link
Copy Markdown
Contributor

haykam821 commented Jan 30, 2022

GitHub Desktop has this same problem as well for its github CLI. An unmerged pull request, desktop/desktop#13764, uses Perl to fix the problem.

It seems like GitHub Desktop introduced its CLI in desktop/desktop@65af5e0 based off of VS Code's be4a1ef, so if the Perl approach is used, this would possibly a case of GitHub Desktop contributing a fix upstream (in a sense!).

@fishcharlie
Copy link
Copy Markdown
Author

Shell out to /usr/bin/perl to use some form of realpath, since Perl is still a thing bundled in macOS. Apple still depends on Perl in some core OS tools, and shared tooling baked into many of their installer packages. So, it seems less likely to be going away in the immediate future.

@timsutton @haykam821

I will note in Apple's 10.15 release notes it states:

Scripting language runtimes such as Python, Ruby, and Perl are included in macOS for compatibility with legacy software. Future versions of macOS won’t include scripting language runtimes by default, and might require you to install additional packages. If your software depends on scripting languages, it’s recommended that you bundle the runtime within the app. (49764202)

So even if Apple depends on Perl currently, it's very likely to face the same fate as Python at some point.


I will note that in my issue I created @bpasero linked to #138582.

Should we close this as a duplicate of #138582?

@deepak1556
Copy link
Copy Markdown
Collaborator

Merging to #141749, thanks for the PR!

@deepak1556 deepak1556 closed this Jan 31, 2022
@fishcharlie
Copy link
Copy Markdown
Author

Merging to #141749, thanks for the PR!

@deepak1556 Think you meant #138582?

@fishcharlie fishcharlie deleted the issue141738 branch January 31, 2022 14:26
@github-actions github-actions bot locked and limited conversation to collaborators Mar 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

macOS 12.3 code shell command doesn't work due to Python 2 being removed

6 participants