-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fadd0b1
commit 2c82386
Showing
10 changed files
with
275 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,53 @@ | ||
from subprocess import CalledProcessError, check_output | ||
|
||
from hatch_cython.config.platform import PlatformArgs | ||
from hatch_cython.constants import POSIX_CORE | ||
from hatch_cython.utils import aarch, memo, plat | ||
|
||
BREW = "brew" | ||
|
||
|
||
@memo | ||
def brew_path(): | ||
if plat() == "darwin": | ||
# no user input - S603 is false positive | ||
try: | ||
proc = check_output([BREW, "--prefix"]) # noqa: S603 | ||
except CalledProcessError: | ||
proc = None | ||
dec = proc.decode().replace("\n", "") if proc else None | ||
if dec and dec != "": | ||
return dec | ||
return "/opt/homebrew" if aarch() == "arm64" else "/usr/local" | ||
|
||
|
||
def get_default_link(): | ||
return [ | ||
PlatformArgs(arg="-L/opt/homebrew/lib", platforms=POSIX_CORE, depends_path=True), | ||
base = [ | ||
PlatformArgs(arg="-L/usr/local/lib", platforms=POSIX_CORE, depends_path=True), | ||
PlatformArgs(arg="-L/usr/local/opt", platforms=POSIX_CORE, depends_path=True), | ||
] | ||
|
||
brew = brew_path() | ||
if brew: | ||
base.extend( | ||
[ | ||
PlatformArgs(arg=f"-L{brew}/opt", platforms=POSIX_CORE, depends_path=True), | ||
PlatformArgs(arg=f"-L{brew}/lib", platforms=POSIX_CORE, depends_path=True), | ||
] | ||
) | ||
return base | ||
|
||
|
||
def get_default_compile(): | ||
return [ | ||
base = [ | ||
PlatformArgs(arg="-O2"), | ||
PlatformArgs(arg="-I/opt/homebrew/include", platforms=POSIX_CORE, depends_path=True), | ||
PlatformArgs(arg="-I/usr/local/include", platforms=POSIX_CORE, depends_path=True), | ||
] | ||
brew = brew_path() | ||
if brew: | ||
base.extend( | ||
[ | ||
PlatformArgs(arg=f"-I{brew}/include", platforms=POSIX_CORE, depends_path=True), | ||
] | ||
) | ||
return base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.