coveralls: ## Pull Request Test Coverage Report for [Build 273](https://coveralls.io/builds/20987122)

* **0** of **0**   changed or added relevant lines in **0** files are covered.
* **2** unchanged lines in **1** file lost coverage.
* Overall coverage decreased (**-0.2%**) to **86.186%**

---


|  Files with Coverage Reduction | New Missed Lines | % |
| :-----|--------------|--: |
| [.tox/py36/lib/python3.6/site-packages/shiv/bootstrap/__init__.py](https://coveralls.io/builds/20987122/source?filename=.tox%2Fpy36%2Flib%2Fpython3.6%2Fsite-packages%2Fshiv%2Fbootstrap%2F__init__.py#L82) | 2 | 90.48% |
<!-- | **Total:** | **2** |  | -->

|  Totals | [![Coverage Status](https://coveralls.io/builds/20987122/badge)](https://coveralls.io/builds/20987122) |
| :-- | --: |
| Change from base [Build 271](https://coveralls.io/builds/20916851): |  -0.2% |
| Covered Lines: | 287 |
| Relevant Lines: | 333 |

---
##### 💛  - [Coveralls](https://coveralls.io)

diff --git a/src/shiv/bootstrap/__init__.py b/src/shiv/bootstrap/__init__.py
index 997f288..fc62175 100644
--- a/src/shiv/bootstrap/__init__.py
+++ b/src/shiv/bootstrap/__init__.py
@@ -73,8 +73,13 @@ def extract_site_packages(archive, target_path, compile_pyc, compile_workers=0,
     :param ZipFile archive: The zipfile object we are bootstrapping from.
     :param Path target_path: The path to extract our zip to.
     """
-    target_path_tmp = Path(target_path.parent, target_path.stem + ".tmp")
-    lock = Path(target_path.parent, target_path.stem + ".lock")
+    parent = target_path.parent
+    target_path_tmp = Path(parent, target_path.stem + ".tmp")
+    lock = Path(parent, target_path.stem + ".lock")
+
+    # If this is the first time that a pyz is being extracted, we'll need to create the ~/.shiv dir
+    if not parent.exists():
+        parent.mkdir(parents=True, exist_ok=True)
 
     with FileLock(lock):
 

FileNotFoundError during bootstrapping to acquire_nix lock
Attempting to follow the example given in the readme, using OSX 10.11.6:
```
$ mktmpenv --python=`which python3.6`
$ which python3
/Users/<username>/Virtualenvs/tmp-cf98a678da0c70e/bin/python3

$ python -V
Python 3.6.2

$ python3 -m pip download boto
[...] Saved ./boto-2.49.0-py2.py3-none-any.whl

$ python3 -m pip install shiv
[...]

$ shiv -o boto.pyz --find-links . --no-index boto
[...] Successfully installed boto-2.49.0

$ ./boto.pyz
Traceback (most recent call last):
  File "/Users/<username>/.pyenv/versions/3.6.2/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Users/<username>/.pyenv/versions/3.6.2/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "boto.pyz/__main__.py", line 3, in <module>
  File "boto.pyz/_bootstrap/__init__.py", line 127, in bootstrap
  File "boto.pyz/_bootstrap/__init__.py", line 79, in extract_site_packages
  File "boto.pyz/_bootstrap/filelock.py", line 71, in __enter__
  File "boto.pyz/_bootstrap/filelock.py", line 39, in acquire_nix
FileNotFoundError: [Errno 2] No such file or directory: '/Users/<username>/.shiv/boto_cab7037d-ea57-4001-9b01-da4b73096d73.lock'

$ ls -al $HOME/.shiv
ls: /Users/<username>/.shiv: No such file or directory

$ mkdir $HOME/.shiv

$ ./boto.pyz
Python 3.6.2 [...]
>>> 
```

It seems like the lock acquisition assumes the directory exists, but I can't see where that's explained in the documentation.
diff --git a/test/test_bootstrap.py b/test/test_bootstrap.py
index 95b7c47..10330bd 100644
--- a/test/test_bootstrap.py
+++ b/test/test_bootstrap.py
@@ -76,13 +76,18 @@ class TestBootstrap:
         with mock.patch.object(sys, 'path', []):
             assert _first_sitedir_index() is None
 
+    @pytest.mark.parametrize("nested", (False, True))
     @pytest.mark.parametrize("compile_pyc", (False, True))
     @pytest.mark.parametrize("force", (False, True))
-    def test_extract_site_packages(self, tmpdir, zip_location, compile_pyc, force):
+    def test_extract_site_packages(self, tmpdir, zip_location, nested, compile_pyc, force):
 
         zipfile = ZipFile(str(zip_location))
         target = Path(tmpdir, "test")
 
+        if nested:
+            # we want to test for not-yet-created shiv root dirs
+            target = target / "nested" / "root"
+
         if force:
             # we want to make sure we overwrite if the target exists when using force
             target.mkdir(parents=True, exist_ok=True)

pip install -e .[dev]
parse_log_pytest
pytest
pytest pytest-cov mypy flake8 coveralls
apt-get update apt-get install -y gcc
3.6
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs @ file:///opt/conda/conda-bld/attrs_1642510447205/work
certifi==2021.5.30
charset-normalizer==2.0.12
click==8.0.4
coverage==6.2
coveralls==3.3.1
docopt==0.6.2
flake8==5.0.4
idna==3.10
importlib-metadata==4.2.0
importlib-resources==5.4.0
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
mccabe==0.7.0
more-itertools @ file:///tmp/build/80754af9/more-itertools_1637733554872/work
mypy==0.971
mypy-extensions==1.0.0
packaging @ file:///tmp/build/80754af9/packaging_1637314298585/work
pluggy @ file:///tmp/build/80754af9/pluggy_1615976315926/work
py @ file:///opt/conda/conda-bld/py_1644396412707/work
pycodestyle==2.9.1
pyflakes==2.5.0
pyparsing @ file:///tmp/build/80754af9/pyparsing_1635766073266/work
pytest==6.2.4
pytest-cov==4.0.0
requests==2.27.1
-e git+https://github.com/linkedin/shiv.git@7aba2d94b62c7e587ce5e26cf59464a1c9a3b0df#egg=shiv
toml @ file:///tmp/build/80754af9/toml_1616166611790/work
tomli==1.2.3
typed-ast==1.5.5
typing_extensions @ file:///opt/conda/conda-bld/typing_extensions_1647553014482/work
urllib3==1.26.20
zipp @ file:///tmp/build/80754af9/zipp_1633618647012/work

name: shiv
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - attrs=21.4.0=pyhd3eb1b0_0
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - importlib_metadata=4.8.1=hd3eb1b0_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - more-itertools=8.12.0=pyhd3eb1b0_0
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - packaging=21.3=pyhd3eb1b0_0
  - pip=21.2.2=py36h06a4308_0
  - pluggy=0.13.1=py36h06a4308_0
  - py=1.11.0=pyhd3eb1b0_0
  - pyparsing=3.0.4=pyhd3eb1b0_0
  - pytest=6.2.4=py36h06a4308_2
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - toml=0.10.2=pyhd3eb1b0_0
  - typing_extensions=4.1.1=pyh06a4308_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zipp=3.6.0=pyhd3eb1b0_0
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - charset-normalizer==2.0.12
      - click==8.0.4
      - coverage==6.2
      - coveralls==3.3.1
      - docopt==0.6.2
      - flake8==5.0.4
      - idna==3.10
      - importlib-metadata==4.2.0
      - importlib-resources==5.4.0
      - mccabe==0.7.0
      - mypy==0.971
      - mypy-extensions==1.0.0
      - pycodestyle==2.9.1
      - pyflakes==2.5.0
      - pytest-cov==4.0.0
      - requests==2.27.1
      - tomli==1.2.3
      - typed-ast==1.5.5
      - urllib3==1.26.20
prefix: /opt/conda/envs/shiv

test/test_bootstrap.py::TestBootstrap::test_extract_site_packages[False-False-True] test/test_bootstrap.py::TestBootstrap::test_extract_site_packages[False-True-True]
test/test_bootstrap.py::TestBootstrap::test_import_string test/test_bootstrap.py::TestBootstrap::test_is_zipfile test/test_bootstrap.py::TestBootstrap::test_argv0_is_not_zipfile test/test_bootstrap.py::TestBootstrap::test_cache_path test/test_bootstrap.py::TestBootstrap::test_first_sitedir_index test/test_bootstrap.py::TestBootstrap::test_extract_site_packages[False-False-False] test/test_bootstrap.py::TestBootstrap::test_extract_site_packages[False-True-False] test/test_bootstrap.py::TestBootstrap::test_extract_site_packages[True-False-False] test/test_bootstrap.py::TestBootstrap::test_extract_site_packages[True-False-True] test/test_bootstrap.py::TestBootstrap::test_extract_site_packages[True-True-False] test/test_bootstrap.py::TestBootstrap::test_extract_site_packages[True-True-True] test/test_bootstrap.py::TestBootstrap::test_extend_path[additional_paths0] test/test_bootstrap.py::TestBootstrap::test_extend_path[additional_paths1] test/test_bootstrap.py::TestEnvironment::test_overrides test/test_bootstrap.py::TestEnvironment::test_roundtrip test/test_bootstrap.py::TestEnvironment::test_lock test/test_builder.py::TestBuilder::test_file_prefix[/usr/bin/python-#!/usr/bin/python\n] test/test_builder.py::TestBuilder::test_file_prefix[/usr/bin/env test/test_builder.py::TestBuilder::test_file_prefix[/some/other/path/python test/test_builder.py::TestBuilder::test_binprm_error test/test_builder.py::TestBuilder::test_create_archive test/test_builder.py::TestBuilder::test_archive_permissions test/test_cli.py::TestCLI::test_find_entry_point[.] test/test_cli.py::TestCLI::test_find_entry_point[absolute-path] test/test_cli.py::TestCLI::test_no_args test/test_cli.py::TestCLI::test_no_outfile test/test_cli.py::TestCLI::test_find_interpreter test/test_cli.py::TestCLI::test_find_interpreter_false test/test_cli.py::TestCLI::test_disallowed_args[-t] test/test_cli.py::TestCLI::test_disallowed_args[--target] test/test_cli.py::TestCLI::test_disallowed_args[--editable] test/test_cli.py::TestCLI::test_disallowed_args[-d] test/test_cli.py::TestCLI::test_disallowed_args[--download] test/test_cli.py::TestCLI::test_disallowed_args[--user] test/test_cli.py::TestCLI::test_disallowed_args[--root] test/test_cli.py::TestCLI::test_disallowed_args[--prefix] test/test_cli.py::TestCLI::test_hello_world[.-yes---compile-pyc] test/test_cli.py::TestCLI::test_hello_world[.-yes---no-compile-pyc] test/test_cli.py::TestCLI::test_hello_world[.-no---compile-pyc] test/test_cli.py::TestCLI::test_hello_world[.-no---no-compile-pyc] test/test_cli.py::TestCLI::test_hello_world[absolute-path-yes---compile-pyc] test/test_cli.py::TestCLI::test_hello_world[absolute-path-yes---no-compile-pyc] test/test_cli.py::TestCLI::test_hello_world[absolute-path-no---compile-pyc] test/test_cli.py::TestCLI::test_hello_world[absolute-path-no---no-compile-pyc] test/test_cli.py::TestCLI::test_extend_pythonpath[--extend-pythonpath] test/test_cli.py::TestCLI::test_extend_pythonpath[--no-extend-pythonpath] test/test_cli.py::TestCLI::test_extend_pythonpath[-E] test/test_cli.py::TestCLI::test_no_entrypoint[.] test/test_cli.py::TestCLI::test_no_entrypoint[absolute-path] test/test_pip.py::test_clean_pip_env
src/shiv/bootstrap/__init__.py
src/shiv/bootstrap/__init__.py