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

Pip module not there. Introduce a Fallback #1

Open
AnirudhG07 opened this issue Jan 15, 2025 · 5 comments
Open

Pip module not there. Introduce a Fallback #1

AnirudhG07 opened this issue Jan 15, 2025 · 5 comments
Assignees

Comments

@AnirudhG07
Copy link

AnirudhG07 commented Jan 15, 2025

Hi, looks at this

Python Command Setup
--------------------
Please specify the command to run Python on your system.
Common values: 'python', 'python3', '/path/to/python3'

Enter Python command [python]: python3
Detected: Python 3.13.1

Installing required dependencies...
/Users/anirudhgupta/.nix-profile/bin/python3: No module named pip
Warning: Failed to install dependencies: Command '['python3', '-m', 'pip', 'install', 'cryptography']' returned non-zero exit status 1.
Please manually install the 'cryptography' module using pip
Installing pre-commit hook...
Successfully installed pre-commit hook
Installing post-checkout hook...
Successfully installed post-checkout hook

Decrypting files...
Already on 'main'
Your branch is up to date with 'origin/main'.
Traceback (most recent call last):
  File "/Volumes/Anirudh/IISc/Lean/proofs-and-programs-25/.savemyass/_e.py", line 2, in <module>
    from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
ModuleNotFoundError: No module named 'cryptography'

Setup completed successfully!

Well, this is a bug. I am quite surprised my python3 does not have pip. But I personally dont like the fact you are installing cryptography.
So suggestions

  1. A possible fallback, if it doesnt work, introduce a simple fallback function implemented within code from scratch like Vigenere cipher, which uses a secret key.
  2. Ask for Permission to install, OR tell we will use a GET http request and do it from net(safety guaranteed), so using requests library and some good API(find one), encrypt it.
    --- If the permission is not given, tell falling back to Manually ciphering.

Notice my assignment (go to my fork, not linking here), I pushed it after I did the assi, yet NOTHING happened, well cause crypto failed. Fallback would be great! ik its easily breakable, but better than nothing.

also introduce like more exceptions. Ill put a PR with a possible fallback after discussion.

@AnirudhG07
Copy link
Author

Also I used /usr/bin/python3 which did install the crypto package, yet I dont see any changes to the code.

@mrigankpawagi
Copy link
Owner

mrigankpawagi commented Jan 16, 2025

We can either kill the setup script if -m pip install fails and then have the user take care of it. We can also just ask the user about their pip command.

Alternatively, we can switch to a zipapp archive. But implementing cryptographic functions ourselves is not a feasible option.

@mrigankpawagi mrigankpawagi self-assigned this Jan 16, 2025
@AnirudhG07
Copy link
Author

@mrigankpawagi There does exist a pre-push git hook which would be much better than pre-commit since, in the case of CherryPicking, it might get skipped. (just like it did for me). Lets try that too

@mrigankpawagi
Copy link
Owner

That is a good point, but it will probably be quite complicated. (Let us say we start with no active changes. Otherwise, you can stash them.) You will have to unroll all the unpushed commits and keep stacking them on the stash. Then in the reverse order, you will have to encrypt the assignment files in each commit, and re-create those commits with the encrypted files instead of the original file. After re-creating the latest commit, you will replace the local assignment files with their encrypted versions.

I might be wrong, and would be happy to discuss more.

@AnirudhG07
Copy link
Author

@mrigankpawagi checkout #1
This is enough to solve most problems. I have check it for Proof n programs and it works just fine.
This is better in my opinion rather than something extra like zipapp.

What do you think?

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

2 participants