#include "Python.h"
#include "pycore_fileutils.h"
#include "pycore_initconfig.h"
#include "pycore_pathconfig.h"
#include "pycore_pymem.h"
#include "pycore_pystate.h"
#include "marshal.h"
#include "osdefs.h"
#include <wchar.h>
#ifdef MS_WINDOWS
# include <windows.h>
# include <pathcch.h>
#endif
#ifdef __APPLE__
# include <dlfcn.h>
# include <mach-o/dyld.h>
#endif
#include "Python/frozen_modules/getpath.h"
#if (!defined(PREFIX) || !defined(EXEC_PREFIX) \
|| !defined(VERSION) || !defined(VPATH) \
|| !defined(PLATLIBDIR))
#error "PREFIX, EXEC_PREFIX, VERSION, VPATH and PLATLIBDIR macros must be defined"
#endif
#if !defined(PYTHONPATH)
#define PYTHONPATH …
#endif
#if !defined(PYDEBUGEXT)
#define PYDEBUGEXT …
#endif
#if !defined(PYWINVER)
#ifdef MS_DLL_ID
#define PYWINVER …
#else
#define PYWINVER …
#endif
#endif
#if !defined(EXE_SUFFIX)
#if defined(MS_WINDOWS) || defined(__CYGWIN__) || defined(__MINGW32__)
#define EXE_SUFFIX …
#else
#define EXE_SUFFIX …
#endif
#endif
static PyObject *
getpath_abspath(PyObject *Py_UNUSED(self), PyObject *args)
{ … }
static PyObject *
getpath_basename(PyObject *Py_UNUSED(self), PyObject *args)
{ … }
static PyObject *
getpath_dirname(PyObject *Py_UNUSED(self), PyObject *args)
{ … }
static PyObject *
getpath_isabs(PyObject *Py_UNUSED(self), PyObject *args)
{ … }
static PyObject *
getpath_hassuffix(PyObject *Py_UNUSED(self), PyObject *args)
{ … }
static PyObject *
getpath_isdir(PyObject *Py_UNUSED(self), PyObject *args)
{ … }
static PyObject *
getpath_isfile(PyObject *Py_UNUSED(self), PyObject *args)
{ … }
static PyObject *
getpath_isxfile(PyObject *Py_UNUSED(self), PyObject *args)
{ … }
static PyObject *
getpath_joinpath(PyObject *Py_UNUSED(self), PyObject *args)
{ … }
static PyObject *
getpath_readlines(PyObject *Py_UNUSED(self), PyObject *args)
{ … }
static PyObject *
getpath_realpath(PyObject *Py_UNUSED(self) , PyObject *args)
{ … }
static PyMethodDef getpath_methods[] = …;
static PyObject *
getpath_warn(PyObject *Py_UNUSED(self), PyObject *args)
{ … }
static PyObject *
getpath_nowarn(PyObject *Py_UNUSED(self), PyObject *args)
{ … }
static PyMethodDef getpath_warn_method = …;
static PyMethodDef getpath_nowarn_method = …;
static int
funcs_to_dict(PyObject *dict, int warnings)
{ … }
static int
wchar_to_dict(PyObject *dict, const char *key, const wchar_t *s)
{ … }
static int
decode_to_dict(PyObject *dict, const char *key, const char *s)
{ … }
static int
env_to_dict(PyObject *dict, const char *key, int and_clear)
{ … }
static int
int_to_dict(PyObject *dict, const char *key, int v)
{ … }
#ifdef MS_WINDOWS
static int
winmodule_to_dict(PyObject *dict, const char *key, HMODULE mod)
{
wchar_t *buffer = NULL;
for (DWORD cch = 256; buffer == NULL && cch < (1024 * 1024); cch *= 2) {
buffer = (wchar_t*)PyMem_RawMalloc(cch * sizeof(wchar_t));
if (buffer) {
if (GetModuleFileNameW(mod, buffer, cch) == cch) {
PyMem_RawFree(buffer);
buffer = NULL;
}
}
}
int r = wchar_to_dict(dict, key, buffer);
PyMem_RawFree(buffer);
return r;
}
#endif
static int
progname_to_dict(PyObject *dict, const char *key)
{ … }
static int
library_to_dict(PyObject *dict, const char *key)
{ … }
PyObject *
_Py_Get_Getpath_CodeObject(void)
{ … }
PyStatus
_PyConfig_InitPathConfig(PyConfig *config, int compute_path_config)
{ … }