ComradOrg / Comrad

A socialist network: encrypted, insurveillable, unmontizeable, and self-governing. App is written in Python. (Calling all socialist programmers for help!)
https://comrad.app
Other
196 stars 6 forks source link

Python version tooling #20

Closed mcataford closed 4 years ago

mcataford commented 4 years ago

The project currently depends heavily on the user's installed and active Python version and installs its dependencies directly on the system -- this can have unintended consequences since behaviour may vary between Python versions (as mentioned in marxzuckerburg#19) and having dependencies leak into the user's system (and the system packages leak into the application) muddies the line between the application and the system it runs on.

This PR adds a bootstrap script in the style of One Script to Rule Them All to streamline the dev setup process -- now any and all prep step can be included in script/boostrap, which takes care of setting up a venv with the right Python version (as defined in .python-version), installing the pip dependencies. Additionally, if there are any non-pip dependencies, they can also be set up there so that all contributors have to do is . script/bootstrap and be on their way.

Python version management is done via pyenv; it's reasonable to expect the presence of pyenv on contributors systems given its prevalence in the Python scene, but it could also be mentioned in the README if need be.

quadrismegistus commented 4 years ago

Wow, thank you! This is very useful

quadrismegistus commented 4 years ago

I didn't have pyenv installed on my machine. Should we include instructions on how to install that?

Also, here is what I'm getting afterward:

ryan@hephaestus~/etc/Komrade 09:08:40 $ . script/bootstrap
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.7.3.tar.xz...
-> https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz
Installing Python-3.7.3...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.7.3 to /Users/ryan/.pyenv/versions/3.7.3

/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: No module named venv
-bash: Komrade.venv/bin/activate: No such file or directory
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: No module named pip
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: No module named pip

I'm on mac. My default "python" exec is python2. Is there a way to get around that possibility?

I'll try on my linux machine when I'm back home.

LucaRicardo commented 4 years ago

I'm on mac. My default "python" exec is python2. Is there a way to get around that possibility?

Perhaps edit the script and replace python with python3.7 or just python3

mcataford commented 4 years ago

That would be a quick fix, but still would not resolve the problem of dependency on how the host is set up. That being said, I suspect that it might be a pyenv setup issue as the pyenv install step should switch the current shell to the installed version after finishing the install process. It sounds like despite the install succeeding, pyenv did not switch to 3.7.x and remained on the OS version (i.e. 2.7.x), in which venv isn't a thing yet.

I'll take a look tonight and put up a PR.

On Mon., Aug. 31, 2020, 13:44 LucaRicardo, notifications@github.com wrote:

I'm on mac. My default "python" exec is python2. Is there a way to get around that possibility?

Perhaps edit the script and replace python with python3.7 or just python3

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/marxzuckerburg/Komrade/pull/20#issuecomment-683928035, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPMGOJPZIUK2MWL4S5UEXLSDPORHANCNFSM4QPUYPWQ .

quadrismegistus commented 3 years ago

I think I have a solution up now.

It's a full auto-installer, as described here: https://github.com/Komrade/Komrade#usage

The script is here: https://github.com/Komrade/Komrade/blob/master/script/install

I used your bootstrap code, @mcataford, and added a check for installation of pyenv; if not, the pyenv installer script is called. Should be able to download pyenv and python and get itself running even on a machine with no python originally installed (it would need bash and curl though).

Also added other convenience things, including adding "komrade-cli" and "komrade-app" now added to user's $PATH for convenient usage.

let me know what you guys think if you take a look