File tree Expand file tree Collapse file tree 4 files changed +21
-11
lines changed
Expand file tree Collapse file tree 4 files changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -15,8 +15,8 @@ Install using `pip`:
1515python -m pip install pyoslog
1616```
1717
18- The module will install and import without error on earlier macOS versions.
19- Use ` pyoslog.is_supported() ` if you need to support old macOS versions and want to know at runtime whether to use pyoslog.
18+ The module will install and import without error on earlier macOS versions (and on unsupported Operating Systems and Python versions) .
19+ Use ` pyoslog.is_supported() ` if you need to support old macOS versions or other environments and want to know at runtime whether to use pyoslog.
2020Please note that if ` is_supported() ` returns ` False ` then none of the module's other methods or constants will exist.
2121
2222
@@ -92,4 +92,4 @@ A `log.h` binding is on that project's [roadmap](https://github.com/ronaldoussor
9292
9393
9494## License
95- [ Apache 2.0] ( LICENSE )
95+ [ Apache 2.0] ( https://github.com/simonrob/pyoslog/blob/main/ LICENSE)
Original file line number Diff line number Diff line change 11__title__ = 'pyoslog'
2- __version__ = '0.3 .0'
2+ __version__ = '0.4 .0'
33__description__ = 'Send messages to the macOS unified logging system'
44__author__ = 'Simon Robinson'
55__author_email__ = '[email protected] '
Original file line number Diff line number Diff line change @@ -6,4 +6,5 @@ def is_supported():
66 """Unified logging is only present in macOS 10.12 and later, but it is nicer to not have to check OS type or version
77 strings when installing or importing the module - use this method at runtime to check whether it is supported. It is
88 important to note that if is_supported() is False then none of the module's other methods/constants will exist."""
9- return sys .platform == 'darwin' and float ('.' .join (platform .mac_ver ()[0 ].split ('.' )[:2 ])) >= 10.12
9+ return sys .platform == 'darwin' and sys .version_info >= (3 , 0 ,) and float (
10+ '.' .join (platform .mac_ver ()[0 ].split ('.' )[:2 ])) >= 10.12
Original file line number Diff line number Diff line change 1- import importlib .util
21import os
32
43from setuptools import setup , Extension
1312with open ('README.md' ) as readme_file :
1413 readme = readme_file .read ()
1514
16- # see compatibility.py - allow installation on older versions but provide is_supported() at runtime
17- spec = importlib .util .spec_from_file_location ('compatibility' , os .path .join (working_directory , 'compatibility.py' ))
18- compatibility = importlib .util .module_from_spec (spec )
19- spec .loader .exec_module (compatibility )
15+ # see compatibility.py - allow installation on older versions (or other OSs) but provide is_supported() at runtime
16+ compatibility_module_name = 'compatibility'
17+ compatibility_module_path = os .path .join (working_directory , '%s.py' % compatibility_module_name )
18+ try :
19+ # noinspection PyUnresolvedReferences
20+ import importlib .util
21+
22+ spec = importlib .util .spec_from_file_location (compatibility_module_name , compatibility_module_path )
23+ compatibility = importlib .util .module_from_spec (spec )
24+ spec .loader .exec_module (compatibility )
25+ except ImportError :
26+ import imp
27+
28+ compatibility = imp .load_source (compatibility_module_name , compatibility_module_path )
29+
2030ext_modules = []
21- # noinspection PyUnresolvedReferences
2231if compatibility .is_supported ():
2332 ext_modules .append (Extension ('_' + NAME , ['%s/_%s.c' % (NAME , NAME )]))
2433
You can’t perform that action at this time.
0 commit comments