def run(self, ctx): sources = _util.get_list_from_env("DEVELOP") if sources: prefix = _path.join(_path.sep, "var", "lib", "doppelganger", "develop") site = _path.join(prefix, "lib", "python{}.{}".format(*_sys.version_info[:2]), "site-packages") _os.makedirs(site) for root, dirs, files in _os.walk(prefix): _os.chown(root, ctx.user.id, ctx.group.id) for name in files: _os.chown(_path.join(root, name), ctx.user.id, ctx.group.id) _util.addpath("PYTHONPATH", site) _util.addpath("PATH", _path.join(prefix, "bin")) _os.environ["PYTHONDONTWRITEBYTECODE"] = "1" for source in sources: ugid = _util.get_uid_gid_from_filesystem(source) if ugid != (ctx.user.id, ctx.group.id): raise ValueError( ("source {!r} has unexpected uid/gid {!r} (does not " "match detected uid/gid {!r}") .format(source, ugid, (ctx.user.id, ctx.group.id))) pip_install_editable(source, ctx.user.id, ctx.group.id, prefix)
def test__get_list_from_env(monkeypatch, environ, kw, expected): monkeypatch.setattr("os.environ", environ) result = _util.get_list_from_env("e1", **kw) assert result == expected