Skip to content

Commit 178c50b

Browse files
committed
Java classpath separator should be ';' on Windows
See https://stackoverflow.com/a/60211688 for an explanation of this. Fixes #31.
1 parent ec5bcfb commit 178c50b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

zxing/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import pathlib
1212
import re
1313
import subprocess as sp
14+
import sys
1415
import urllib.parse
1516
import zipfile
1617
from enum import Enum
@@ -41,18 +42,19 @@ def __init__(self, message, filename=None):
4142

4243
class BarCodeReader(object):
4344
cls = "com.google.zxing.client.j2se.CommandLineRunner"
45+
classpath_sep = ';' if sys.platform == 'nt' else ':' # https://stackoverflow.com/a/60211688
4446

4547
def __init__(self, classpath=None, java=None):
4648
self.java = java or 'java'
4749
self.zxing_version = self.zxing_version_info = None
4850
if classpath:
49-
self.classpath = classpath if isinstance(classpath, str) else ':'.join(classpath)
51+
self.classpath = classpath if isinstance(classpath, str) else self.classpath_sep.join(classpath)
5052
elif "ZXING_CLASSPATH" in os.environ:
5153
self.classpath = os.environ.get("ZXING_CLASSPATH", "")
5254
else:
5355
self.classpath = os.path.join(os.path.dirname(__file__), 'java', '*')
5456

55-
for fn in chain.from_iterable(glob.glob(cp) for cp in self.classpath.split(':')):
57+
for fn in chain.from_iterable(glob.glob(cp) for cp in self.classpath.split(self.classpath_sep)):
5658
if os.path.basename(fn) == 'core.jar':
5759
self.core_jar = fn
5860
with zipfile.ZipFile(self.core_jar) as c:

0 commit comments

Comments
 (0)