Commit 180c5bf0 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Undo all the places we changed installed paths

We used to have a installed directory structure that mirrors
our source structure.  This required changing quite a few pieces of CPython
code to look in the new places (virtualenv, distutils, getpath.c, sysconfig).
So, undo all those changes, and change our CMake configuration to install into
the paths that CPython expects.

Note: "the paths that CPython expects" is platform-dependent.  The paths I added
here are based on the "posix" style that it supports.  The CPython code has platform-specific
code to look in different places, and I guess the build system must have platform-specific
knowledge of where to put it as well, but our CMake system will always put it in the linux variant.
parent 0814d218
......@@ -288,7 +288,7 @@ add_definitions(${LLVM_DEFINITIONS})
add_definitions(-DDEFAULT_PYTHON_MAJOR_VERSION=2 -DDEFAULT_PYTHON_MINOR_VERSION=7 -DDEFAULT_PYTHON_MICRO_VERSION=6) # Python 2.7.6
add_definitions(-DLLVMREV=${LLVMREV})
include_directories(${CMAKE_BINARY_DIR}/from_cpython/Include)
include_directories(${CMAKE_BINARY_DIR}/include/python2.7)
include_directories(${LLVM_INCLUDE_DIRS})
find_package(LibLZMA REQUIRED)
......
......@@ -63,9 +63,9 @@ set(CMAKE_REQUIRED_LIBRARIES util)
check_symbol_exists(openpty "pty.h" HAVE_OPENPTY)
configure_file(from_cpython/Include/pyconfig.h.in from_cpython/Include/pyconfig.h)
configure_file(from_cpython/Include/pyconfig.h.in include/python2.7/pyconfig.h)
# CMake sucks: it has no idea that pyconfig.h is something that can be installed.
# Just tell it to install whatever file is at that particular location, and rely on
# the rest of the build rules to ensure that it's made in time.
install(FILES ${CMAKE_BINARY_DIR}/from_cpython/Include/pyconfig.h DESTINATION from_cpython/Include)
install(FILES ${CMAKE_BINARY_DIR}/from_cpython/Include/pyconfig.h DESTINATION include/python2.7)
......@@ -8,9 +8,9 @@ if (${ENABLE_REF_DEBUG})
set(EXT_BUILD_FLAGS "-DPy_REF_DEBUG -DPYMALLOC_DEBUG -DPy_TRACE_REFS ${EXT_BUILD_FLAGS}")
endif()
configure_file(lib_pyston/_sysconfigdata.py.in lib_pyston/_sysconfigdata.py)
configure_file(lib_pyston/_sysconfigdata.py.in lib/python2.7/_sysconfigdata.py)
# CMake sucks: it has no idea that configure-generated files can be installed.
# Just tell it to install whatever file is at that particular location, and rely on
# the rest of the build rules to ensure that it's made in time.
install(FILES ${CMAKE_BINARY_DIR}/lib_pyston/_sysconfigdata.py DESTINATION lib_pyston)
install(FILES ${CMAKE_BINARY_DIR}/lib/python2.7/_sysconfigdata.py DESTINATION lib/python2.7)
......@@ -2,9 +2,9 @@
file(GLOB_RECURSE STDLIB_SRCS Lib/ "*.py")
file(GLOB_RECURSE STD_INCLUDES Include/ "*.h")
set(STDLIB_TARGETS "")
foreach(STDLIB_FILE ${STDLIB_SRCS} ${STD_INCLUDES})
file(RELATIVE_PATH FN_REL ${CMAKE_SOURCE_DIR} ${STDLIB_FILE})
set(TARGET ${CMAKE_BINARY_DIR}/${FN_REL})
foreach(STDLIB_FILE ${STDLIB_SRCS})
file(RELATIVE_PATH FN_REL ${CMAKE_SOURCE_DIR}/from_cpython/Lib ${STDLIB_FILE})
set(TARGET ${CMAKE_BINARY_DIR}/lib/python2.7/${FN_REL})
add_custom_command(OUTPUT ${TARGET} COMMAND
${CMAKE_COMMAND} -E copy_if_different ${STDLIB_FILE} ${TARGET}
......@@ -14,7 +14,21 @@ foreach(STDLIB_FILE ${STDLIB_SRCS} ${STD_INCLUDES})
set(STDLIB_TARGETS ${STDLIB_TARGETS} ${TARGET})
get_filename_component(DIR ${FN_REL} DIRECTORY)
install(FILES ${STDLIB_FILE} DESTINATION ${DIR})
install(FILES ${STDLIB_FILE} DESTINATION lib/python2.7/${DIR})
endforeach(STDLIB_FILE)
foreach(STDLIB_FILE ${STD_INCLUDES})
file(RELATIVE_PATH FN_REL ${CMAKE_SOURCE_DIR}/from_cpython/Include ${STDLIB_FILE})
set(TARGET ${CMAKE_BINARY_DIR}/include/python2.7/${FN_REL})
add_custom_command(OUTPUT ${TARGET} COMMAND
${CMAKE_COMMAND} -E copy_if_different ${STDLIB_FILE} ${TARGET}
DEPENDS ${STDLIB_FILE}
COMMENT "Copying ${FN_REL}"
)
set(STDLIB_TARGETS ${STDLIB_TARGETS} ${TARGET})
get_filename_component(DIR ${FN_REL} DIRECTORY)
install(FILES ${STDLIB_FILE} DESTINATION include/python2.7/${DIR})
endforeach(STDLIB_FILE)
add_custom_target(copy_stdlib ALL DEPENDS ${STDLIB_TARGETS})
......@@ -144,25 +158,25 @@ add_library(FROM_CPYTHON OBJECT ${STDMODULE_SRCS} ${STDOBJECT_SRCS} ${STDPYTHON_
add_dependencies(FROM_CPYTHON copy_stdlib)
set(STDMODULES
${CMAKE_BINARY_DIR}/from_cpython/Lib/bz2.pyston.so
${CMAKE_BINARY_DIR}/from_cpython/Lib/cmath.pyston.so
${CMAKE_BINARY_DIR}/from_cpython/Lib/cPickle.pyston.so
${CMAKE_BINARY_DIR}/from_cpython/Lib/_ctypes.pyston.so
${CMAKE_BINARY_DIR}/from_cpython/Lib/_curses.pyston.so
${CMAKE_BINARY_DIR}/from_cpython/Lib/_elementtree.pyston.so
${CMAKE_BINARY_DIR}/from_cpython/Lib/future_builtins.pyston.so
${CMAKE_BINARY_DIR}/from_cpython/Lib/grp.pyston.so
${CMAKE_BINARY_DIR}/from_cpython/Lib/_locale.pyston.so
${CMAKE_BINARY_DIR}/from_cpython/Lib/mmap.pyston.so
${CMAKE_BINARY_DIR}/from_cpython/Lib/_multiprocessing.pyston.so
${CMAKE_BINARY_DIR}/from_cpython/Lib/parser.pyston.so
${CMAKE_BINARY_DIR}/from_cpython/Lib/pyexpat.pyston.so
${CMAKE_BINARY_DIR}/from_cpython/Lib/readline.pyston.so
${CMAKE_BINARY_DIR}/from_cpython/Lib/termios.pyston.so
${CMAKE_BINARY_DIR}/lib/python2.7/lib-dynload/bz2.pyston.so
${CMAKE_BINARY_DIR}/lib/python2.7/lib-dynload/cmath.pyston.so
${CMAKE_BINARY_DIR}/lib/python2.7/lib-dynload/cPickle.pyston.so
${CMAKE_BINARY_DIR}/lib/python2.7/lib-dynload/_ctypes.pyston.so
${CMAKE_BINARY_DIR}/lib/python2.7/lib-dynload/_curses.pyston.so
${CMAKE_BINARY_DIR}/lib/python2.7/lib-dynload/_elementtree.pyston.so
${CMAKE_BINARY_DIR}/lib/python2.7/lib-dynload/future_builtins.pyston.so
${CMAKE_BINARY_DIR}/lib/python2.7/lib-dynload/grp.pyston.so
${CMAKE_BINARY_DIR}/lib/python2.7/lib-dynload/_locale.pyston.so
${CMAKE_BINARY_DIR}/lib/python2.7/lib-dynload/mmap.pyston.so
${CMAKE_BINARY_DIR}/lib/python2.7/lib-dynload/_multiprocessing.pyston.so
${CMAKE_BINARY_DIR}/lib/python2.7/lib-dynload/parser.pyston.so
${CMAKE_BINARY_DIR}/lib/python2.7/lib-dynload/pyexpat.pyston.so
${CMAKE_BINARY_DIR}/lib/python2.7/lib-dynload/readline.pyston.so
${CMAKE_BINARY_DIR}/lib/python2.7/lib-dynload/termios.pyston.so
)
add_custom_command(OUTPUT ${STDMODULES}
COMMAND ${CMAKE_BINARY_DIR}/pyston setup.py build --build-lib ${CMAKE_BINARY_DIR}/from_cpython/Lib
COMMAND ${CMAKE_BINARY_DIR}/pyston setup.py build --build-lib ${CMAKE_BINARY_DIR}/lib/python2.7/lib-dynload
DEPENDS
pyston
copy_stdlib
......@@ -193,6 +207,6 @@ add_custom_command(OUTPUT ${STDMODULES}
Modules/cPickle.c
Modules/parsermodule.c
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
add_custom_target(sharedmods ALL DEPENDS ${CMAKE_BINARY_DIR}/from_cpython/Lib/_multiprocessing.pyston.so)
add_custom_target(sharedmods ALL DEPENDS ${CMAKE_BINARY_DIR}/lib/python2.7/lib-dynload/_multiprocessing.pyston.so)
install(FILES ${STDMODULES} DESTINATION from_cpython/Lib)
install(FILES ${STDMODULES} DESTINATION lib/python2.7/lib-dynload)
......@@ -41,11 +41,8 @@ else:
INSTALL_SCHEMES = {
'unix_prefix': {
# Pyston change
# 'purelib': '$base/lib/python$py_version_short/site-packages',
# 'platlib': '$platbase/lib/python$py_version_short/site-packages',
'purelib': '$base/site-packages',
'platlib': '$base/site-packages',
'purelib': '$base/lib/python$py_version_short/site-packages',
'platlib': '$platbase/lib/python$py_version_short/site-packages',
'headers': '$base/include/python$py_version_short/$dist_name',
'scripts': '$base/bin',
'data' : '$base',
......
# This file is originally from CPython 2.7, with modifications for Pyston
# We should probably create a pyston-specific version instead of modifying the
# CPython one.
"""Provide access to Python's configuration information. The specific
configuration variables available depend heavily on the platform and
configuration. The values may be retrieved using
......@@ -68,9 +64,6 @@ def get_python_version():
def get_python_inc(plat_specific=0, prefix=None):
# Pyston change: this is the way we layout things internally:
return os.path.join(sys.prefix, "from_cpython/Include")
"""Return the directory containing installed Python header files.
If 'plat_specific' is false (the default), this is the path to the
......@@ -126,17 +119,12 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
prefix = plat_specific and EXEC_PREFIX or PREFIX
if os.name == "posix":
# Pyston change
# libpython = os.path.join(prefix,
# "lib", "python" + get_python_version())
libpython = os.path.join(prefix,
"from_cpython", "Lib")
"lib", "python" + get_python_version())
if standard_lib:
return libpython
else:
# Pyston change
# return os.path.join(libpython, "site-packages")
return os.path.join(prefix, "site-packages")
return os.path.join(libpython, "site-packages")
elif os.name == "nt":
if standard_lib:
......
......@@ -7,19 +7,12 @@ from os.path import pardir, realpath
_INSTALL_SCHEMES = {
'posix_prefix': {
# Pyston changes: changed paths
# 'stdlib': '{base}/lib/python{py_version_short}',
# 'platstdlib': '{platbase}/lib/python{py_version_short}',
# 'purelib': '{base}/lib/python{py_version_short}/site-packages',
# 'platlib': '{platbase}/lib/python{py_version_short}/site-packages',
# 'include': '{base}/include/python{py_version_short}',
# 'platinclude': '{platbase}/include/python{py_version_short}',
'stdlib': '{base}/from_cpython/Lib',
'platstdlib': '{platbase}/from_cpython/Lib',
'purelib': '{base}/site-packages',
'platlib': '{platbase}/site-packages',
'include': '{base}/from_cpython/Include',
'platinclude': '{platbase}/from_cpython/Include',
'stdlib': '{base}/lib/python{py_version_short}',
'platstdlib': '{platbase}/lib/python{py_version_short}',
'purelib': '{base}/lib/python{py_version_short}/site-packages',
'platlib': '{platbase}/lib/python{py_version_short}/site-packages',
'include': '{base}/include/python{py_version_short}',
'platinclude': '{platbase}/include/python{py_version_short}',
'scripts': '{base}/bin',
'data': '{base}',
},
......
......@@ -91,6 +91,14 @@
* process to find the installed Python tree.
*/
// Pyston change:
// In CPython, these are passed via commandline flags:
#define VERSION "2.7"
#define PREFIX ""
#define EXEC_PREFIX ""
#define VPATH ""
#define PYTHONPATH ":lib-dynload"
#ifdef __cplusplus
extern "C" {
#endif
......@@ -117,9 +125,8 @@
#endif
#ifndef PYTHONPATH
// Pyston change
#define PYTHONPATH PREFIX "/from_cpython/Lib:" \
EXEC_PREFIX "/from_cpython/Lib/lib-dynload"
#define PYTHONPATH PREFIX "/lib/python" VERSION ":" \
EXEC_PREFIX "/lib/python" VERSION "/lib-dynload"
#endif
#ifndef LANDMARK
......@@ -130,7 +137,7 @@ static char prefix[MAXPATHLEN+1];
static char exec_prefix[MAXPATHLEN+1];
static char progpath[MAXPATHLEN+1];
static char *module_search_path = NULL;
static char lib_python[] = "from_cpython/Lib"; // Pyston change
static char lib_python[] = "lib/python" VERSION;
static void
reduce(char *dir)
......@@ -397,7 +404,6 @@ calculate_path(void)
const char *prog = Py_GetProgramName();
char argv0_path[MAXPATHLEN+1];
char zip_path[MAXPATHLEN+1];
char lib_pyston_path[MAXPATHLEN+1]; // Pyston change
int pfound, efound; /* 1 if found; -1 if found build directory */
char *buf;
size_t bufsz;
......@@ -591,16 +597,6 @@ calculate_path(void)
bufsz += strlen(zip_path) + 1;
bufsz += strlen(exec_prefix) + 1;
// Pyston change: add from_cpython/Lib and lib_pyston
// Prefix contains at this point the full path to 'from_cpython/Lib'
strcpy(lib_pyston_path, prefix);
// go from ./from_cpython/Lib to ./lib_pyston
reduce(lib_pyston_path);
reduce(lib_pyston_path);
joinpath(lib_pyston_path, "lib_pyston");
bufsz += strlen(lib_pyston_path) + 1;
bufsz += strlen(prefix) + 1;
/* This is the only malloc call in this file */
buf = (char *)PyMem_Malloc(bufsz);
......@@ -621,17 +617,7 @@ calculate_path(void)
/* Next is the default zip path */
strcat(buf, zip_path);
// Pyston change
// add from_cpython/Lib
strcat(buf, delimiter);
strcat(buf, prefix);
// add lib_pyston
strcat(buf, delimiter);
strcat(buf, lib_pyston_path);
strcat(buf, delimiter);
/* Next goes merge of compile-time $PYTHONPATH with
* dynamically located prefix.
......
......@@ -2,8 +2,8 @@
file(GLOB_RECURSE LIBPYSTON_SRCS . "*.py")
set(LIBPYSTON_TARGETS "")
foreach(STDLIB_FILE ${LIBPYSTON_SRCS})
file(RELATIVE_PATH FN_REL ${CMAKE_SOURCE_DIR} ${STDLIB_FILE})
set(TARGET ${CMAKE_BINARY_DIR}/${FN_REL})
file(RELATIVE_PATH FN_REL ${CMAKE_SOURCE_DIR}/lib_pyston ${STDLIB_FILE})
set(TARGET ${CMAKE_BINARY_DIR}/lib/python2.7/${FN_REL})
add_custom_command(OUTPUT ${TARGET} COMMAND
${CMAKE_COMMAND} -E copy_if_different ${STDLIB_FILE} ${TARGET}
......@@ -14,4 +14,4 @@ foreach(STDLIB_FILE ${LIBPYSTON_SRCS})
endforeach(STDLIB_FILE)
add_custom_target(copy_libpyston ALL DEPENDS ${LIBPYSTON_TARGETS})
install(FILES ${LIBPYSTON_SRCS} DESTINATION lib_pyston)
install(FILES ${LIBPYSTON_SRCS} DESTINATION lib/python2.7)
Subproject commit c48a89b5c43cbb19d87c6f8467fdfa7fbc3438a9
Subproject commit db70fc5084483b636b4bbf05519f4d69a2c741fa
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment