Skip to content

Commit 0a5476b

Browse files
setup.py: made OS-detection more consistent.
Use just platform.system().
1 parent 492f900 commit 0a5476b

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

setup.py

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -518,14 +518,23 @@ def get_mupdf():
518518
extra_link_args = []
519519
extra_compile_args = []
520520

521+
log( f'platform.system()={platform.system()!r}')
522+
log( f'sys.platform={sys.platform!r}')
523+
524+
linux = platform.system() == 'Linux'
525+
openbsd = platform.system() == 'OpenBSD'
526+
freebsd = platform.system() == 'FreeBSD'
527+
darwin = platform.system() == 'Darwin'
528+
windows = platform.system() == 'Windows' or platform.system().startswith('CYGWIN')
529+
521530
if 'sdist' in sys.argv:
522531
# Create local mupdf.tgz, for inclusion in sdist.
523532
get_mupdf_tgz()
524533

525534

526535
if ('-h' not in sys.argv and '--help' not in sys.argv
527-
and (
528-
'bdist_wheel' in sys.argv
536+
and (0
537+
or 'bdist_wheel' in sys.argv
529538
or 'build' in sys.argv
530539
or 'bdist' in sys.argv
531540
or 'install' in sys.argv
@@ -560,7 +569,7 @@ def get_mupdf():
560569
log( f'Building mupdf.')
561570
shutil.copy2( 'fitz/_config.h', f'{mupdf_local}include/mupdf/fitz/config.h')
562571

563-
if platform.system() == 'Windows' or platform.system().startswith('CYGWIN'):
572+
if windows:
564573
# Windows build.
565574
devenv = os.environ.get('PYMUPDF_SETUP_DEVENV')
566575
if not devenv:
@@ -587,9 +596,9 @@ def get_mupdf():
587596
flags += ' verbose=yes'
588597
env = ''
589598
make = 'make'
590-
if os.uname()[0] == 'Linux':
599+
if linux:
591600
env += ' CFLAGS="-fPIC"'
592-
if os.uname()[0] in ('OpenBSD', 'FreeBSD'):
601+
if openbsd or freebsd:
593602
make = 'gmake'
594603
env += ' CFLAGS="-fPIC" CXX=clang++'
595604

@@ -646,13 +655,6 @@ def get_mupdf():
646655
if unix_build_dir:
647656
library_dirs.append( unix_build_dir)
648657

649-
log( f'sys.platform={sys.platform!r}')
650-
651-
linux = sys.platform.startswith( 'linux') or 'gnu' in sys.platform
652-
openbsd = sys.platform.startswith( 'openbsd')
653-
freebsd = sys.platform.startswith( 'freebsd')
654-
darwin = sys.platform.startswith( 'darwin')
655-
656658
if mupdf_local and (linux or openbsd or freebsd):
657659
# setuptools' link command always seems to put '-L
658660
# /usr/local/lib' before any <library_dirs> that we specify,
@@ -703,13 +705,13 @@ def get_mupdf():
703705

704706
library_dirs.append("/opt/homebrew/lib")
705707

706-
if sys.platform.startswith( 'freebsd'):
708+
if freebsd:
707709
libraries += [
708710
'freetype',
709711
'harfbuzz',
710712
]
711713

712-
else:
714+
elif windows:
713715
# Windows.
714716
assert mupdf_local
715717
if word_size() == 32:
@@ -725,6 +727,9 @@ def get_mupdf():
725727
]
726728
extra_link_args = ["/NODEFAULTLIB:MSVCRT"]
727729

730+
else:
731+
assert 0, 'Unrecognised OS'
732+
728733
if linux or openbsd or freebsd or darwin:
729734
extra_compile_args.append( '-Wno-incompatible-pointer-types')
730735
extra_compile_args.append( '-Wno-pointer-sign')
@@ -742,13 +747,6 @@ def get_mupdf():
742747
include_dirs += local_dirs.get("include_dirs", [])
743748
library_dirs += local_dirs.get("library_dirs", [])
744749

745-
if 1:
746-
# Diagnostics.
747-
log( f'library_dirs={library_dirs}')
748-
log( f'libraries={libraries}')
749-
log( f'include_dirs={include_dirs}')
750-
log( f'extra_link_args={extra_link_args}')
751-
752750
log( f'include_dirs={include_dirs}')
753751
log( f'library_dirs={library_dirs}')
754752
log( f'libraries={libraries}')

0 commit comments

Comments
 (0)