未验证 提交 49765579 编写于 作者: P Peifeng Qiu 提交者: GitHub

Fix pygresql windows build (#10420)

- CMakeLists.txt moved to gpMgmt/bin/pythonSrc/PyGreSQL
- Unpack source code from gpMgmt/bin/pythonSrc/ext/PyGreSQL-*.tar.gz
- Add declaration to force dllexport on init_pg
- Remove the pygresql level folder. All files are moved up.
上级 f2efbda3
......@@ -113,7 +113,9 @@ nmake install NODEBUG=1
# Build steps
Replace <path\to\gpdb> with real location of your gpdb source code.
Replace <path\to\gpdb> with real location of your gpdb source code. Make sure you have
also cloned the submodule at gpMgmt\bin\pythonSrc\ext.
We will install client package to C:\greenplum-db-devel. If you want another location,
make sure you've replaced C:\greenplum-db-devel in the following scripts.
......@@ -142,7 +144,7 @@ cmake --build . --config Release --target INSTALL
4. Build pygresql, needed by gpload
```
cd <path\to\gpdb>\gpMgmt\bin\pythonSrc\PyGreSQL-4.0
cd <path\to\gpdb>\gpMgmt\bin\pythonSrc\PyGreSQL
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH=C:\greenplum-db-devel -DCMAKE_INSTALL_PREFIX:PATH=C:\greenplum-db-devel -G "Visual Studio 15 2017 Win64" ..
......
......@@ -50,6 +50,7 @@ function remote_clone() {
git clone "${GIT_URI}" gpdb_src
cd gpdb_src
git reset --hard "${GIT_COMMIT}"
git submodule update --init --recursive
EOF
}
......
......@@ -15,7 +15,7 @@ cmake --build . --config Release --target ALL_BUILD
cmake --build . --config Release --target INSTALL
REM build pygresql
cd %WORK_DIR%\gpdb_src\gpMgmt\bin\pythonSrc\PyGreSQL-4.0
cd %WORK_DIR%\gpdb_src\gpMgmt\bin\pythonSrc\PyGreSQL
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH=%WORK_DIR%\greenplum-db-devel -DCMAKE_INSTALL_PREFIX:PATH=%WORK_DIR%\greenplum-db-devel -G "Visual Studio 15 2017 Win64" ..
......
......@@ -1142,14 +1142,12 @@ If you want to review or change any of your installation settings, click Back. C
</Directory>
<Directory Id="TOPLEVELlib" Name="lib">
<Directory Id="PYTHONlib" Name="python">
<Directory Id="PYGRESQLlib" Name="pygresql">
<Component Id="PYGRESQLlib" DiskId="1" Guid="CDFE5977-8F11-43AF-95B7-374510FA872D">
<File Id="__init__.py.pygresql" Name="__init__.py" Source="$(var.SRCDIR)\lib\python\pygresql\__init__.py" />
<File Id="_pg.pyd" Name="_pg.pyd" Source="$(var.SRCDIR)\lib\python\pygresql\_pg.pyd" />
<File Id="pg.py" Name="pg.py" Source="$(var.SRCDIR)\lib\python\pygresql\pg.py" />
<File Id="pgdb.py" Name="pgdb.py" Source="$(var.SRCDIR)\lib\python\pygresql\pgdb.py" />
</Component>
</Directory>
<Component Id="PYGRESQLlib" DiskId="1" Guid="CDFE5977-8F11-43AF-95B7-374510FA872D">
<File Id="__init__.py" Name="__init__.py" Source="$(var.SRCDIR)\lib\python\__init__.py" />
<File Id="_pg.pyd" Name="_pg.pyd" Source="$(var.SRCDIR)\lib\python\_pg.pyd" />
<File Id="pg.py" Name="pg.py" Source="$(var.SRCDIR)\lib\python\pg.py" />
<File Id="pgdb.py" Name="pgdb.py" Source="$(var.SRCDIR)\lib\python\pgdb.py" />
</Component>
<Directory Id="YAMLlib" Name="yaml">
<Component Id="YAMLlib" DiskId="1" Guid="77EAA4D5-888B-4633-BE68-8C81186EAA83">
<File Id="composer.py" Name="composer.py" Source="$(var.SRCDIR)\lib\python\yaml\composer.py" />
......
cmake_minimum_required(VERSION 3.12)
set (CMAKE_CONFIGURATION_TYPES Release RelWithDebInfo)
project(pygresql C)
find_package(Python2 COMPONENTS Interpreter Development)
if (Python2_FOUND)
include_directories(${Python2_INCLUDE_DIRS})
else ()
message(FATAL_ERROR "python2 not found")
endif(Python2_FOUND)
file(GLOB SRC_TARBALL ${CMAKE_CURRENT_SOURCE_DIR}/../ext/PyGreSQL-*.tar.gz)
if (NOT SRC_TARBALL)
message(FATAL_ERROR "PyGreSQL source tarball not found, run git submodule update --init --recursive")
endif()
execute_process(COMMAND tar -xf ${SRC_TARBALL} --strip-components=1
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
file(READ pgmodule.c PGMODULE_LINES)
file(WRITE pgmodule.c "__declspec(dllexport) void init_pg(void);\n")
file(APPEND pgmodule.c "${PGMODULE_LINES}")
add_definitions("/D FRONTEND")
set (CPPFLAGS "/MP /wd4996 /wd4018 /wd4090 /wd4102 /wd4244 /wd4267 /wd4273 /wd4715")
add_definitions("${CPPFLAGS}")
file(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/__init__.py" "")
set(GPDB_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../)
include_directories(${GPDB_SRC_DIR}/src/include
${GPDB_SRC_DIR}/src/interfaces/libpq
${GPDB_SRC_DIR}/src/include/port
${GPDB_SRC_DIR}/src/include/port/win32
${GPDB_SRC_DIR}/src/include/port/win32_msvc
${GPDB_SRC_DIR}/src/port
${Python2_INCLUDE_DIRS})
link_directories(${CMAKE_PREFIX_PATH}/lib)
find_library(LIBPQ NAMES libpq HINTS ${CMAKE_INSTALL_PREFIX}/LIB)
find_library(LIBPGPORT NAMES libpgport HINTS ${CMAKE_INSTALL_PREFIX}/LIB)
find_library(LIBPGCOMMON NAMES libpgcommon HINTS ${CMAKE_INSTALL_PREFIX}/LIB)
add_library (pygresql SHARED pgmodule.c)
target_link_libraries(pygresql ${LIBPQ} ${LIBPGPORT} ${LIBPGCOMMON} ws2_32 secur32 ${Python2_LIBRARIES})
set_target_properties(pygresql PROPERTIES OUTPUT_NAME "_pg")
set_target_properties(pygresql PROPERTIES SUFFIX ".pyd")
install(TARGETS pygresql DESTINATION lib/python)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/pg.py DESTINATION lib/python)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/pgdb.py DESTINATION lib/python)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/__init__.py DESTINATION lib/python)
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册