Skip to content

Commit

Permalink
Only add pip platform option on Intel mac and Rosetta 2
Browse files Browse the repository at this point in the history
  • Loading branch information
xxyzz committed Jan 15, 2022
1 parent c3a73ef commit 48cfde8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ Please read [CONTRIBUTING](./docs/CONTRIBUTING.md).

```
$ brew install python
// or install Command Line Tools
$ xcode-select --install
```

- Windows: use Chocolatey or download from https://www.python.org/downloads
Expand Down
15 changes: 8 additions & 7 deletions deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def __init__(self, model, plugin_path, notif):
self.model_v = '3.2.0'
self.plugin_path = plugin_path
self.notif = notif
self.machine = platform.machine()
self.which_python()
self.install_x_ray_deps()

Expand All @@ -26,12 +27,12 @@ def which_python(self):
py = 'py' if shutil.which('py') else 'python'
elif ismacos:
# stupid macOS loses PATH when calibre is not launched in terminal
py_paths = ['/opt/homebrew/bin/python3', # ARM
'/usr/local/bin/python3', # x86-64
'/usr/bin/python3'] # Command Line Tools
py_paths = [p for p in py_paths if Path(p).exists()]
if py_paths:
py = py_paths[0]
if self.machine == 'arm64':
py = '/opt/homebrew/bin/python3'
else:
py = '/usr/local/bin/python3'
if not shutil.which(py):
py = '/usr/bin/python3' # Command Line Tools
command = 'import platform;' \
'print(".".join(platform.python_version_tuple()[:2]))'
r = subprocess.run([py, '-c', command], check=True,
Expand Down Expand Up @@ -83,7 +84,7 @@ def pip_args(self, pkg, pkg_version, compiled, url):
args.append('win_amd64')
else:
raise Exception('32BIT_CALIBRE')
elif ismacos:
elif ismacos and self.machine == 'x86_64':
# prevent command line tool's pip from compiling package
args.extend(['--platform', 'macosx_10_9_x86_64'])
if url:
Expand Down

0 comments on commit 48cfde8

Please sign in to comment.