Skip to content

Change shebang of validation script to python, because python3 is not installed on Windows #7764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

Cjkjvfnby
Copy link
Contributor

Describe your change:

When I run pre-commit run --all files I got an error.

Validate filenames.......................................................Failed
- hook id: validate-filenames
- exit code: 9009

This error happens because the python3 executable is not found.

I have a Windows machine and just installed the latest Python via the official installer. Python3 alias is not included.

It was a time when using python2 and python3 aliases was important, but now python2 is not used anymore so it should not be a problem.

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

@algorithms-keeper algorithms-keeper bot added enhancement This PR modified some existing files awaiting reviews This PR is ready to be reviewed labels Oct 27, 2022
@algorithms-keeper algorithms-keeper bot mentioned this pull request Oct 27, 2022
14 tasks
@cclauss
Copy link
Member

cclauss commented Oct 28, 2022

Does Windows use shebang files?!?

On my Mac... python --version

zsh: command not found: python

This can be fixed by adding a venv but that is the default behavior.

@Cjkjvfnby
Copy link
Contributor Author

Does Windows use shebang files?!?

It uses the associated program by an extension. When Python is installed, py is associated with it.
py is a switcher between installed Pythons, and it respects the shebang. https://docs.python.org/3/using/windows.html#python-launcher-for-windows

On my Mac... python --version

On my Mac I use pyenv, I have both python and python3. But not sure that my installation could be considered typical.

Docker image python:3.9.10 also supports python

I'll check if I could fix it on my Win machine with py.ini. If it will work I'll post the solution here and close the PR. Other users will be able to find this problem by searching.

@cclauss
Copy link
Member

cclauss commented Oct 28, 2022

Funny because, I use py on my Mac and earlier today I opened and then closed brettcannon/python-launcher#235

@Cjkjvfnby
Copy link
Contributor Author

In my case, it's py from cPython. According to docs and my experiments python3 and /usr/bin/env python are supported and /usr/bin/env python3 is not. I Will resubmit the issue there.

I haven't found any workaround yet.

@Cjkjvfnby Cjkjvfnby closed this Oct 28, 2022
@Cjkjvfnby Cjkjvfnby deleted the fix-pre-commit-on-windows branch November 5, 2022 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants