diff --git a/.travis.yml b/.travis.yml index c241520..78e4045 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,3 +30,45 @@ jobs: - <<: *tests name: "Unit Tests w/ Python 3.6" python: "3.6" + + - &build + name: "Linux" + python: "3.6" + install: + - pip install pyinstaller + - pip install -e . + + script: + - pyinstaller -F -n aioupnp aioupnp/__main__.py + - chmod +x dist/aioupnp + - zip -j dist/aioupnp-${OS}.zip dist/aioupnp + + env: OS=linux + addons: + artifacts: + working_dir: dist + paths: + - aioupnp-${OS}.zip + + - <<: *build + name: "Mac" + os: osx + osx_image: xcode9.4 + language: generic + env: OS=mac + + - <<: *build + name: "Windows" + language: generic + services: + - docker + install: + - docker pull cdrx/pyinstaller-windows:python3-32bit + script: + - docker run -v "$(pwd):/src/aioupnp" cdrx/pyinstaller-windows:python3-32bit aioupnp/wine_build.sh + - sudo zip -j dist/aioupnp-windows.zip dist/aioupnp.exe + addons: + artifacts: + working_dir: dist + paths: + - aioupnp-windows.zip diff --git a/aioupnp/upnp.py b/aioupnp/upnp.py index 6d37c09..0ee8ea7 100644 --- a/aioupnp/upnp.py +++ b/aioupnp/upnp.py @@ -335,11 +335,17 @@ class UPnP: kwargs = kwargs or {} igd_args = igd_args timeout = int(timeout) + close_loop = False try: - asyncio.get_running_loop() + loop = asyncio.get_running_loop() except RuntimeError: loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) + close_loop = True + if not loop and not close_loop: + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + close_loop = True fut: asyncio.Future = asyncio.Future() @@ -374,7 +380,10 @@ class UPnP: if not hasattr(UPnP, method) or not hasattr(getattr(UPnP, method), "_cli"): fut.set_exception(UPnPError("\"%s\" is not a recognized command" % method)) wrapper = lambda : None - asyncio.run(wrapper()) + + loop.run_until_complete(wrapper()) + if close_loop: + loop.close() try: result = fut.result() except UPnPError as err: diff --git a/wine_build.sh b/wine_build.sh new file mode 100755 index 0000000..d58b501 --- /dev/null +++ b/wine_build.sh @@ -0,0 +1,12 @@ +set -x + +rm -rf /tmp/.wine-* + +apt-get -qq update +apt-get -qq install -y git + +pip install setuptools_scm + +cd aioupnp +pip install -e . +pyinstaller -F -n aioupnp aioupnp/__main__.py