Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit 96384a5

Browse files
author
Jay Logue
committed
Support for installable Python package (wheel) for OpenWeave
-- Added support for building an installable Python wheel (.whl) file that can be used to install the OpenWeave Python code using pip on any Linux or OS X machine. The OpenWeave installable package includes the “openweave” Python module (containing WeaveDeviceManager and other classes), the associated _WeaveDeviceMgr.so shared library, and the Weave Device Manager Shell script (weave-device-mgr). Once installed, the code and tools can be used without reference to the openweave-core source tree, and without concern as to how the code locates the shared library. Building the OpenWeave Python installer requires the Python setuptools and wheel packages to be installed on the build machine. The --(enable|disable)-installable-python-package configure option can be used to control whether the installable package is built. By default, the installable package will be built if configure detects that the prerequisite build packages are available.
1 parent 79ba2a3 commit 96384a5

File tree

6 files changed

+464
-42
lines changed

6 files changed

+464
-42
lines changed

configure

Lines changed: 101 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /bin/sh
22
# Guess values for system-dependent variables and create Makefiles.
3-
# Generated by GNU Autoconf 2.68 for Weave g212389ac-dirty.
3+
# Generated by GNU Autoconf 2.68 for Weave g9c6721d9-dirty.
44
#
55
# Report bugs to <[email protected]>.
66
#
@@ -570,8 +570,8 @@ MAKEFLAGS=
570570
# Identity of this package.
571571
PACKAGE_NAME='Weave'
572572
PACKAGE_TARNAME='weave'
573-
PACKAGE_VERSION='g212389ac-dirty'
574-
PACKAGE_STRING='Weave g212389ac-dirty'
573+
PACKAGE_VERSION='g9c6721d9-dirty'
574+
PACKAGE_STRING='Weave g9c6721d9-dirty'
575575
PACKAGE_BUGREPORT='[email protected]'
576576
PACKAGE_URL='https://developer.nest.com/'
577577

@@ -699,6 +699,8 @@ WEAVE_FUZZING_ENABLED_FALSE
699699
WEAVE_FUZZING_ENABLED_TRUE
700700
WEAVE_WITH_VERHOEFF_FALSE
701701
WEAVE_WITH_VERHOEFF_TRUE
702+
WEAVE_BUILD_INSTALLABLE_PYTHON_PACKAGE_FALSE
703+
WEAVE_BUILD_INSTALLABLE_PYTHON_PACKAGE_TRUE
702704
WEAVE_BUILD_DEVICE_MANAGER_FALSE
703705
WEAVE_BUILD_DEVICE_MANAGER_TRUE
704706
INET_CONFIG_ENABLE_ASYNC_DNS_SOCKETS_FALSE
@@ -1071,6 +1073,7 @@ enable_ipv4
10711073
with_inet_endpoint
10721074
enable_adns
10731075
enable_device_manager
1076+
enable_installable_python_package
10741077
enable_verhoeff
10751078
enable_fuzzing
10761079
with_enhanced_printf
@@ -1709,7 +1712,7 @@ if test "$ac_init_help" = "long"; then
17091712
# Omit some internal or obsolete options to make the list less imposing.
17101713
# This message is too long to be a string in the A/UX 3.1 sh.
17111714
cat <<_ACEOF
1712-
\`configure' configures Weave g212389ac-dirty to adapt to many kinds of systems.
1715+
\`configure' configures Weave g9c6721d9-dirty to adapt to many kinds of systems.
17131716

17141717
Usage: $0 [OPTION]... [VAR=VALUE]...
17151718

@@ -1780,7 +1783,7 @@ fi
17801783

17811784
if test -n "$ac_init_help"; then
17821785
case $ac_init_help in
1783-
short | recursive ) echo "Configuration of Weave g212389ac-dirty:";;
1786+
short | recursive ) echo "Configuration of Weave g9c6721d9-dirty:";;
17841787
esac
17851788
cat <<\_ACEOF
17861789

@@ -1842,6 +1845,9 @@ Optional Features:
18421845
--disable-adns Disable building of adns [default=no].
18431846
--enable-device-manager Enable building of Device Manager wrapper libraries
18441847
[default=yes].
1848+
--enable-installable-python-package
1849+
Enable building of an installable Python package
1850+
(wheel) for OpenWeave [default=yes].
18451851
--enable-verhoeff Enable Verhoeff support [default=no].
18461852
--enable-fuzzing Enable Fuzzing - Requires clang 6.0 or greater
18471853
[default=no].
@@ -2146,7 +2152,7 @@ fi
21462152
test -n "$ac_init_help" && exit $ac_status
21472153
if $ac_init_version; then
21482154
cat <<\_ACEOF
2149-
Weave configure g212389ac-dirty
2155+
Weave configure g9c6721d9-dirty
21502156
generated by GNU Autoconf 2.68
21512157

21522158
Copyright (C) 2010 Free Software Foundation, Inc.
@@ -3158,7 +3164,7 @@ cat >config.log <<_ACEOF
31583164
This file contains any messages produced by compilers while
31593165
running configure, to aid debugging if configure makes a mistake.
31603166

3161-
It was created by Weave $as_me g212389ac-dirty, which was
3167+
It was created by Weave $as_me g9c6721d9-dirty, which was
31623168
generated by GNU Autoconf 2.68. Invocation command line was
31633169

31643170
$ $0 $@
@@ -4365,7 +4371,7 @@ fi
43654371

43664372
# Define the identity of the package.
43674373
PACKAGE='weave'
4368-
VERSION='g212389ac-dirty'
4374+
VERSION='g9c6721d9-dirty'
43694375

43704376

43714377
# Some tools Automake needs.
@@ -9294,6 +9300,29 @@ if test "${PYTHON}" = ""; then
92949300
as_fn_error $? "could not find python: python is required to build this package." "$LINENO" 5
92959301
fi
92969302

9303+
# Check for specific Python packages
9304+
9305+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python setuptools package" >&5
9306+
$as_echo_n "checking for Python setuptools package... " >&6; }
9307+
if ${PYTHON} -c 'import setuptools' >/dev/null 2>&1; then
9308+
have_python_package_setuptools=yes
9309+
else
9310+
have_python_package_setuptools=no
9311+
fi
9312+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${have_python_package_setuptools}" >&5
9313+
$as_echo "${have_python_package_setuptools}" >&6; }
9314+
9315+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python wheel package" >&5
9316+
$as_echo_n "checking for Python wheel package... " >&6; }
9317+
if ${PYTHON} -c 'import wheel' >/dev/null 2>&1; then
9318+
have_python_package_wheel=yes
9319+
else
9320+
have_python_package_wheel=no
9321+
fi
9322+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${have_python_package_wheel}" >&5
9323+
$as_echo "${have_python_package_wheel}" >&6; }
9324+
9325+
92979326
#
92989327
# Checks for specific compiler characteristics
92999328
#
@@ -24503,7 +24532,7 @@ fi
2450324532
# Fail if Device Manager wrapper libraries are enabled but the "sockets" network stack is not. This combination is
2450424533
# not supported.
2450524534
if test "${build_device_manager}" = "yes"; then
24506-
if test "${WEAVE_SYSTEM_CONFIG_USE_SOCKETS}" eq 0; then
24535+
if test ${WEAVE_SYSTEM_CONFIG_USE_SOCKETS} -eq 0; then
2450724536
as_fn_error $? "Building Device Manager wrapper libraries requires selecting sockets as a target network stack" "$LINENO" 5
2450824537
fi
2450924538
fi
@@ -24520,6 +24549,63 @@ fi
2452024549

2452124550

2452224551

24552+
#
24553+
# OpenWeave Python installable package (wheel)
24554+
#
24555+
24556+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build installable Python package for OpenWeave" >&5
24557+
$as_echo_n "checking whether to build installable Python package for OpenWeave... " >&6; }
24558+
# Check whether --enable-installable_python_package was given.
24559+
if test "${enable_installable_python_package+set}" = set; then :
24560+
enableval=$enable_installable_python_package;
24561+
case "${enableval}" in
24562+
24563+
no|yes)
24564+
build_installable_python_package=${enableval}
24565+
;;
24566+
24567+
*)
24568+
as_fn_error $? "Invalid value ${enableval} for --enable-installable-python-package" "$LINENO" 5
24569+
;;
24570+
24571+
esac
24572+
24573+
else
24574+
24575+
# By default, enable building an installable Python package iff the setuptools and wheel packages
24576+
# are available.
24577+
if test "${have_python_package_setuptools}" == "yes" -a "${have_python_package_wheel}" == "yes"; then
24578+
build_installable_python_package=yes
24579+
else
24580+
build_installable_python_package=no
24581+
fi
24582+
24583+
fi
24584+
24585+
24586+
# Fail if requested to build an installable Python package but the setuptools and wheel packages
24587+
# are not available
24588+
if test "${build_installable_python_package}" = "yes"; then
24589+
if test "${have_python_package_setuptools}" != "yes"; then
24590+
as_fn_error $? "The Python setuptools package must be installed in order to build an installable package for OpenWeave" "$LINENO" 5
24591+
fi
24592+
if test "${have_python_package_wheel}" != "yes"; then
24593+
as_fn_error $? "The Python wheel package must be installed in order to build an installable package for OpenWeave" "$LINENO" 5
24594+
fi
24595+
fi
24596+
24597+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${build_installable_python_package}" >&5
24598+
$as_echo "${build_installable_python_package}" >&6; }
24599+
if test "${build_installable_python_package}" = "yes"; then
24600+
WEAVE_BUILD_INSTALLABLE_PYTHON_PACKAGE_TRUE=
24601+
WEAVE_BUILD_INSTALLABLE_PYTHON_PACKAGE_FALSE='#'
24602+
else
24603+
WEAVE_BUILD_INSTALLABLE_PYTHON_PACKAGE_TRUE='#'
24604+
WEAVE_BUILD_INSTALLABLE_PYTHON_PACKAGE_FALSE=
24605+
fi
24606+
24607+
24608+
2452324609
#
2452424610
# Verhoeff support
2452524611
#
@@ -29754,6 +29840,10 @@ if test -z "${WEAVE_BUILD_DEVICE_MANAGER_TRUE}" && test -z "${WEAVE_BUILD_DEVICE
2975429840
as_fn_error $? "conditional \"WEAVE_BUILD_DEVICE_MANAGER\" was never defined.
2975529841
Usually this means the macro was only invoked conditionally." "$LINENO" 5
2975629842
fi
29843+
if test -z "${WEAVE_BUILD_INSTALLABLE_PYTHON_PACKAGE_TRUE}" && test -z "${WEAVE_BUILD_INSTALLABLE_PYTHON_PACKAGE_FALSE}"; then
29844+
as_fn_error $? "conditional \"WEAVE_BUILD_INSTALLABLE_PYTHON_PACKAGE\" was never defined.
29845+
Usually this means the macro was only invoked conditionally." "$LINENO" 5
29846+
fi
2975729847
if test -z "${WEAVE_WITH_VERHOEFF_TRUE}" && test -z "${WEAVE_WITH_VERHOEFF_FALSE}"; then
2975829848
as_fn_error $? "conditional \"WEAVE_WITH_VERHOEFF\" was never defined.
2975929849
Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -30231,7 +30321,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
3023130321
# report actual input values of CONFIG_FILES etc. instead of their
3023230322
# values after options handling.
3023330323
ac_log="
30234-
This file was extended by Weave $as_me g212389ac-dirty, which was
30324+
This file was extended by Weave $as_me g9c6721d9-dirty, which was
3023530325
generated by GNU Autoconf 2.68. Invocation command line was
3023630326

3023730327
CONFIG_FILES = $CONFIG_FILES
@@ -30298,7 +30388,7 @@ _ACEOF
3029830388
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
3029930389
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
3030030390
ac_cs_version="\\
30301-
Weave config.status g212389ac-dirty
30391+
Weave config.status g9c6721d9-dirty
3030230392
configured by $0, generated by GNU Autoconf 2.68,
3030330393
with options \\"\$ac_cs_config\\"
3030430394

configure.ac

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,25 @@ if test "${PYTHON}" = ""; then
324324
AC_MSG_ERROR([could not find python: python is required to build this package.])
325325
fi
326326

327+
# Check for specific Python packages
328+
329+
AC_MSG_CHECKING([for Python setuptools package])
330+
if ${PYTHON} -c 'import setuptools' >/dev/null 2>&1; then
331+
have_python_package_setuptools=yes
332+
else
333+
have_python_package_setuptools=no
334+
fi
335+
AC_MSG_RESULT(${have_python_package_setuptools})
336+
337+
AC_MSG_CHECKING([for Python wheel package])
338+
if ${PYTHON} -c 'import wheel' >/dev/null 2>&1; then
339+
have_python_package_wheel=yes
340+
else
341+
have_python_package_wheel=no
342+
fi
343+
AC_MSG_RESULT(${have_python_package_wheel})
344+
345+
327346
#
328347
# Checks for specific compiler characteristics
329348
#
@@ -1692,7 +1711,7 @@ AC_ARG_ENABLE(device_manager,
16921711
# Fail if Device Manager wrapper libraries are enabled but the "sockets" network stack is not. This combination is
16931712
# not supported.
16941713
if test "${build_device_manager}" = "yes"; then
1695-
if test "${WEAVE_SYSTEM_CONFIG_USE_SOCKETS}" eq 0; then
1714+
if test ${WEAVE_SYSTEM_CONFIG_USE_SOCKETS} -eq 0; then
16961715
AC_MSG_ERROR([Building Device Manager wrapper libraries requires selecting sockets as a target network stack])
16971716
fi
16981717
fi
@@ -1701,6 +1720,51 @@ AC_MSG_RESULT(${build_device_manager})
17011720
AM_CONDITIONAL([WEAVE_BUILD_DEVICE_MANAGER], [test "${build_device_manager}" = "yes"])
17021721

17031722

1723+
#
1724+
# OpenWeave Python installable package (wheel)
1725+
#
1726+
1727+
AC_MSG_CHECKING([whether to build installable Python package for OpenWeave])
1728+
AC_ARG_ENABLE(installable_python_package,
1729+
[AS_HELP_STRING([--enable-installable-python-package],[Enable building of an installable Python package (wheel) for OpenWeave @<:@default=yes@:>@.])],
1730+
[
1731+
case "${enableval}" in
1732+
1733+
no|yes)
1734+
build_installable_python_package=${enableval}
1735+
;;
1736+
1737+
*)
1738+
AC_MSG_ERROR([Invalid value ${enableval} for --enable-installable-python-package])
1739+
;;
1740+
1741+
esac
1742+
],
1743+
[
1744+
# By default, enable building an installable Python package iff the setuptools and wheel packages
1745+
# are available.
1746+
if test "${have_python_package_setuptools}" == "yes" -a "${have_python_package_wheel}" == "yes"; then
1747+
build_installable_python_package=yes
1748+
else
1749+
build_installable_python_package=no
1750+
fi
1751+
])
1752+
1753+
# Fail if requested to build an installable Python package but the setuptools and wheel packages
1754+
# are not available
1755+
if test "${build_installable_python_package}" = "yes"; then
1756+
if test "${have_python_package_setuptools}" != "yes"; then
1757+
AC_MSG_ERROR([The Python setuptools package must be installed in order to build an installable package for OpenWeave])
1758+
fi
1759+
if test "${have_python_package_wheel}" != "yes"; then
1760+
AC_MSG_ERROR([The Python wheel package must be installed in order to build an installable package for OpenWeave])
1761+
fi
1762+
fi
1763+
1764+
AC_MSG_RESULT(${build_installable_python_package})
1765+
AM_CONDITIONAL([WEAVE_BUILD_INSTALLABLE_PYTHON_PACKAGE], [test "${build_installable_python_package}" = "yes"])
1766+
1767+
17041768
#
17051769
# Verhoeff support
17061770
#

src/device-manager/python/Makefile.am

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ openweave_PYTHON = \
4040
# Location into which the "openweave" python package will be installed.
4141
openweavedir = $(pyexecdir)/openweave
4242

43+
4344
# ------------------------------------------------------------
4445
# DLL wrapper for Weave Device Manager
4546
# ------------------------------------------------------------
@@ -95,14 +96,49 @@ install-exec-hook:
9596
rm -f $(DESTDIR)$(openweavedir)/_WeaveDeviceMgr.la
9697
rm -f $(DESTDIR)$(openweavedir)/_WeaveDeviceMgr.a
9798

99+
98100
# ------------------------------------------------------------
99101
# Weave Device Manager Shell Script
100102
# ------------------------------------------------------------
101103

102-
dist_bin_SCRIPTS = weave-device-mgr
104+
EXTRA_DIST = \
105+
$(srcdir)/weave-device-mgr.py \
106+
$(NULL)
107+
108+
bin_SCRIPTS = weave-device-mgr
103109

104110
weave-device-mgr: $(srcdir)/weave-device-mgr.py
105111
cp $(srcdir)/weave-device-mgr.py weave-device-mgr
106112

113+
CLEANFILES = weave-device-mgr
114+
115+
116+
# ------------------------------------------------------------
117+
# "openweave" Python Wheel
118+
# ------------------------------------------------------------
119+
120+
if WEAVE_BUILD_INSTALLABLE_PYTHON_PACKAGE
121+
122+
EXTRA_DIST += \
123+
$(srcdir)/build-openweave-wheel.py \
124+
$(NULL)
125+
126+
.openweave-wheel: $(srcdir)/build-openweave-wheel.py weave-device-mgr _WeaveDeviceMgr.la $(shell find $(srcdir) -type f -name '*.py')
127+
rm -f openweave-*.whl
128+
$(PYTHON) $(srcdir)/build-openweave-wheel.py
129+
touch .openweave-wheel
130+
131+
install-exec-local: .openweave-wheel
132+
mkdir -p $(DESTDIR)$(pyexecdir)
133+
rm -f $(DESTDIR)$(pyexecdir)/openweave-*.whl
134+
cp openweave-*.whl $(DESTDIR)$(pyexecdir)
135+
136+
uninstall-local:
137+
rm -f $(DESTDIR)$(pyexecdir)/openweave-*.whl
138+
139+
clean-local:
140+
rm -f .openweave-wheel openweave-*.whl
141+
142+
endif # WEAVE_BUILD_INSTALLABLE_PYTHON_PACKAGE
107143

108144
include $(abs_top_nlbuild_autotools_dir)/automake/post.am

0 commit comments

Comments
 (0)