-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add --readonly-app-data option (#2009)
- Loading branch information
Showing
12 changed files
with
241 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
Add ``--read-only-app-data`` option to allow for creation based on an existing | ||
app data cache which is non-writable. This may be useful (for example) to | ||
produce a docker image where the app-data is pre-populated. | ||
|
||
.. code-block:: dockerfile | ||
ENV \ | ||
VIRTUALENV_OVERRIDE_APP_DATA=/opt/virtualenv/cache \ | ||
VIRTUALENV_SYMLINK_APP_DATA=1 | ||
RUN virtualenv venv && rm -rf venv | ||
ENV VIRTUALENV_READ_ONLY_APP_DATA=1 | ||
USER nobody | ||
# this virtualenv has symlinks into the read-only app-data cache | ||
RUN virtualenv /tmp/venv | ||
Patch by :user:`asottile`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import os.path | ||
|
||
from virtualenv.util.lock import NoOpFileLock | ||
|
||
from .via_disk_folder import AppDataDiskFolder, PyInfoStoreDisk | ||
|
||
|
||
class ReadOnlyAppData(AppDataDiskFolder): | ||
can_update = False | ||
|
||
def __init__(self, folder): # type: (str) -> None | ||
if not os.path.isdir(folder): | ||
raise RuntimeError("read-only app data directory {} does not exist".format(folder)) | ||
self.lock = NoOpFileLock(folder) | ||
|
||
def reset(self): # type: () -> None | ||
raise RuntimeError("read-only app data does not support reset") | ||
|
||
def py_info_clear(self): # type: () -> None | ||
raise NotImplementedError | ||
|
||
def py_info(self, path): | ||
return _PyInfoStoreDiskReadOnly(self.py_info_at, path) | ||
|
||
def embed_update_log(self, distribution, for_py_version): | ||
raise NotImplementedError | ||
|
||
|
||
class _PyInfoStoreDiskReadOnly(PyInfoStoreDisk): | ||
def write(self, content): | ||
raise RuntimeError("read-only app data python info cannot be updated") | ||
|
||
|
||
__all__ = ("ReadOnlyAppData",) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.