Skip to content

Commit

Permalink
Merge pull request #31 from mrjerryjohns/feature/local-venv
Browse files Browse the repository at this point in the history
 Pip installation from local site packages
  • Loading branch information
mrjerryjohns authored Jan 30, 2020
2 parents 090b46a + 3f9632d commit 333fdd6
Show file tree
Hide file tree
Showing 15 changed files with 86 additions and 90 deletions.
3 changes: 2 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ $(BACKEND_TARGET): $(top_srcdir)/$(SCRIPTSDIR)/setup_compiler.sh | $(RESULTSDIR)
--includedir "$(WDLC_INCLUDEDIR)" \
--libdir "$(WDLC_LIBDIR)" \
--srcdir "$(top_srcdir)" \
--output "$(RESULTSDIR)"
--output "$(RESULTSDIR)" \
--local-packages "$(WDLC_PYTHON_LOCAL_PACKAGE_DIR)"

# A final step of the compiler set-up process is running the compiler
# backend schema validation. Running that validation requires the
Expand Down
7 changes: 4 additions & 3 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ host_triplet = @host@
target_triplet = @target@
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/third_party/nlbuild-autotools/repo/autoconf/m4/nl_enable_tests.m4 \
$(top_srcdir)/third_party/nlbuild-autotools/repo/autoconf/m4/nl_filtered_canonical.m4 \
am__aclocal_m4_deps = $(top_srcdir)/third_party/nlbuild-autotools/repo/autoconf/m4/nl_filtered_canonical.m4 \
$(top_srcdir)/build/autoconf/m4/nl_check_python_module.m4 \
$(top_srcdir)/build/autoconf/m4/nl_path_prog.m4 \
$(top_srcdir)/configure.ac
Expand Down Expand Up @@ -284,6 +283,7 @@ SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
WDLC_PYTHON_LOCAL_PACKAGE_DIR = @WDLC_PYTHON_LOCAL_PACKAGE_DIR@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
Expand Down Expand Up @@ -1085,7 +1085,8 @@ $(BACKEND_TARGET): $(top_srcdir)/$(SCRIPTSDIR)/setup_compiler.sh | $(RESULTSDIR)
--includedir "$(WDLC_INCLUDEDIR)" \
--libdir "$(WDLC_LIBDIR)" \
--srcdir "$(top_srcdir)" \
--output "$(RESULTSDIR)"
--output "$(RESULTSDIR)" \
--local-packages "$(WDLC_PYTHON_LOCAL_PACKAGE_DIR)"

# A final step of the compiler set-up process is running the compiler
# backend schema validation. Running that validation requires the
Expand Down
1 change: 0 additions & 1 deletion aclocal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,6 @@ AC_SUBST([am__tar])
AC_SUBST([am__untar])
]) # _AM_PROG_TAR

m4_include([third_party/nlbuild-autotools/repo/autoconf/m4/nl_enable_tests.m4])
m4_include([third_party/nlbuild-autotools/repo/autoconf/m4/nl_filtered_canonical.m4])
m4_include([build/autoconf/m4/nl_check_python_module.m4])
m4_include([build/autoconf/m4/nl_path_prog.m4])
4 changes: 2 additions & 2 deletions backend/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ host_triplet = @host@
target_triplet = @target@
subdir = backend
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/third_party/nlbuild-autotools/repo/autoconf/m4/nl_enable_tests.m4 \
$(top_srcdir)/third_party/nlbuild-autotools/repo/autoconf/m4/nl_filtered_canonical.m4 \
am__aclocal_m4_deps = $(top_srcdir)/third_party/nlbuild-autotools/repo/autoconf/m4/nl_filtered_canonical.m4 \
$(top_srcdir)/build/autoconf/m4/nl_check_python_module.m4 \
$(top_srcdir)/build/autoconf/m4/nl_path_prog.m4 \
$(top_srcdir)/configure.ac
Expand Down Expand Up @@ -190,6 +189,7 @@ SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
WDLC_PYTHON_LOCAL_PACKAGE_DIR = @WDLC_PYTHON_LOCAL_PACKAGE_DIR@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
Expand Down
15 changes: 14 additions & 1 deletion build/scripts/install_python_modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function usage() {
echo " --python PYTHON Use the PYTHON python executable (default: ${PYTHON})."
echo " -q, --quiet Work silently; do not display diagnostic and"
echo " -r, --requirement FILE Install from the given requirements file. This option can be used multiple times."
echo " -l, --local-packages DIR Install Python packages from DIR instead of downloading them from the internet."
echo " -v, --verbose Work verbosely; increase the level of diagnostic"
fi

Expand All @@ -69,6 +70,7 @@ PYTHON="python"
requirement_options=""
requirement_paths=""
verbose=1
local_packages_dir=""

# While there are command line options and arguments to parse, parse
# and consume them.
Expand Down Expand Up @@ -106,6 +108,11 @@ while [ "${#}" -gt 0 ]; do
shift 2
;;

-l | --local-packages)
local_packages_dir="${2}"
shift 2
;;

-v | --verbose)
((verbose += 1))
shift 1
Expand Down Expand Up @@ -155,8 +162,14 @@ source "${OUTPUTDIR}/bin/activate"
# environment. However, for the sake of being explicit, reference the
# virtual environment path.

pip_options="--upgrade ${requirement_options}"

if [ ! -z "${local_packages_dir}" ]; then
pip_options+=" --no-index --find-links=${local_packages_dir}"
fi

progress "PYTHON" "pip install ${requirement_paths}"
${OUTPUTDIR}/bin/python -m pip -q install --upgrade ${requirement_options}
${OUTPUTDIR}/bin/python -m pip -q install ${pip_options}

if [ ${?} -ne 0 ]; then
echo "Could not install Python modules specified in ${requirement_paths}" >&2
Expand Down
33 changes: 20 additions & 13 deletions build/scripts/setup_compiler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,19 @@ function usage() {
echo ""
echo "Options:"
echo ""
echo " --bindir DIR Set the executable directory to DIR, relative to the output directory."
echo " --datadir DIR Set the read-only data directory to DIR, relative to the output directory."
echo " -h, --help Print this help, then exit."
echo " --includedir DIR Set the header directory to DIR, relative to the output directory."
echo " --libdir DIR Set the library directory to DIR, relative to the output directory."
echo " --srcdir DIR Find the package sources in DIR (default: ${PWD})."
echo " -o, --output DIR Generate set up to the output directory DIR."
echo " --protoc PROTOC Use the PROTOC protoc executable (default: ${PROTOC})."
echo " --python PYTHON Use the PYTHON python executable (default: ${PYTHON})."
echo " -q, --quiet Work silently; do not display diagnostic and"
echo " -r, --requirement FILE Install from the given Python PIP requirements file. This option can be used multiple times."
echo " -v, --verbose Work verbosely; increase the level of diagnostic"
echo " --bindir DIR Set the executable directory to DIR, relative to the output directory."
echo " --datadir DIR Set the read-only data directory to DIR, relative to the output directory."
echo " -h, --help Print this help, then exit."
echo " --includedir DIR Set the header directory to DIR, relative to the output directory."
echo " --libdir DIR Set the library directory to DIR, relative to the output directory."
echo " --srcdir DIR Find the package sources in DIR (default: ${PWD})."
echo " -o, --output DIR Generate set up to the output directory DIR."
echo " --protoc PROTOC Use the PROTOC protoc executable (default: ${PROTOC})."
echo " --python PYTHON Use the PYTHON python executable (default: ${PYTHON})."
echo " -q, --quiet Work silently; do not display diagnostic and"
echo " -r, --requirement FILE Install from the given Python PIP requirements file. This option can be used multiple times."
echo " -l, --local-packages DIR Install Python packages from DIR instead of downloading them from the internet."
echo " -v, --verbose Work verbosely; increase the level of diagnostic"
fi

exit ${1}
Expand Down Expand Up @@ -101,6 +102,7 @@ wdlc_datadir=""
wdlc_libdir=""
wdlc_includedir=""
wdlc_srcdir="${PWD}"
local_packages_dir=""

# While there are command line options and arguments to parse, parse
# and consume them.
Expand Down Expand Up @@ -153,6 +155,11 @@ while [ "${#}" -gt 0 ]; do
shift 1
;;

-l | --local-packages)
local_packages_dir="${2}"
shift 2
;;

-r | --requirement)
# Accumulate Python PIP requirement paths by appending
# (preserving order priority) subsequent paths as a space-
Expand Down Expand Up @@ -271,7 +278,7 @@ find "${wdlc_libdir}/" -type d -exec chmod 775 {} \;
create_directory "${wdlc_datadir}"

progress "SETUP" "python"
"${SCRIPTDIR}/setup_venv.sh" --output "${wdlc_datadir}" --python "${PYTHON}" ${requirement_options}
"${SCRIPTDIR}/setup_venv.sh" --output "${wdlc_datadir}" --python "${PYTHON}" ${requirement_options} --local-packages "${local_packages_dir}"

if [ ${?} -ne 0 ]; then
echo "Could not set up Python for the wdlc backend." >&2
Expand Down
21 changes: 14 additions & 7 deletions build/scripts/setup_venv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ function usage() {
echo ""
echo "Options:"
echo ""
echo " -h, --help Print this help, then exit."
echo " -o, --output DIR Generate set up to the output directory DIR."
echo " --python PYTHON Use the PYTHON python executable (default: ${PYTHON})."
echo " -q, --quiet Work silently; do not display diagnostic and"
echo " -r, --requirement FILE Install from the given requirements file. This option can be used multiple times."
echo " -v, --verbose Work verbosely; increase the level of diagnostic"
echo " -h, --help Print this help, then exit."
echo " -o, --output DIR Generate set up to the output directory DIR."
echo " --python PYTHON Use the PYTHON python executable (default: ${PYTHON})."
echo " -q, --quiet Work silently; do not display diagnostic and"
echo " -r, --requirement FILE Install from the given requirements file. This option can be used multiple times."
echo " -l, --local-packages DIR Install Python packages from DIR instead of downloading them from the internet."
echo " -v, --verbose Work verbosely; increase the level of diagnostic"
fi

exit ${1}
Expand Down Expand Up @@ -81,6 +82,7 @@ PYTHON="python"
requirement_options=""
requirement_paths=""
verbose=1
local_packages_dir=""

# While there are command line options and arguments to parse, parse
# and consume them.
Expand Down Expand Up @@ -118,6 +120,11 @@ while [ "${#}" -gt 0 ]; do
shift 2
;;

-l | --local-packages)
local_packages_dir="${2}"
shift 2
;;

-v | --verbose)
((verbose += 1))
shift 1
Expand Down Expand Up @@ -150,7 +157,7 @@ venv_path="${OUTPUTDIR}/venv"

create_directory "${venv_path}"

"${SCRIPTDIR}/install_python_modules.sh" --python "${PYTHON}" --output "${venv_path}" ${requirement_options} --python "${PYTHON}"
"${SCRIPTDIR}/install_python_modules.sh" --python "${PYTHON}" --output "${venv_path}" ${requirement_options} --python "${PYTHON}" --local-packages "${local_packages_dir}"

if [ ${?} -ne 0 ]; then
echo "Could not install Python modules specified in ${requirements_paths} to ${OUTPUTDIR}" >&2
Expand Down
4 changes: 2 additions & 2 deletions codegen/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ target_triplet = @target@
subdir = codegen
SUBDIRS =
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/third_party/nlbuild-autotools/repo/autoconf/m4/nl_enable_tests.m4 \
$(top_srcdir)/third_party/nlbuild-autotools/repo/autoconf/m4/nl_filtered_canonical.m4 \
am__aclocal_m4_deps = $(top_srcdir)/third_party/nlbuild-autotools/repo/autoconf/m4/nl_filtered_canonical.m4 \
$(top_srcdir)/build/autoconf/m4/nl_check_python_module.m4 \
$(top_srcdir)/build/autoconf/m4/nl_path_prog.m4 \
$(top_srcdir)/configure.ac
Expand Down Expand Up @@ -250,6 +249,7 @@ SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
WDLC_PYTHON_LOCAL_PACKAGE_DIR = @WDLC_PYTHON_LOCAL_PACKAGE_DIR@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
Expand Down
4 changes: 2 additions & 2 deletions codegen/weave-device-cpp/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ host_triplet = @host@
target_triplet = @target@
subdir = codegen/weave-device-cpp
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/third_party/nlbuild-autotools/repo/autoconf/m4/nl_enable_tests.m4 \
$(top_srcdir)/third_party/nlbuild-autotools/repo/autoconf/m4/nl_filtered_canonical.m4 \
am__aclocal_m4_deps = $(top_srcdir)/third_party/nlbuild-autotools/repo/autoconf/m4/nl_filtered_canonical.m4 \
$(top_srcdir)/build/autoconf/m4/nl_check_python_module.m4 \
$(top_srcdir)/build/autoconf/m4/nl_path_prog.m4 \
$(top_srcdir)/configure.ac
Expand Down Expand Up @@ -190,6 +189,7 @@ SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
WDLC_PYTHON_LOCAL_PACKAGE_DIR = @WDLC_PYTHON_LOCAL_PACKAGE_DIR@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
Expand Down
Loading

0 comments on commit 333fdd6

Please sign in to comment.