Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize setup.py #262

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
properties added, if block added
ademhilmibozkurt committed Dec 16, 2024
commit fdc84855ddad845043c9ebeeb824bc7ce88fc03b
18 changes: 17 additions & 1 deletion homebrew.py
Original file line number Diff line number Diff line change
@@ -17,11 +17,23 @@ def libdirs(self):
def incdirs(self):
return self._incdirs

@property
def homebrew_version(self):
return self._homebrew_version

@property
def homebrew_netsnmp_version(self):
return self._netsnmp_version

@property
def homebrew_openssl_version(self):
return self._openssl_version

def _check_brew_isinstalled(self):
# Check if brew is installed via: `brew --version` it should return something like: `Homebrew 4.4.5`
try:
homebrew_version = check_output("brew --version", shell=True).decode()

self._homebrew_version = homebrew_version
except CalledProcessError:
print("Homebrew isn't installed...")
pass
@@ -66,8 +78,11 @@ def _get_homebrew_net_snmp_info(self):
brew = check_output(
"brew info net-snmp", shell=True
).decode() # this may cause error

self._netsnmp_version = brew
openssl_ver = self._get_openssl_ver(self, brew)
self._append_openssl_paths(self, openssl_ver)

except CalledProcessError:
print("A brew command failed...")
pass
@@ -86,6 +101,7 @@ def _get_openssl_ver(self, brew) -> list:
),
)
)[0]
self._openssl_version = openssl_ver

return openssl_ver

20 changes: 12 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
@@ -67,20 +67,24 @@
libdirs = [flag[2:] for flag in s_split(netsnmp_libs) if flag[:2] == "-L"]
incdirs = ["ezsnmp/include/"]

print(f"libs: {libs}")
print(f"libdirs: {libdirs}")
print(f"incdirs: {incdirs}")

hb = HomeBrew()
hb.libdirs = libdirs
hb.incdirs = incdirs
if hb.libdirs and hb.incdirs:
libdirs = hb.libdirs
incdirs = hb.incdirs
homebrew_version = hb.homebrew_version
homebrew_netsnmp_version = hb.homebrew_netsnmp_version
homebrew_openssl_version = hb.homebrew_openssl_version

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}")
print(f"homebrew_version: {str(homebrew_version).strip()}")
print(f"homebrew_netsnmp_version: {homebrew_netsnmp_version}")
print(f"homebrew_openssl_version: {homebrew_openssl_version}")
print(f"libs: {libs}")
print(f"libdirs: {libdirs}")
print(f"incdirs: {incdirs}")


class RelinkLibraries(BuildCommand):