<br><br>On Wednesday, November 1, 2017, Steve Barnes <<a href="mailto:gadgetsteve@live.co.uk">gadgetsteve@live.co.uk</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
On 01/11/2017 06:54, Wes Turner wrote:<br>
> Suggestions to help to minimize unnecessary logged bandwidth use and<br>
> even work with a closed loop LAN:<br>
><br>
> This reads from the filesystem:<br>
><br>
>      import requests<br>
><br>
> This would read from the PyPi service over the network bandwidth:<br>
><br>
>     #!pip install -U requests<br>
>     #%run pip install -U requests<br>
><br>
>     #pip('install -U requests')<br>
><br>
> This doesn't work because you SHOULD restart the interpreter after<br>
> running pip (because imports are cached):<br>
><br>
>      import requests<br>
>      !pip install -U requests<br>
>      import requests<br>
><br>
> Some tips on running educational environments for beginners (optionally<br>
> in a lab):<br>
><br>
<Snipped a lot of good stuff><br>
<br>
One tip that I have used when teaching python in a closed, (sometimes<br>
internet free environment), was to pre-prepare by, in an on-line<br>
environment:<br>
<br>
  1. Create a virtual environment with the version of Python that I am<br>
going to be teaching on the target platform<br>
  2. Activate that environment<br>
  3. Ensure that I am On-line<br>
  4. Download the pip install packages that I know I will need by using<br>
`pip download` to download but not install the packages, ideally using<br>
the -r requirements.txt syntax, (plus any windows specific builds from<br>
Christoph Gohlke's site).<br>
  5. Go Off-line and run pip install with the downloaded package - if I<br>
hit any errors due to packages having unspecified dependencies add those<br>
to the requirements list and repeat from 3. (While I am at it I often<br>
log an issue with the package maintainer).<br>
  6. A fast, personal, run through my lesson plan to ensure that I<br>
haven't missed anything.<br>
<br>
I normally also download a few goodies that might not be essential to<br>
the lesson but that can act as a teaser for the more interested students.<br>
<br>
At the start of the first lesson I give the students the downloaded<br>
packages directory, usually on a USB key, and get them to pip install<br>
them while explaining the difference between local and on-line installation.</blockquote><div><br></div><div>That works. You could also host the packages with devpi or just a static HTTP server.</div><div><br></div><div>As a transparent cache, if you test your ``requirements.txt`` with each OS/CPU_architecture combination, DevPi will store and serve each package to everyone at once.</div><div><br></div><div>So do you do (in a virtualenv):</div><div><br></div><div>  pip install --download ./dir -r requirements.txt</div><div><br></div><div>And then</div><div><br></div><div>  pip install --no-index --find-links ./dir -r requirements.text</div><div><br></div><div>Like in the pip docs?</div><div><br></div><div><a href="https://pip.pypa.io/en/stable/user_guide/#installing-from-local-packages">https://pip.pypa.io/en/stable/user_guide/#installing-from-local-packages</a><br></div><div><br></div><div>DevPi can host package documentation.</div><div><a href="https://devpi.net/docs/devpi/devpi/stable/+doc/userman/devpi_packages.html#uploading-documentation">https://devpi.net/docs/devpi/devpi/stable/+doc/userman/devpi_packages.html#uploading-documentation</a> *<br></div><div><br></div><div>GitLab Pages can host package documentation and any static HTML pages (e.g. the CPython docs) alongside **the source**</div><div><a href="https://docs.gitlab.com/ce/user/project/pages/index.html">https://docs.gitlab.com/ce/user/project/pages/index.html</a><br></div><div><br></div><div><a href="https://github.com/python/cpython/tree/3.6/Doc">https://github.com/python/cpython/tree/3.6/Doc</a><br></div><div><br></div><div><br></div><div>ReadTheDocs can host Sphinx docs and can be run in a Docker container for an internet-free LAN:</div><div><a href="https://github.com/rtfd/readthedocs-docker-images">https://github.com/rtfd/readthedocs-docker-images</a></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I know that I could save having to get the students to run pip by<br>
packaging up the virtual environment as a portable, or using by<br>
pyInstaller, but having them run pip on the local downloads gives me a<br>
chance to explain how to do it in the wild.</blockquote><div><br></div><div>AFAIU, YMMV with ``virtualenv --relocatable``; and it certainly doesn't do all combinations of OS and processor architecture:</div><div><br></div><div><a href="https://virtualenv.pypa.io/en/stable/userguide/#making-environments-relocatable">https://virtualenv.pypa.io/en/stable/userguide/#making-environments-relocatable</a><br></div><div><br></div><div>itertools.combinations(</div><div>  ['win', 'mac', 'lin', '', '686', 'x86_64', 'ARM'], 2)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
BTW while Docker is great for this it is a whole other learning<br>
experience, (plus getting it running with some corporate security &<br>
anti-virus can be quite a challenge).</blockquote><div> </div><div>Yeah, hosting Docker containers with Kubernetes across a couple extra workstations is initially more work than creating a few USB keys and waiting for everyone's virtualenvs to converge (with ``$ pip install``, ``!PIP_INDEX='' pip install``, and now a new pip GUI button press sequence).</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
These USB keys are often re-used by other co-workers as a getting<br>
started or after my computer got changed/re-imaged starting point.</blockquote><div><br></div><div>Wouldn't it be create if, just like oldschool floppies, there was a way to break off the sliding write protect tab of a USB stick?</div><div><br></div><div><a href="https://en.wikipedia.org/wiki/USB_flash_drive_security#Malware_infections">https://en.wikipedia.org/wiki/USB_flash_drive_security#Malware_infections</a><br></div><div><br></div><div>CD-ROM and DVD-ROM drives seem to be more and more scare these days.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
--<br>
Steve (Gadget) Barnes<br>
Any opinions in this message are my personal opinions and do not reflect<br>
those of my employer.<br>
<br>
---<br>
This email has been checked for viruses by AVG.<br>
<a href="http://www.avg.com" target="_blank">http://www.avg.com</a><br>
<br>
______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="javascript:;" onclick="_e(event, 'cvml', 'Python-ideas@python.org')">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank">http://python.org/psf/<wbr>codeofconduct/</a><br>
</blockquote>