learning-it by example

#312 Forward deployed engineer interviews 5.7 min

Air-Gapped Python Install: Offline Wheels and Hashes

A swapped package installed with no error. With hash checking on, it was refused.

1. What are the two halves of the air-gapped install routine?
2. In the offline wheel install demo, what happened to the bad copy of the tabulate wheel, which had one extra file inside?
3. In the offline wheel install demo, how does the install step make sure pip cannot reach the internet?
4. What does hash checking tell you about a package?
5. Which of these is a mistake the video lists for offline installs?

Practice only: nothing is saved and no score counts towards anything. Each answer comes with the reason.

  1. Run the offline install demo

    Copy the code folder first. Install pip 26.2.2 as the video does (python -m pip install pip==26.2.2, best in a fresh virtual environment), then run python run.py. It needs internet once, to download tabulate, and everything after that runs with the network switched off by settings. Compare your seven lines with the video: the bad copy has a different hash, is refused when hashes are checked, and installs with an extra file when they are not.

    A hint

    Your first hash characters should match the video if you downloaded the same wheel.

  2. Predict a different missing package

    In run.py change colorama==0.4.6 in the missing requirements file to tabulate==0.9.0. This is a prediction exercise. Before you run it, write down what the line starting a package not in the folder will print, then run it. What does this tell you about what the wheelhouse folder decides? Then change tabulate==0.9.0 back to colorama==0.4.6.

    A hint

    The label of that print line stays the same, but the package changed.

  3. Predict a hash file without the flag

    In run.py change the check_hashes=True argument in the refuse install to check_hashes=False. This is a prediction exercise. The requirements file still has a hash on its line. Using what the video says about the pip documentation and one hash, write down whether the bad copy will still be refused, then run it and check. Then change check_hashes back to True.

    A hint

    The video says one hash switches hash checking on for the whole file.

  4. Predict a different extra file

    In wheelhouse.py in the tamper function, change tabulate/_added.py to tabulate/_other.py. This is a prediction exercise. Predict what the two printed lines 'bad copy has the same hash' and 'extra file' will say, then run it. Afterwards change _other.py back to _added.py. Why does the hash still change, even though the check for the extra file now finds nothing?

    A hint

    The extra file check looks for the name tabulate._added.

These tasks are for you to try on your own machine. Nothing is checked or saved.

What this does not show

A simulated air gap (pip settings and a dead proxy; the proxy is never reached in this run), one small package with no dependencies, one laptop. The download step needs internet. Hash checking shows a file is the one you downloaded, not that it is safe.

Up next in Forward deployed engineer interviews

More in Forward deployed engineer interviews

All Forward deployed engineer interviews videos

Related videos