Skip to content

Commit 15146f9

Browse files
committed
dont use pkg resources for emulator
Signed-off-by: Andrey Parfenov <a1994ndrey@gmail.com>
1 parent eba0cfa commit 15146f9

File tree

3 files changed

+17
-24
lines changed

3 files changed

+17
-24
lines changed

.github/workflows/run_windows.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ jobs:
7171
shell: cmd
7272
- name: Install Emulator
7373
run: |
74+
pip install setuptools
7475
pip install %GITHUB_WORKSPACE%\emulator\
7576
cd %GITHUB_WORKSPACE%
7677
.\emulator\brainflow_emulator\com0com\certmgr.exe /add %GITHUB_WORKSPACE%\emulator\brainflow_emulator\com0com\com0com.cer /s /r localMachine root

emulator/brainflow_emulator/cyton_windows.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import sys
55
import time
66

7-
from importlib.resources import files
7+
from pathlib import Path
88
from brainflow_emulator.emulate_common import TestFailureError, Listener, log_multilines
99
from serial import Serial
1010

@@ -17,24 +17,20 @@ def read(port, num_bytes):
1717
return port.read(num_bytes)
1818

1919

20-
def get_isntaller():
21-
try:
22-
resource = files(__name__).joinpath('com0com').joinpath('setup_com0com_W7_x64_signed.exe')
23-
return str(resource)
24-
except (TypeError, AttributeError):
25-
# Fallback for:
26-
# 1. Python < 3.9 (importlib.resources.files not available)
27-
# 2. NixOS/packaging edge cases where importlib.resources may not work
28-
import pkg_resources
29-
return pkg_resources.resource_filename(__name__, os.path.join('com0com', 'setup_com0com_W7_x64_signed.exe'))
20+
def get_installer():
21+
return str(
22+
Path(__file__).resolve().parent
23+
/ "com0com"
24+
/ "setup_com0com_W7_x64_signed.exe"
25+
)
3026

3127

3228
def install_com0com():
3329
this_directory = os.path.abspath(os.path.dirname(__file__))
3430
directory = os.path.join(this_directory, 'com0com')
3531
if not os.path.exists(directory):
3632
os.makedirs(directory)
37-
cmds = [get_isntaller(), '/NCRC', '/S', '/D=%s' % directory]
33+
cmds = [get_installer(), '/NCRC', '/S', '/D=%s' % directory]
3834
logging.info('running %s' % ' '.join(cmds))
3935
p = subprocess.Popen(cmds, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
4036
out, err = p.communicate()

emulator/brainflow_emulator/freeeeg32_windows.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import sys
55
import time
66

7-
from importlib.resources import files
7+
from pathlib import Path
88
from brainflow_emulator.emulate_common import TestFailureError, log_multilines
99
from brainflow_emulator.freeeeg32_emulator import Listener
1010
from serial import Serial
@@ -18,24 +18,20 @@ def read(port, num_bytes):
1818
return port.read(num_bytes)
1919

2020

21-
def get_isntaller():
22-
try:
23-
resource = files(__name__).joinpath('com0com').joinpath('setup_com0com_W7_x64_signed.exe')
24-
return str(resource)
25-
except (TypeError, AttributeError):
26-
# Fallback for:
27-
# 1. Python < 3.9 (importlib.resources.files not available)
28-
# 2. NixOS/packaging edge cases where importlib.resources may not work
29-
import pkg_resources
30-
return pkg_resources.resource_filename(__name__, os.path.join('com0com', 'setup_com0com_W7_x64_signed.exe'))
21+
def get_installer():
22+
return str(
23+
Path(__file__).resolve().parent
24+
/ "com0com"
25+
/ "setup_com0com_W7_x64_signed.exe"
26+
)
3127

3228

3329
def install_com0com():
3430
this_directory = os.path.abspath(os.path.dirname(__file__))
3531
directory = os.path.join(this_directory, 'com0com')
3632
if not os.path.exists(directory):
3733
os.makedirs(directory)
38-
cmds = [get_isntaller(), '/NCRC', '/S', '/D=%s' % directory]
34+
cmds = [get_installer(), '/NCRC', '/S', '/D=%s' % directory]
3935
logging.info('running %s' % ' '.join(cmds))
4036
p = subprocess.Popen(cmds, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
4137
out, err = p.communicate()

0 commit comments

Comments
 (0)