def is_libdir_writable(self):
        """
        Check if the Postgres installation directory is writable.

        If it is, we will assume that sudo is not required to
        install/uninstall the library, so the sudo program will not be invoked
        or its specification will not be required.
        """
        dir = self.call_pg_config('libdir')
        logger.debug("testing if %s is writable", dir)
        try:
            f = tempfile.TemporaryFile(prefix="pgxn-", suffix=".test", dir=dir)
            f.write(b('test'))
            f.close()
        except (IOError, __HOLE__):
            rv = False
        else:
            rv = True

        return rv
dataset/ETHPy150Open dvarrazzo/pgxnclient/pgxnclient/commands/install.py/SudoInstallUninstall.is_libdir_writable