wendlers / mpfshell

A simple shell based file explorer for ESP8266 Micropython based devices ⛺
MIT License
396 stars 84 forks source link

Support installing the package inside a virtual environment. #40

Open bartfeenstra opened 7 years ago

bartfeenstra commented 7 years ago

The change to setup.py is necessary, but I'd have to look up the exact reason. Without the change, though, running this package using an environment-provided Python executable (which is what virtual environments do) is not possible on my system (testing on Python 2.7).

The README now includes step-by-step instructions on how to set this up.

This PR works well with https://github.com/wendlers/mpfshell/pull/39.

If https://github.com/wendlers/mpfshell/pull/39 is merged before this one, this PR must first update README.md to change the manual Python package installations to pip install -r requirements.txt.

bartfeenstra commented 7 years ago

Hi! I'm not sure I understand your question. Aren't the commands you shared here pretty much the same as the one in the PR, with the exception of a few clarifications as the python executable and virtual environment paths are up to the user? I guess it's a matter of how detailed you'd like the instructions to be.

wendlers commented 7 years ago

Hi, I see the following difference between the two scripts:

# this is in both approaches the same ...
$python_global -m virtualenv venv

# but the created venv is not activated, and thus the pip command will affect the 
# default Python environment, and not the virtual one 
pip install -r requirements.txt
# also this all affects the non virtual env
sudo python setup.py build -e "/usr/bin/env python"
sudo python setup.py install

I don't see how anything is installed in the venv here ..

So might be that only the activation is missing here. But still, then we don't need sudo, and also this is then is the same as already described in the README at the very end.

bartfeenstra commented 7 years ago

The activation was indeed missing and I had indeed missed the other documentation further in the file. I tried reproducing my original problem with the shebang ('fixed' by passing -e to the build script) but can't.

I also noticed you published the package on PyPI today (thanks!), so perhaps it would be best to recommend that approach combined with a virtual environment at the top of the file. The instructions could be made shorter and less likely to fail this way. What do you think of that?

wendlers commented 7 years ago

Hi, sounds valid. Having the shortened instructions for virtual setup near the system wide instructions, and removing the complete last section from the README about the virtualenv might definitely clear things up! I think it would be good to have instructions for the pip variant and the non pip (from source) variante (since pip offers released version, and people might prefer using stuff from head). So sketched up roughly, it might come to something like this:

... From PiPy

To install the latest release from PyPi system-wide:

sudo pip install mpfshell

To install in a virtual environment

new instructions for venv (create, activate, pip install) ...

And

... From Source

Clone this repository:

....

To install for Python 2, execute the following: ... To install for Python 3, execute the following: ...

To install in a virtual environmen: new instructions for venv (create, activate, pip with requirements, setup.py)

... remove section "Running the Shell in a Virtual Environment"