Example #1
0
    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)
Example #2
0
def test__get_uid_gid_from_filesystem(monkeypatch):
    monkeypatch.setattr("os.stat", _mock.create_autospec(_os.stat))
    result = _util.get_uid_gid_from_filesystem("/my/path")
    _os.stat.assert_called_once_with("/my/path")
    assert result == (_os.stat.return_value.st_uid,
                      _os.stat.return_value.st_gid)