Repository: pypa/pip

Issue:
[pip 1.0] No such file or directory: ... installed-files.txt
``` shell
# pip --version
pip 1.0 from /usr/lib/python2.7/dist-packages (python 2.7)

# pip install --install-option='--root=/tmp/ROOT' --install-option='--prefix=/usr' turbogears
Requirement already satisfied (use --upgrade to upgrade): turbogears in /usr/lib/pymodules/python2.7
Requirement already satisfied (use --upgrade to upgrade): CherryPy>=2.3.0,<3.0dev in /usr/lib/pymodules/python2.7 (from turbogears)
Requirement already satisfied (use --upgrade to upgrade): ConfigObj>=4.3.2 in /usr/lib/python2.7/dist-packages (from turbogears)
Requirement already satisfied (use --upgrade to upgrade): FormEncode>=1.2.1 in /usr/lib/python2.7/dist-packages (from turbogears)
Requirement already satisfied (use --upgrade to upgrade): Genshi>=0.4.4 in /usr/lib/python2.7/dist-packages (from turbogears)
Requirement already satisfied (use --upgrade to upgrade): PasteScript[cheetah]>=1.7 in /usr/lib/python2.7/dist-packages (from turbogears)
Requirement already satisfied (use --upgrade to upgrade): PEAK-Rules>=0.5a1.dev-r2555 in /usr/lib/pymodules/python2.7 (from turbogears)
Requirement already satisfied (use --upgrade to upgrade): distribute in /usr/lib/python2.7/dist-packages (from turbogears)
Requirement already satisfied (use --upgrade to upgrade): simplejson>=1.9.1 in /usr/lib/python2.7/dist-packages (from turbogears)
Requirement already satisfied (use --upgrade to upgrade): TurboJson>=1.2.1 in /usr/lib/python2.7/dist-packages (from turbogears)
Downloading/unpacking tgMochiKit>=1.4.2 (from turbogears)
  Running setup.py egg_info for package tgMochiKit

Requirement already satisfied (use --upgrade to upgrade): Paste>=1.3 in /usr/lib/python2.7/dist-packages (from PasteScript[cheetah]>=1.7->turbogears)
Requirement already satisfied (use --upgrade to upgrade): PasteDeploy in /usr/lib/python2.7/dist-packages (from PasteScript[cheetah]>=1.7->turbogears)
Requirement already satisfied (use --upgrade to upgrade): BytecodeAssembler>=0.6 in /usr/lib/pymodules/python2.7 (from PEAK-Rules>=0.5a1.dev-r2555->turbogears)
Requirement already satisfied (use --upgrade to upgrade): DecoratorTools>=1.7dev-r2450 in /usr/lib/pymodules/python2.7 (from PEAK-Rules>=0.5a1.dev-r2555->turbogears)
Requirement already satisfied (use --upgrade to upgrade): AddOns>=0.6 in /usr/lib/pymodules/python2.7 (from PEAK-Rules>=0.5a1.dev-r2555->turbogears)
Requirement already satisfied (use --upgrade to upgrade): Extremes>=1.1 in /usr/lib/pymodules/python2.7 (from PEAK-Rules>=0.5a1.dev-r2555->turbogears)
Requirement already satisfied (use --upgrade to upgrade): SymbolType>=1.0 in /usr/lib/pymodules/python2.7 (from BytecodeAssembler>=0.6->PEAK-Rules>=0.5a1.dev-r2555->turbogears)
Installing collected packages: tgMochiKit
  Running setup.py install for tgMochiKit

Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 126, in main
    self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 228, in run
    requirement_set.install(install_options, global_options)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1093, in install
    requirement.install(install_options, global_options)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 593, in install
    f = open(os.path.join(egg_info_dir, 'installed-files.txt'), 'w')
IOError: [Errno 2] No such file or directory: '/usr/lib/python2.7/site-packages/tgMochiKit-1.4.2-py2.7.egg-info/installed-files.txt'
```



Discussion:
I stumbled across this bug because I was also trying to use --root with pip.  After searching around, I realized that I really wanted to be using --prefix instead of --root (see [Python issue 8357](http://bugs.python.org/issue8357) for a description of the difference).  I thought I'd comment here in case other people were making my same mistake.  Pip works as expected with --prefix.

I'm going to close this since it's very old and I can't seem to reproduce.

@dstufft, sounds like I'm running into exactly the same problem with latest pip on Ubuntu 14.04 with stock Python 2.7, and only when installing from git, normal instal from PyPI works just fine:

```
$ python -m pip --version
pip 8.1.1 from /home/zaytsev/.local/lib/python2.7/site-packages (python 2.7)

$ python -m pip install --ignore-installed --prefix lib/python-dev git+https://github.com/michaeljones/breathe.git#egg=breathe
Collecting breathe from git+https://github.com/michaeljones/breathe.git#egg=breathe
  Cloning https://github.com/michaeljones/breathe.git to /tmp/pip-build-isU_Kb/breathe
Collecting Sphinx>=1.4 (from breathe)
  Using cached Sphinx-1.4.1-py2.py3-none-any.whl
Collecting docutils>=0.5 (from breathe)
Collecting six>=1.4 (from breathe)
  Using cached six-1.10.0-py2.py3-none-any.whl
Collecting babel!=2.0,>=1.3 (from Sphinx>=1.4->breathe)
  Using cached Babel-2.3.3-py2.py3-none-any.whl
Collecting snowballstemmer>=1.1 (from Sphinx>=1.4->breathe)
  Using cached snowballstemmer-1.2.1-py2.py3-none-any.whl
Collecting Pygments>=2.0 (from Sphinx>=1.4->breathe)
  Using cached Pygments-2.1.3-py2.py3-none-any.whl
Collecting Jinja2>=2.3 (from Sphinx>=1.4->breathe)
  Using cached Jinja2-2.8-py2.py3-none-any.whl
Collecting imagesize (from Sphinx>=1.4->breathe)
  Using cached imagesize-0.7.0-py2.py3-none-any.whl
Collecting alabaster<0.8,>=0.7 (from Sphinx>=1.4->breathe)
  Using cached alabaster-0.7.7-py2.py3-none-any.whl
Collecting pytz>=0a (from babel!=2.0,>=1.3->Sphinx>=1.4->breathe)
  Using cached pytz-2016.3-py2.py3-none-any.whl
Collecting MarkupSafe (from Jinja2>=2.3->Sphinx>=1.4->breathe)
Installing collected packages: pytz, babel, snowballstemmer, six, Pygments, docutils, MarkupSafe, Jinja2, imagesize, alabaster, Sphinx, breathe
  Running setup.py install for breathe ... done
Exception:
Traceback (most recent call last):
  File "/home/zaytsev/.local/lib/python2.7/site-packages/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
  File "/home/zaytsev/.local/lib/python2.7/site-packages/pip/commands/install.py", line 317, in run
    prefix=options.prefix_path,
  File "/home/zaytsev/.local/lib/python2.7/site-packages/pip/req/req_set.py", line 732, in install
    **kwargs
  File "/home/zaytsev/.local/lib/python2.7/site-packages/pip/req/req_install.py", line 928, in install
    with open(inst_files_path, 'w') as f:
IOError: [Errno 2] No such file or directory: 'lib/python-dev/lib/python2.7/site-packages/breathe-4.2.0-py2.7.egg-info/installed-files.txt'
```

I encountered this issue too, when installing to a `--user` with `PYTHONUSERBASE` set to a relative directory.

```
$ ls env
ls: env: No such file or directory
$ PYTHONUSERBASE=env python2.7 -m pip install --user genshi
Collecting genshi
  Using cached Genshi-0.7.tar.gz
Installing collected packages: genshi
  Running setup.py install for genshi ... done
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 317, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 732, in install
    **kwargs
  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 928, in install
    with open(inst_files_path, 'w') as f:
IOError: [Errno 2] No such file or directory: 'env/lib/python/site-packages/Genshi-0.7-py2.7.egg-info/installed-files.txt'
$ PYTHONUSERBASE=`pwd`/env python2.7 -m pip install --user genshi
Collecting genshi
  Using cached Genshi-0.7.tar.gz
Installing collected packages: genshi
  Running setup.py install for genshi ... done
Successfully installed genshi
```

I encounter this issue, too. Using `pip install` with the `--prefix` option.

```
Installing Python dependencies for "@niklas/nodepy-standalone-builder@0.0.1" (dev) ...
  Installing Python dependencies via Pip: --prefix nodepy_modules/.pip pyminifier py-blobbify
Collecting pyminifier
  Using cached pyminifier-2.1.tar.gz
Collecting py-blobbify
  Using cached py-blobbify-1.3.tar.gz
Installing collected packages: pyminifier, py-blobbify
  Running setup.py install for pyminifier ... done
Exception:
Traceback (most recent call last):
  File "c:\users\niklas\applications\python35-32\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "c:\users\niklas\applications\python35-32\lib\site-packages\pip\commands\install.py", line 342, in run
    prefix=options.prefix_path,
  File "c:\users\niklas\applications\python35-32\lib\site-packages\pip\req\req_set.py", line 784, in install
    **kwargs
  File "c:\users\niklas\applications\python35-32\lib\site-packages\pip\req\req_install.py", line 922, in install
    with open(inst_files_path, 'w') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'nodepy_modules\\.pip\\Lib\\site-packages\\pyminifier-2.1-py3.5.egg-info\\installed-files.txt'
Error: `pip install` failed with exit-code 2
```
I can reproduce this issue when using Python installed via Homebrew on macOS.

```
$ pip3.6 install -v --install-option="--prefix=nodepy_modules/.pip" werkzeug 
/usr/local/lib/python3.6/site-packages/pip/commands/install.py:194: UserWarning: Disabling all use of wheels due to the use of --build-options / --global-options / --install-options.
  cmdoptions.check_install_build_global(options)
Collecting werkzeug
  1 location(s) to search for versions of werkzeug:
  * https://pypi.python.org/simple/werkzeug/
  Getting page https://pypi.python.org/simple/werkzeug/
  Looking up "https://pypi.python.org/simple/werkzeug/" in the cache
  Current age based on date: 124
  Freshness lifetime from max-age: 600
  Freshness lifetime from request max-age: 600
  The response is "fresh", returning cached response
  600 > 124
  Analyzing links from page https://pypi.python.org/simple/werkzeug/
    Skipping link https://pypi.python.org/packages/0b/37/398042f9b852c57f7e9b4e1173dcd40e7b9980d9c76a700647c458f582b1/Werkzeug-0.11.1-py2.py3-none-any.whl#md5=ff8452a255afa44a5fcb1b79a3da2f27 (from https://pypi.python.org/simple/werkzeug/); No binaries permitted for werkzeug
  [...]
    Found link https://pypi.python.org/packages/fe/7f/6d70f765ce5484e07576313897793cb49333dd34e462488ee818d17244af/Werkzeug-0.11.15.tar.gz#md5=cb4010478dd33905f95920e4880204a2 (from https://pypi.python.org/simple/werkzeug/), version: 0.11.15
  Using version 0.12.1 (newest of versions: 0.1, 0.2, 0.3, 0.3.1, 0.4, 0.4.1, 0.5, 0.5.1, 0.6, 0.6.1, 0.6.2, 0.7, 0.7.1, 0.7.2, 0.8, 0.8.1, 0.8.2, 0.8.3, 0.9, 0.9.1, 0.9.2, 0.9.3, 0.9.4, 0.9.5, 0.9.6, 0.10, 0.10.1, 0.10.2, 0.10.4, 0.11, 0.11.1, 0.11.2, 0.11.3, 0.11.4, 0.11.5, 0.11.6, 0.11.7, 0.11.8, 0.11.9, 0.11.10, 0.11.11, 0.11.12, 0.11.13, 0.11.14, 0.11.15, 0.12, 0.12.1)
  Looking up "https://pypi.python.org/packages/ab/65/d3f1edd1109cb1beb6b82f4139addad482df5b5ea113bdc98242383bf402/Werkzeug-0.12.1.tar.gz" in the cache
  Current age based on date: 80370
  Freshness lifetime from max-age: 31557600
  The response is "fresh", returning cached response
  31557600 > 80370
  Using cached Werkzeug-0.12.1.tar.gz
  Downloading from URL https://pypi.python.org/packages/ab/65/d3f1edd1109cb1beb6b82f4139addad482df5b5ea113bdc98242383bf402/Werkzeug-0.12.1.tar.gz#md5=b1c7bbe0066c0578116d75fef65c7eb3 (from https://pypi.python.org/simple/werkzeug/)
  Running setup.py (path:/private/var/folders/5l/jc83jsrs0nl4vkk9qyv0n1f00000gn/T/pip-build-7r4v773m/werkzeug/setup.py) egg_info for package werkzeug
    Running command python setup.py egg_info
    running egg_info
    creating pip-egg-info/Werkzeug.egg-info
    writing pip-egg-info/Werkzeug.egg-info/PKG-INFO
    writing dependency_links to pip-egg-info/Werkzeug.egg-info/dependency_links.txt
    writing requirements to pip-egg-info/Werkzeug.egg-info/requires.txt
    writing top-level names to pip-egg-info/Werkzeug.egg-info/top_level.txt
    writing manifest file 'pip-egg-info/Werkzeug.egg-info/SOURCES.txt'
    reading manifest file 'pip-egg-info/Werkzeug.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    no previously-included directories found matching 'docs/_build'
    no previously-included directories found matching 'docs/_themes'
    warning: no previously-included files matching '*.py[cdo]' found anywhere in distribution
    warning: no previously-included files matching '__pycache__' found anywhere in distribution
    warning: no previously-included files matching '*.so' found anywhere in distribution
    warning: no previously-included files matching '*.pyd' found anywhere in distribution
    writing manifest file 'pip-egg-info/Werkzeug.egg-info/SOURCES.txt'
  Source in /private/var/folders/5l/jc83jsrs0nl4vkk9qyv0n1f00000gn/T/pip-build-7r4v773m/werkzeug has version 0.12.1, which satisfies requirement werkzeug from https://pypi.python.org/packages/ab/65/d3f1edd1109cb1beb6b82f4139addad482df5b5ea113bdc98242383bf402/Werkzeug-0.12.1.tar.gz#md5=b1c7bbe0066c0578116d75fef65c7eb3
Skipping bdist_wheel for werkzeug, due to binaries being disabled for it.
Installing collected packages: werkzeug
  Running setup.py install for werkzeug ...     Running command /usr/local/opt/python3/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/5l/jc83jsrs0nl4vkk9qyv0n1f00000gn/T/pip-build-7r4v773m/werkzeug/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/5l/jc83jsrs0nl4vkk9qyv0n1f00000gn/T/pip-tmmuud28-record/install-record.txt --single-version-externally-managed --compile --prefix=nodepy_modules/.pip
    running install
    running build
    running build_py
    creating build
    creating build/lib
    creating build/lib/werkzeug
    copying werkzeug/__init__.py -> build/lib/werkzeug
    [...] 
    running egg_info
    writing Werkzeug.egg-info/PKG-INFO
    writing dependency_links to Werkzeug.egg-info/dependency_links.txt
    writing requirements to Werkzeug.egg-info/requires.txt
    writing top-level names to Werkzeug.egg-info/top_level.txt
    reading manifest file 'Werkzeug.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    no previously-included directories found matching 'docs/_build'
    no previously-included directories found matching 'docs/_themes'
    warning: no previously-included files matching '*.py[cdo]' found anywhere in distribution
    warning: no previously-included files matching '__pycache__' found anywhere in distribution
    warning: no previously-included files matching '*.so' found anywhere in distribution
    warning: no previously-included files matching '*.pyd' found anywhere in distribution
    writing manifest file 'Werkzeug.egg-info/SOURCES.txt'
    creating build/lib/werkzeug/debug/shared
    copying werkzeug/debug/shared/FONT_LICENSE -> build/lib/werkzeug/debug/shared
    copying werkzeug/debug/shared/console.png -> build/lib/werkzeug/debug/shared
    copying werkzeug/debug/shared/debugger.js -> build/lib/werkzeug/debug/shared
    copying werkzeug/debug/shared/jquery.js -> build/lib/werkzeug/debug/shared
    copying werkzeug/debug/shared/less.png -> build/lib/werkzeug/debug/shared
    copying werkzeug/debug/shared/more.png -> build/lib/werkzeug/debug/shared
    copying werkzeug/debug/shared/source.png -> build/lib/werkzeug/debug/shared
    copying werkzeug/debug/shared/style.css -> build/lib/werkzeug/debug/shared
    copying werkzeug/debug/shared/ubuntu.ttf -> build/lib/werkzeug/debug/shared
    warning: build_py: byte-compiling is disabled, skipping.

    running install_lib
    creating nodepy_modules
    creating nodepy_modules/.pip
    creating nodepy_modules/.pip/lib
    creating nodepy_modules/.pip/lib/python3.6
    creating nodepy_modules/.pip/lib/python3.6/site-packages
    creating nodepy_modules/.pip/lib/python3.6/site-packages/werkzeug
    copying build/lib/werkzeug/__init__.py -> nodepy_modules/.pip/lib/python3.6/site-packages/werkzeug
    [...]
    copying build/lib/werkzeug/useragents.py -> nodepy_modules/.pip/lib/python3.6/site-packages/werkzeug
    copying build/lib/werkzeug/utils.py -> nodepy_modules/.pip/lib/python3.6/site-packages/werkzeug
    copying build/lib/werkzeug/wrappers.py -> nodepy_modules/.pip/lib/python3.6/site-packages/werkzeug
    copying build/lib/werkzeug/wsgi.py -> nodepy_modules/.pip/lib/python3.6/site-packages/werkzeug
    warning: install_lib: byte-compiling is disabled, skipping.

    running install_egg_info
    Copying Werkzeug.egg-info to nodepy_modules/.pip/lib/python3.6/site-packages/Werkzeug-0.12.1-py3.6.egg-info
    running install_scripts
    writing list of installed files to '/var/folders/5l/jc83jsrs0nl4vkk9qyv0n1f00000gn/T/pip-tmmuud28-record/install-record.txt'
done
Cleaning up...
  Removing source in /private/var/folders/5l/jc83jsrs0nl4vkk9qyv0n1f00000gn/T/pip-build-7r4v773m/werkzeug
Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/local/lib/python3.6/site-packages/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/usr/local/lib/python3.6/site-packages/pip/req/req_set.py", line 784, in install
    **kwargs
  File "/usr/local/lib/python3.6/site-packages/pip/req/req_install.py", line 922, in install
    with open(inst_files_path, 'w') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'nodepy_modules/.pip/lib/python3.6/site-packages/Werkzeug-0.12.1-py3.6.egg-info/installed-files.txt'
```

This is not limited to Werkzeug. It does not happen when I use `--user --install-option="--prefix="` instead, but of course that installs to the user location.

Ths method of installation is related to Homebrew setting the `prefix` option, see https://github.com/Homebrew/brew/blob/master/docs/Homebrew-and-Python.md#note-on-pip-install---user .
The solution mentioned in [this](http://stackoverflow.com/a/41143578/791713) StackOverflow answer, works. I wonder then, why `--install-option=--prefix=` does not have the exact same effect.

*Edit* It breaks installations without `--user` or `--prefix` though.
Found a command to reproduce this issue on Windows. Pip version is 9.0.1. Using the `--target` option instead makes it work, but that will only install libraries but no scripts, etc.

```
$ pip install --prefix nodepy_modules\.pip markdown==2.6.8 Flask-HTTPAuth==3.2.2 Pygments==2.2.0 Flask==0.12 mongoengine==0.11.0 mkdocs==0.16.1 Flask-RESTful==0.3.5
Requirement already satisfied: markdown==2.6.8 in c:\python35-32\lib\site-packages
Requirement already satisfied: Flask-HTTPAuth==3.2.2 in c:\python35-32\lib\site-packages
Collecting Pygments==2.2.0
  Using cached Pygments-2.2.0-py2.py3-none-any.whl
Requirement already satisfied: Flask==0.12 in c:\python35-32\lib\site-packages
Requirement already satisfied: mongoengine==0.11.0 in c:\python35-32\lib\site-packages
Collecting mkdocs==0.16.1
  Using cached mkdocs-0.16.1-py2.py3-none-any.whl
Collecting Flask-RESTful==0.3.5
  Using cached Flask_RESTful-0.3.5-py2.py3-none-any.whl
Requirement already satisfied: itsdangerous>=0.21 in c:\python35-32\lib\site-packages (from Flask==0.12)
Requirement already satisfied: click>=2.0 in c:\python35-32\lib\site-packages (from Flask==0.12)
Requirement already satisfied: Werkzeug>=0.7 in c:\python35-32\lib\site-packages (from Flask==0.12)
Requirement already satisfied: Jinja2>=2.4 in c:\python35-32\lib\site-packages (from Flask==0.12)
Requirement already satisfied: six in c:\python35-32\lib\site-packages (from mongoengine==0.11.0)
Requirement already satisfied: pymongo>=2.7.1 in c:\python35-32\lib\site-packages (from mongoengine==0.11.0)
Requirement already satisfied: PyYAML>=3.10 in c:\python35-32\lib\site-packages (from mkdocs==0.16.1)
Requirement already satisfied: livereload>=2.3.2 in c:\python35-32\lib\site-packages (from mkdocs==0.16.1)
Requirement already satisfied: tornado>=4.1 in c:\python35-32\lib\site-packages (from mkdocs==0.16.1)
Requirement already satisfied: pytz in c:\python35-32\lib\site-packages (from Flask-RESTful==0.3.5)
Collecting aniso8601>=0.82 (from Flask-RESTful==0.3.5)
  Using cached aniso8601-1.2.1.tar.gz
Requirement already satisfied: MarkupSafe in c:\python35-32\lib\site-packages (from Jinja2>=2.4->Flask==0.12)
Requirement already satisfied: python-dateutil in c:\python35-32\lib\site-packages (from aniso8601>=0.82->Flask-RESTful==0.3.5)
Installing collected packages: Pygments, mkdocs, aniso8601, Flask-RESTful
  Running setup.py install for aniso8601 ... done
Exception:
Traceback (most recent call last):
  File "c:\python35-32\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "c:\python35-32\lib\site-packages\pip\commands\install.py", line 342, in run
    prefix=options.prefix_path,
  File "c:\python35-32\lib\site-packages\pip\req\req_set.py", line 784, in install
    **kwargs
  File "c:\python35-32\lib\site-packages\pip\req\req_install.py", line 922, in install
    with open(inst_files_path, 'w') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'nodepy_modules.pip\\Lib\\site-packages\\aniso8601-1.2.1-py3.5.egg-info\\installed-files.txt'
```

Resolving patch:
diff --git a/pip/req/req_install.py b/pip/req/req_install.py
--- a/pip/req/req_install.py
+++ b/pip/req/req_install.py
@@ -786,9 +786,9 @@ def prepend_root(path):
                     if os.path.isdir(filename):
                         filename += os.path.sep
                     new_lines.append(
-                        os.path.relpath(
-                            prepend_root(filename), egg_info_dir)
+                        os.path.relpath(prepend_root(filename), egg_info_dir)
                     )
+            ensure_dir(egg_info_dir)
             inst_files_path = os.path.join(egg_info_dir, 'installed-files.txt')
             with open(inst_files_path, 'w') as f:
                 f.write('\n'.join(new_lines) + '\n')


Test patch: