Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-install Python Package #277

Merged
merged 32 commits into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1725a57
cmake function to install python package once make install is completed
varunagrawal Mar 21, 2020
93a00a3
add new make command for installing python wrapper
varunagrawal Jun 23, 2020
ca46ebf
added comments and removed unnecessary code
varunagrawal Jun 23, 2020
56539c9
Merge branch 'develop' into feature/python-install
varunagrawal Jun 24, 2020
6972a5c
updated comments in shell script
varunagrawal Jun 24, 2020
530016e
added Windows batch script to install python wrapped package
varunagrawal Jun 24, 2020
efde078
pure CMake script to install Python wrapper after compiling
varunagrawal Jun 24, 2020
9698b03
removed extra line
varunagrawal Jun 24, 2020
5feaf6d
reset to previous version
varunagrawal Jun 24, 2020
2475e6c
Load Cython requirements file instead of reading it in cmake
varunagrawal Jun 24, 2020
453d3a7
Added cmake variable GTSAM_CYTHON_INSTALL_FULLPATH to include build t…
varunagrawal Jun 24, 2020
4f6f821
Vastly improved setup.py template
varunagrawal Jun 24, 2020
192184b
Specify working directory from where to call setup.py
varunagrawal Jun 24, 2020
54c2903
make python-install command depends on gtsam target
varunagrawal Jun 29, 2020
806e5b1
cleaner version of execution script which only needs 'make install'
varunagrawal Jun 30, 2020
16532bf
run setup.py after installing the gtsam_eigency module
varunagrawal Jun 30, 2020
55701d5
Merge branch 'develop' into feature/python-install
varunagrawal Jun 30, 2020
192bf87
newline added to end of CMake file
varunagrawal Jun 30, 2020
9cbabb2
Set high level Cython/Eigency variables to reduce duplication
varunagrawal Jul 1, 2020
06476c8
Create and use cython build directory
varunagrawal Jul 1, 2020
c84060a
Use the high level cython variables, improve install process
varunagrawal Jul 1, 2020
7a725bf
Remove redundant postfix checking since the postfix is already added …
varunagrawal Jul 1, 2020
54f2acd
updated cython wrapper README
varunagrawal Jul 1, 2020
8859b96
In-place cython build
varunagrawal Jul 1, 2020
74591ee
fixed CYTHON_INSTALL_PATH cmake variable wrt cache
varunagrawal Jul 1, 2020
59968fd
Python Wrapper CMake update
varunagrawal Jul 1, 2020
a6908cd
removed unneeded install commands and updated README
varunagrawal Jul 1, 2020
d2f69ee
Add python-install dependency for gtsam_unstable as well
varunagrawal Jul 1, 2020
cb151dd
update python build location in travis script
varunagrawal Jul 5, 2020
e08e392
Improved paths and added checks
varunagrawal Jul 6, 2020
db40cd7
Merge branch 'develop' into feature/python-install
varunagrawal Jul 7, 2020
6657046
fix working directory for python install target
varunagrawal Jul 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,9 @@ if (GTSAM_INSTALL_CYTHON_TOOLBOX)
if(NOT GTSAM_CYTHON_INSTALL_PATH)
set(GTSAM_CYTHON_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/cython")
endif()
set(GTSAM_EIGENCY_INSTALL_PATH ${GTSAM_CYTHON_INSTALL_PATH}/gtsam_eigency)
# Cython install path appended with Build type (e.g. cython, cythonDebug, etc).
set(GTSAM_CYTHON_INSTALL_FULLPATH "${GTSAM_CYTHON_INSTALL_PATH}${GTSAM_BUILD_TAG}")
set(GTSAM_EIGENCY_INSTALL_PATH ${GTSAM_CYTHON_INSTALL_FULLPATH}/gtsam_eigency)
add_subdirectory(cython)
else()
set(GTSAM_INSTALL_CYTHON_TOOLBOX 0) # This will go into config.h
Expand Down
3 changes: 1 addition & 2 deletions cmake/GtsamCythonWrap.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ function(install_cython_wrapped_library interface_header generated_files_path in
# Split up filename to strip trailing '/' in GTSAM_CYTHON_INSTALL_PATH/subdirectory if there is one
get_filename_component(location "${install_path}" PATH)
get_filename_component(name "${install_path}" NAME)
message(STATUS "Installing Cython Toolbox to ${location}${GTSAM_BUILD_TAG}/${name}") #${GTSAM_CYTHON_INSTALL_PATH}"
message(STATUS "Installing Cython Toolbox to ${location}${GTSAM_BUILD_TAG}/${name}") #${GTSAM_CYTHON_INSTALL_FULLPATH}"

if(GTSAM_BUILD_TYPE_POSTFIXES)
foreach(build_type ${CMAKE_CONFIGURATION_TYPES})
Expand Down Expand Up @@ -278,4 +278,3 @@ function(install_cython_files source_files dest_directory)
endif()

endfunction()

9 changes: 7 additions & 2 deletions cython/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ if (GTSAM_INSTALL_CYTHON_TOOLBOX)
)
endif()

file(READ "${PROJECT_SOURCE_DIR}/cython/requirements.txt" CYTHON_INSTALL_REQUIREMENTS)
file(READ "${PROJECT_SOURCE_DIR}/README.md" README_CONTENTS)
set(CYTHON_INSTALL_REQUIREMENTS_FILE "${PROJECT_SOURCE_DIR}/cython/requirements.txt")

# Install the custom-generated __init__.py
# This is to make the build/cython/gtsam folder a python package, so gtsam can be found while wrapping gtsam_unstable
Expand All @@ -45,4 +44,10 @@ if (GTSAM_INSTALL_CYTHON_TOOLBOX)
install_cython_scripts("${PROJECT_SOURCE_DIR}/cython/gtsam" "${GTSAM_CYTHON_INSTALL_PATH}" "*.py")
install_cython_scripts("${PROJECT_SOURCE_DIR}/cython/gtsam_unstable" "${GTSAM_CYTHON_INSTALL_PATH}" "*.py")

# Add the new make target command
install(CODE
"execute_process(COMMAND ${PYTHON_EXECUTABLE} setup.py install
WORKING_DIRECTORY ${GTSAM_CYTHON_INSTALL_FULLPATH})")


endif ()
8 changes: 4 additions & 4 deletions cython/gtsam_eigency/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ add_dependencies(cythonize_eigency cythonize_eigency_conversions cythonize_eigen

# install
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DESTINATION "${GTSAM_CYTHON_INSTALL_PATH}${GTSAM_BUILD_TAG}"
DESTINATION "${GTSAM_CYTHON_INSTALL_FULLPATH}"
PATTERN "CMakeLists.txt" EXCLUDE
PATTERN "__init__.py.in" EXCLUDE)
install(TARGETS cythonize_eigency_core cythonize_eigency_conversions
DESTINATION "${GTSAM_CYTHON_INSTALL_PATH}${GTSAM_BUILD_TAG}/gtsam_eigency")
install(FILES ${OUTPUT_DIR}/conversions_api.h DESTINATION ${GTSAM_CYTHON_INSTALL_PATH}${GTSAM_BUILD_TAG}/gtsam_eigency)
DESTINATION "${GTSAM_CYTHON_INSTALL_FULLPATH}/gtsam_eigency")
install(FILES ${OUTPUT_DIR}/conversions_api.h DESTINATION ${GTSAM_CYTHON_INSTALL_FULLPATH}/gtsam_eigency)
configure_file(__init__.py.in ${OUTPUT_DIR}/__init__.py)
install(FILES ${OUTPUT_DIR}/__init__.py DESTINATION ${GTSAM_CYTHON_INSTALL_PATH}${GTSAM_BUILD_TAG}/gtsam_eigency)
install(FILES ${OUTPUT_DIR}/__init__.py DESTINATION ${GTSAM_CYTHON_INSTALL_FULLPATH}/gtsam_eigency)
27 changes: 19 additions & 8 deletions cython/setup.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ except ImportError:

packages = find_packages()

package_data = {
package:
[f for f in os.listdir(package.replace('.', os.path.sep)) if os.path.splitext(f)[1] in ('.so', '.pyd')]
for package in packages
}

cython_install_requirements = open("${CYTHON_INSTALL_REQUIREMENTS_FILE}").readlines()

install_requires = [line.strip() \
for line in cython_install_requirements \
if len(line.strip()) > 0 and not line.strip().startswith('#')
]

# Cleaner to read in the contents rather than copy them over.
readme_contents = open("${PROJECT_SOURCE_DIR}/README.md").read()

setup(
name='gtsam',
description='Georgia Tech Smoothing And Mapping library',
Expand All @@ -16,7 +32,7 @@ setup(
author_email='[email protected]',
license='Simplified BSD license',
keywords='slam sam robotics localization mapping optimization',
long_description='''${README_CONTENTS}''',
long_description=readme_contents,
long_description_content_type='text/markdown',
python_requires='>=2.7',
# https://pypi.org/pypi?%3Aaction=list_classifiers
Expand All @@ -34,11 +50,6 @@ setup(
],

packages=packages,
package_data={package:
[f for f in os.listdir(package.replace('.', os.path.sep)) if os.path.splitext(f)[1] in ('.so', '.pyd')]
for package in packages
},
install_requires=[line.strip() for line in '''
${CYTHON_INSTALL_REQUIREMENTS}
'''.splitlines() if len(line.strip()) > 0 and not line.strip().startswith('#')]
package_data=package_data,
install_requires=install_requires
)