diff --git a/.github/workflows/run_windows.yml b/.github/workflows/run_windows.yml index 9691e2dd7..244c3f0e5 100644 --- a/.github/workflows/run_windows.yml +++ b/.github/workflows/run_windows.yml @@ -21,6 +21,10 @@ jobs: uses: actions/setup-dotnet@v3 with: dotnet-version: '7.0.x' + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' - name: Set Version id: version run: if ("tag" -eq $Env:GITHUB_REF_TYPE) { echo "::set-output name=version::$Env:GITHUB_REF_NAME" } else { echo "::set-output name=version::$Env:GITHUB_SHA" } @@ -67,6 +71,7 @@ jobs: shell: cmd - name: Install Emulator run: | + pip install setuptools pip install %GITHUB_WORKSPACE%\emulator\ cd %GITHUB_WORKSPACE% .\emulator\brainflow_emulator\com0com\certmgr.exe /add %GITHUB_WORKSPACE%\emulator\brainflow_emulator\com0com\com0com.cer /s /r localMachine root diff --git a/emulator/brainflow_emulator/cyton_windows.py b/emulator/brainflow_emulator/cyton_windows.py index b5360e15b..ac2f78907 100644 --- a/emulator/brainflow_emulator/cyton_windows.py +++ b/emulator/brainflow_emulator/cyton_windows.py @@ -4,7 +4,7 @@ import sys import time -from importlib.resources import files +from pathlib import Path from brainflow_emulator.emulate_common import TestFailureError, Listener, log_multilines from serial import Serial @@ -17,16 +17,12 @@ def read(port, num_bytes): return port.read(num_bytes) -def get_isntaller(): - try: - resource = files(__name__).joinpath('com0com').joinpath('setup_com0com_W7_x64_signed.exe') - return str(resource) - except (TypeError, AttributeError): - # Fallback for: - # 1. Python < 3.9 (importlib.resources.files not available) - # 2. NixOS/packaging edge cases where importlib.resources may not work - import pkg_resources - return pkg_resources.resource_filename(__name__, os.path.join('com0com', 'setup_com0com_W7_x64_signed.exe')) +def get_installer(): + return str( + Path(__file__).resolve().parent + / "com0com" + / "setup_com0com_W7_x64_signed.exe" + ) def install_com0com(): @@ -34,7 +30,7 @@ def install_com0com(): directory = os.path.join(this_directory, 'com0com') if not os.path.exists(directory): os.makedirs(directory) - cmds = [get_isntaller(), '/NCRC', '/S', '/D=%s' % directory] + cmds = [get_installer(), '/NCRC', '/S', '/D=%s' % directory] logging.info('running %s' % ' '.join(cmds)) p = subprocess.Popen(cmds, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() diff --git a/emulator/brainflow_emulator/freeeeg32_windows.py b/emulator/brainflow_emulator/freeeeg32_windows.py index 223f56ac0..3da7a3aa2 100644 --- a/emulator/brainflow_emulator/freeeeg32_windows.py +++ b/emulator/brainflow_emulator/freeeeg32_windows.py @@ -4,7 +4,7 @@ import sys import time -from importlib.resources import files +from pathlib import Path from brainflow_emulator.emulate_common import TestFailureError, log_multilines from brainflow_emulator.freeeeg32_emulator import Listener from serial import Serial @@ -18,16 +18,12 @@ def read(port, num_bytes): return port.read(num_bytes) -def get_isntaller(): - try: - resource = files(__name__).joinpath('com0com').joinpath('setup_com0com_W7_x64_signed.exe') - return str(resource) - except (TypeError, AttributeError): - # Fallback for: - # 1. Python < 3.9 (importlib.resources.files not available) - # 2. NixOS/packaging edge cases where importlib.resources may not work - import pkg_resources - return pkg_resources.resource_filename(__name__, os.path.join('com0com', 'setup_com0com_W7_x64_signed.exe')) +def get_installer(): + return str( + Path(__file__).resolve().parent + / "com0com" + / "setup_com0com_W7_x64_signed.exe" + ) def install_com0com(): @@ -35,7 +31,7 @@ def install_com0com(): directory = os.path.join(this_directory, 'com0com') if not os.path.exists(directory): os.makedirs(directory) - cmds = [get_isntaller(), '/NCRC', '/S', '/D=%s' % directory] + cmds = [get_installer(), '/NCRC', '/S', '/D=%s' % directory] logging.info('running %s' % ' '.join(cmds)) p = subprocess.Popen(cmds, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate()