JohnCRuf / alderman_machine

This is the repository for a research project investigating clientelistic politics in Chicago
3 stars 2 forks source link

Revamp Python package management #33

Closed tmalthouse closed 1 year ago

tmalthouse commented 1 year ago

This PR redoes Python package management to:

1) Use a Conda environment 2) Install all packages needed by Thomas and John from a single source of truth (python_environment.txt) 3) Pin down Python to 3.10 and Pandas>=2.0 (I need the copy-on-write for some of my code).

Todos:

JohnCRuf commented 1 year ago

For the first TODO, I'm not sure. But I think for the conda activation, you should be able to add it here: shell_functions.make and create a new function that deliberately loads the conda environment in shell_functions.sh. After that, we need to replace all instances of python script.py arguments in each makefile with $(PYTHON) script.py arguments.

JohnCRuf commented 1 year ago

Overall this looks very good.

Only issue that I seem to be getting is that for whatever reason, conda activate alderman_machine doesn't work when ran through make for me, but does work when ran through bash.

conda activate alderman_machine                      

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.                                    
To initialize your shell, run

    $ conda init <SHELL_NAME>

Currently supported shells are:
  - bash
  - fish
  - tcsh
  - xonsh
  - zsh
  - powershell

See 'conda init --help' for more information and options.

IMPORTANT: You may need to close and restart your shell after running 'conda init'.

make: *** [Makefile:14: ../output/conda_install_log.txt] Error 1
(base) [jackruf@rufframework code]$ make -n
make: Nothing to be done for 'all'.
(base) [jackruf@rufframework code]$ conda activate alderman_machine
(alderman_machine) [jackruf@rufframework code]$ conda activate alderman_machine
(alderman_machine) [jackruf@rufframework code]$ 
JohnCRuf commented 1 year ago

ugh, it looks like conda is more meant for interactive environments that are anathema to GNU make's primary usecases.

From chatgpt:

"In general, it's good to remember that Makefiles and Conda environments serve different purposes and can sometimes clash in their design principles. Conda is designed around interactive shell sessions, while Make is designed for non-interactive building of targets. Combining them can sometimes lead to issues like the one you're experiencing."

When asked for the best alternative, the only non-global tool was pip and venv. Agghhhhh. I like python a lot why can't they make it easier for me to use.