-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- fix for PyPi test builds. Need to try catch the brew version command.
- Loading branch information
1 parent
ae7abb6
commit d186005
Showing
1 changed file
with
63 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
compile_args = ["-std=c++17", "-Werror", "-Wno-unguarded-availability-new"] | ||
link_args = [] | ||
netsnmp_version = check_output("net-snmp-config --version", shell=True).decode() | ||
homebrew_version = None | ||
|
||
for arg in argv: | ||
if arg.startswith("--debug"): | ||
|
@@ -70,69 +71,75 @@ | |
print(f"libdirs: {libdirs}") | ||
print(f"incdirs: {incdirs}") | ||
|
||
# Check if brew is installed via: `brew --version` it should return something like: `Homebrew 4.4.5` | ||
homebrew_version = check_output("brew --version", shell=True).decode() | ||
if search(r"Homebrew (\d+\.\d+\.\d+)", homebrew_version): | ||
# Check if net-snmp is installed via Brew | ||
try: | ||
brew = check_output("brew list net-snmp 2>/dev/null", shell=True).decode() | ||
lines = brew.splitlines() | ||
include_dir = list(filter(lambda l: "include/net-snmp" in l, lines))[0] | ||
incdirs.append(include_dir[: include_dir.index("include/net-snmp") + 7]) | ||
|
||
if platform == "darwin": | ||
lib_dir = list(filter(lambda l: "lib/libnetsnmp.dylib" in l, lines))[0] | ||
libdirs.append(lib_dir[: lib_dir.index("lib/libnetsnmp.dylib") + 3]) | ||
|
||
# The homebrew version also depends on the Openssl keg | ||
brew = check_output("brew info net-snmp", shell=True).decode() | ||
openssl_ver = list( | ||
filter( | ||
lambda o: "openssl" in o, | ||
*map( | ||
str.split, | ||
filter( | ||
lambda l: "openssl" in l, | ||
str(brew.replace("'", "")).split("\n"), | ||
try: | ||
# Check if brew is installed via: `brew --version` it should return something like: `Homebrew 4.4.5` | ||
homebrew_version = check_output("brew --version", shell=True).decode() | ||
if search(r"Homebrew (\d+\.\d+\.\d+)", homebrew_version): | ||
# Check if net-snmp is installed via Brew | ||
try: | ||
brew = check_output("brew list net-snmp 2>/dev/null", shell=True).decode() | ||
lines = brew.splitlines() | ||
include_dir = list(filter(lambda l: "include/net-snmp" in l, lines))[0] | ||
incdirs.append(include_dir[: include_dir.index("include/net-snmp") + 7]) | ||
|
||
if platform == "darwin": | ||
lib_dir = list(filter(lambda l: "lib/libnetsnmp.dylib" in l, lines))[0] | ||
libdirs.append(lib_dir[: lib_dir.index("lib/libnetsnmp.dylib") + 3]) | ||
|
||
# The homebrew version also depends on the Openssl keg | ||
brew = check_output("brew info net-snmp", shell=True).decode() | ||
openssl_ver = list( | ||
filter( | ||
lambda o: "openssl" in o, | ||
*map( | ||
str.split, | ||
filter( | ||
lambda l: "openssl" in l, | ||
str(brew.replace("'", "")).split("\n"), | ||
), | ||
), | ||
), | ||
) | ||
)[0] | ||
|
||
brew = check_output( | ||
"brew info {0}".format(openssl_ver), shell=True | ||
).decode() | ||
temp = brew.split("\n") | ||
# As of 06/04/2024 brew info openssl spits out lines. the fifth one is what we care about | ||
# This works for now, but we need a better solution | ||
# ==> openssl@3: stable 3.3.0 (bottled) | ||
# Cryptography and SSL/TLS Toolkit | ||
# https://openssl.org/ | ||
# Installed | ||
# /opt/homebrew/Cellar/openssl@3/3.3.0 (6,977 files, 32.4MB) * | ||
# Poured from bottle using the formulae.brew.sh API on 2024-06-04 at 21:17:37 | ||
# From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/o/[email protected] | ||
# License: Apache-2.0 | ||
# ... | ||
# print(temp) | ||
temp_path = str(temp[4].split("(")[0]).strip() | ||
|
||
libdirs.append(temp_path + "/lib") | ||
incdirs.append(temp_path + "/include") | ||
|
||
print(f"libdirs: {libdirs}") | ||
print(f"incdirs: {incdirs}") | ||
print(f"openssl_ver: {openssl_ver}") | ||
|
||
except CalledProcessError: | ||
print("A brew command failed...") | ||
pass | ||
) | ||
)[0] | ||
|
||
brew = check_output( | ||
"brew info {0}".format(openssl_ver), shell=True | ||
).decode() | ||
temp = brew.split("\n") | ||
# As of 06/04/2024 brew info openssl spits out lines. the fifth one is what we care about | ||
# This works for now, but we need a better solution | ||
# ==> openssl@3: stable 3.3.0 (bottled) | ||
# Cryptography and SSL/TLS Toolkit | ||
# https://openssl.org/ | ||
# Installed | ||
# /opt/homebrew/Cellar/openssl@3/3.3.0 (6,977 files, 32.4MB) * | ||
# Poured from bottle using the formulae.brew.sh API on 2024-06-04 at 21:17:37 | ||
# From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/o/[email protected] | ||
# License: Apache-2.0 | ||
# ... | ||
# print(temp) | ||
temp_path = str(temp[4].split("(")[0]).strip() | ||
|
||
libdirs.append(temp_path + "/lib") | ||
incdirs.append(temp_path + "/include") | ||
|
||
print(f"libdirs: {libdirs}") | ||
print(f"incdirs: {incdirs}") | ||
print(f"openssl_ver: {openssl_ver}") | ||
|
||
except CalledProcessError: | ||
print("A brew command failed...") | ||
pass | ||
|
||
except CalledProcessError: | ||
print("Homebrew isn't installed...") | ||
pass | ||
|
||
print(f"in_tree: {in_tree}") | ||
print(f"compile_args: {compile_args}") | ||
print(f"link_args: {link_args}") | ||
print(f"platform: {platform}") | ||
print(f"netsnmp_version: {netsnmp_version}") | ||
print(f"homebrew_version: {homebrew_version}") | ||
|
||
|
||
class RelinkLibraries(BuildCommand): | ||
|