forked from nv-morpheus/Morpheus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update morpheus dev container to support flag for building with debug…
… python build + source files. (nv-morpheus#81) resolves nv-morpheus#21 Add the ability to build the morpheus dev container with a debug build of cpython + source libraries. Authors: - Devin Robison (https://github.com/drobison00) Approvers: - Pete MacKinnon (https://github.com/pdmack) - Michael Demoret (https://github.com/mdemoret-nv) URL: nv-morpheus#81
- Loading branch information
1 parent
6b56c9a
commit bd60e5d
Showing
7 changed files
with
284 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2021-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
./configure --with-pydebug --enable-shared --enable-ipv6 --prefix=$PREFIX | ||
make -j | ||
make install | ||
|
||
|
||
cd $PREFIX/bin | ||
ln -s python${PY_VER} python | ||
ln -s pydoc${PY_VER} pydoc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2021-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
c_compiler_version: | ||
- 9.4 | ||
|
||
cxx_compiler_version: | ||
- 9.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2021-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
{% set version = environ.get('MORPHEUS_PYTHON_VER') %} | ||
|
||
package: | ||
name: python | ||
version: {{ version }} | ||
|
||
source: | ||
fn: Python-{{ version }}.tar.xz | ||
url: https://www.python.org/ftp/python/{{ version }}/Python-{{ version }}.tar.xz | ||
# md5: c4b7100dcaace9d33ab1fda9a3a038d6 | ||
# If you want to build from the github source. This is quite a bit slower than pulling the tarball. | ||
#git_url: https://github.com/python/cpython.git | ||
#git_rev: 3.8 | ||
|
||
build: | ||
include_recipe: False | ||
no_link: bin/python | ||
number: 0 | ||
string: py{{ version }}_dbg_morpheus | ||
|
||
requirements: | ||
build: | ||
- bzip2 [unix] | ||
- libffi [unix] # Required for _ctypes, pip will complain that setuptools doesn't exist if _ctypes is missing. | ||
- openssl >=1.1.1n,<2.0 # Required for TLS/SSL capabilities in pip. | ||
- readline [unix] | ||
- sqlite [unix] | ||
- tk [unix] | ||
- xz [unix] | ||
- zlib [unix] | ||
run: | ||
- bzip2 [unix] | ||
- libffi [unix] | ||
- openssl >=1.1.1n,<2.0 # Required for TLS/SSL capabilities in pip. | ||
- readline [unix] | ||
- sqlite [unix] | ||
- tk [unix] | ||
- xz [unix] | ||
- zlib [unix] | ||
|
||
test: | ||
commands: | ||
- python -V [unix] | ||
- python3 -V [unix] | ||
- 2to3 -h | ||
- pydoc -h | ||
- python3-config --help [unix] | ||
|
||
about: | ||
home: http://www.python.org/ | ||
license: PSF | ||
summary: general purpose programming language |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -e | ||
|
||
function usage { | ||
echo "$0 -s [CPYTHON_SOURCE] -p [CONDA_INSTALL_FILE_PATH] -i [SOURCE_INSTALL_PATH] -g [GDBINIT_INSTALL_PATH]" | ||
|
||
exit 0 | ||
} | ||
|
||
function help { | ||
echo <<-DOC | ||
Usage: $0 [OPTION]... | ||
Install debug version of cpython, into the current conda environment, which has previously been downloaded/built. | ||
Arguments: | ||
-s Path to cpython (s)ource tarball, source files will be extracted and installed to path specified by '-i'. | ||
-c Path to cpython (c)onda tarball, this is what will be installed into the conda environment. | ||
-i Path where cpython source files will be installed. | ||
Default: ci/conda/recipes/python-dbg/source | ||
-g Path to install point for cpython 'gdbinit' file. Ignored if empty. | ||
Note: Requires cpython source install point '-i' to be specified so that we can locate the gdb macros. | ||
DOC | ||
|
||
exit 0 | ||
} | ||
|
||
function set_py_ver { | ||
## Get the version information | ||
PYDEBUG_VERSION=$(python --version | cut -d ' ' -f2 ) | ||
PYDEBUG_VERSION_MAJ_MIN=$(echo "${PYDEBUG_VERSION}" | awk '{split($0,ver,"."); print ver[1] "." ver[2]}') | ||
} | ||
|
||
PYDEBUG_CONDA_INSTALL_FILE="" | ||
PYDEBUG_INSTALL_GDB_PATH="" | ||
PYDEBUG_INSTALL_GDB_PATH="" | ||
PYDEBUG_INSTALL_PATH=${PWD}/ci/conda/recipes/python-dbg/source | ||
PYDEBUG_VERSION="" | ||
PYDEBUG_VERSION_MAJ_MIN="" | ||
|
||
while getopts "s:c:i:gh" opt; do | ||
case ${opt} in | ||
s) PYDEBUG_SOURCE=${OPTARG};; | ||
c) PYDEBUG_CONDA_INSTALL_FILE=${OPTARG};; | ||
i) PYDEBUG_INSTALL_PATH=${OPTARG};; | ||
g) PYDEBUG_INSTALL_GDB_PATH=${OPTARG};; | ||
h) help;; | ||
*) usage;; | ||
esac | ||
done | ||
|
||
# Install conda package | ||
if [ -n "${PYDEBUG_CONDA_INSTALL_FILE}" ]; then | ||
if [ ! -f "${PYDEBUG_CONDA_INSTALL_FILE}" ]; then | ||
echo "Conda install file does not exist or is inaccessible: ${PYDEBUG_CONDA_INSTALL_FILE}" | ||
exit 1 | ||
else | ||
echo "Installing cpython debug build: ${PYDEBUG_CONDA_INSTALL_FILE}" | ||
mamba install --use-local "${PYDEBUG_CONDA_INSTALL_FILE}" | ||
|
||
set_py_ver | ||
## Conda package will install python source to python3.xd (for development), which the CMake configure files won't find | ||
## Copy the includes to the python3.x folder so CMake can find them. | ||
cp -R /opt/conda/envs/morpheus/include/python${PYDEBUG_VERSION_MAJ_MIN}d/* \ | ||
/opt/conda/envs/morpheus/include/python${PYDEBUG_VERSION_MAJ_MIN} | ||
fi | ||
else | ||
echo "No Conda install file specified, skipping..." | ||
set_py_ver | ||
fi | ||
|
||
# Install cpython source files | ||
if [[ -n ${PYDEBUG_SOURCE} && -n ${PYDEBUG_INSTALL_PATH} ]]; then | ||
if [[ ! -f ${PYDEBUG_SOURCE} ]]; then | ||
echo "Cpython source file does not exist or is inaccessible: ${PYDEBUG_SOURCE}" | ||
exit 1 | ||
fi | ||
|
||
if [[ ! -f ${PYDEBUG_INSTALL_PATH} ]]; then | ||
mkdir -p "${PYDEBUG_INSTALL_PATH}" | ||
fi | ||
|
||
# Extract cpython source to /workspace \ | ||
for src_dir in Include Misc Modules Objects Python; do | ||
tar --strip-components=1 --extract --wildcards --file="${PYDEBUG_SOURCE}" Python-${PYDEBUG_VERSION}/${src_dir}/* | ||
mv ./${src_dir} "${PYDEBUG_INSTALL_PATH}/${src_dir}" | ||
done | ||
else | ||
echo "Missing cpython source tarball or install path, skipping..." | ||
fi | ||
|
||
# Install GDB init macros | ||
if [[ -f ${PYDEBUG_INSTALL_PATH} ]]; then | ||
# Move cpython gdb helper macros to ${HOME}/.gdbinit \ | ||
# See: https://github.com/python/cpython/blob/main/Misc/gdbinit | ||
if [[ "${PYDEBUG_INSTALL_GDB_PATH}" != "" ]]; then | ||
GDB_SRC_PATH="${PYDEBUG_INSTALL_PATH}/Misc/gdbinit" | ||
if [[ ! -f "${GDB_SRC_PATH}" ]]; then | ||
echo "gdbinit path does not exist or is inaccessible: ${GDB_SRC_PATH}" | ||
exit 1 | ||
fi | ||
|
||
cp "${GDB_SRC_PATH}" "${PYDEBUG_INSTALL_GDB_PATH}" | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters