Skip to content
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

Making it work with macOS Monterey 12.3 -- which has python2 removed and supports only python3 #65

Open
himanshubabal opened this issue Feb 10, 2022 · 3 comments

Comments

@himanshubabal
Copy link

himanshubabal commented Feb 10, 2022

I had trouble making this work on M1 Macbook with macOS Monterey 12.3.
Error -- sudo: /usr/bin/python: command not found
Reason -- Apple is removing support for Python2 from this release (12.3) onwards.
Solution -- make the code work for Python3

Files location -- /opt/homebrew/bin/auto-selfcontrol and /opt/homebrew/bin/auto-selfcontrol.py

  1. Changing the file "auto-selfcontrol"

line 55 -- change sudo /usr/bin/python to sudo /usr/bin/python3

  1. Changing the file "auto-selfcontrol.py"

change print to print() on line 87 and line 132.
change has_key to __contains__ on line 343, line 352 and line 361.

edit the get_osx_usernames() function on line 348 by -
adding .decode() at the end of line 385 to process the 'b' put by Python3 in front of strings.
changing output = subprocess.check_output(["dscl", ".", "list", "/users"]) to output = subprocess.check_output(["dscl", ".", "list", "/users"]).decode()

edit the get_launchscript() function to run Python3 -- <string>/usr/bin/python</string> to <string>/usr/bin/python3</string>

The script runs without any errors after the above changes, however, many other changes might also be required for uncaught exceptions to make the script run from 12.3 onwards.
In the meantime, someone please push the above changes to this repo.

Also, the script does run without errors.
But it does not work properly -- it does not block (issue 64)

Also
auto-selfcontrol install shows

Detected API v2
Start installation of Auto-SelfControl
Removed previous installation files
Save run configuration
Installed

Why does it show API v2. Shouldn't it be API v3 since I am running SelfControl Version 4.0.2 (410)?

andreasgrill added a commit that referenced this issue Feb 12, 2022
Add support for the new CLI of SelfControl 4.

Support for older SelfControl versions <= 3 is removed to simplify
the code. Older Auto-SelfControl versions can still be installed
for SelfControl 3 support.
The upcoming macOS Monterey 12.3 will remove oob support for Python2.

Incorporate separate Python3 module in main module.

Resolves: #65
andreasgrill added a commit that referenced this issue Feb 12, 2022
Add support for the new CLI of SelfControl 4.

Support for older SelfControl versions <= 3 is removed to simplify
the code. Older Auto-SelfControl versions can still be installed
for SelfControl 3 support.
The upcoming macOS Monterey 12.3 will remove oob support for Python2.

Incorporate separate Python3 module in main module.

Resolves: #65
andreasgrill added a commit that referenced this issue Feb 12, 2022
Add support for the new CLI of SelfControl 4.

Support for older SelfControl versions <= 3 is removed to simplify
the code. Older Auto-SelfControl versions can still be installed
for SelfControl 3 support.
The upcoming macOS Monterey 12.3 will remove oob support for Python2.

Incorporate separate Python3 module in main module.

Resolves: #65
andreasgrill added a commit that referenced this issue Feb 12, 2022
Add support for the new CLI of SelfControl 4.

Support for older SelfControl versions <= 3 is removed to simplify
the code. Older Auto-SelfControl versions can still be installed
for SelfControl 3 support.
The upcoming macOS Monterey 12.3 will remove oob support for Python2.

Incorporate separate Python3 module in main module.

Resolves: #65
@andreasgrill
Copy link
Owner

andreasgrill commented Feb 12, 2022

Thanks for the help. I've added your recommendations and the ones from #28. My local tests were successful but they are still on a branch. Until we found a solution for #64, it is not of much use anyway. When we solve this issue, we can build a new major version with the changes from the python3 branch.

@annnnnk
Copy link

annnnnk commented Sep 19, 2022

Is there a workaround yet? I can't seem to make auto-selfcontrol work.

@cristobal-io
Copy link

I've tried the changes suggested but it doesn't work.

I hope that we can get some solution for this, I can not make it run :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants