I have created a collection of Python scripts, to be used as tools in our dev group. The scripts have dependencies, such as requests
and flake8
(this should technically be under dev
setup, but whatever).
I have created a setup-dev.bat
file, with the idea of being a "first-use" setup.
python -m pip install --upgrade pip --user
python -m pip install --upgrade virtualenv --user
python -m venv .env
call .\.env\Scripts\Activate.bat
python -m pip install --upgrade pip --user
python -m pip install --upgrade virtualenv --user
pip install .
The idea is:
Install and/or upgrade
pip
on the systemInstall and/or upgrade
virtualenv
on the systemCreate a virtual environment
.env
Activate it
Upgrade the
pip
andvirtualenv
under it (not sure if this makes sense at all)'Install' the scripts - most importantly, this install the dependencies
Now the scripts are ready to use and their dependencies are contained within .env
. The idea is - if/when those scripts get distributed to the higher environments for Ops to run, I don't want to pollute their environment with my dependencies.
I should point out that those tools will never be distributed over pip
or any other system, they are for internal use within the company and will be hosted on a source control, or emailed to Operations with execution instructions.
Now my questions:
- Does this even make sense?
- Have I unintentionally created a dependency on Windows? In step
4
above I should probably run just\activate
instead of the.bat
? I guess the.env
depends on the host system and would have different contents under a different OS? Which script do I have to call to activate the environment in most OS-agnostic way? Theactivate
, theps1
or the.bat
? - After the users of my scripts have set it up for first time, I guess they should be educated that if they want to run the scripts, they'd first have to run
.env\Scripts\activate
? Is there any way to semi-automate this, make it more obvious or fool-proof? - Why do I get
You are using pip version 19.0.3, however version 19.3.1 is available.
as a result of mypip upgrade
command?!
Edits:
- I've changed
python -m pip install --upgrade pip --user
topython -m pip install --upgrade pip
and this got rid of the error. I guess installing "for the user" under thevenv
doesn't make sense anyway. - I got rid of the
virtualenv
steps, per the comment below - Changed
pip install .
topip install -e .
to ensure that the scripts (some of which act as configurations) are still editable.
I feel like I am progressing, but I am confused about the lack of posts around such setup and it feels like I am doing something wrong.