-
Notifications
You must be signed in to change notification settings - Fork 235
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
[WIP] Add a command to install CyIpopt #1474
Conversation
idaes/config.py
Outdated
[oe.get("LD_LIBRARY_PATH", ""), bin_directory] | ||
[ | ||
oe.get("LD_LIBRARY_PATH", ""), | ||
bin_directory, | ||
# We add .idaes/bin/lib to LD_LIBRARY_PATH to pick up any libraries | ||
# we introduced by unpacking the idaes-local tar.gz file. This | ||
# directory should be changed when/if the IDAES extensions directory | ||
# structure changes (e.g. to .idaes/lib). -RBP | ||
os.path.join(bin_directory, "lib"), | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is necessary (or at all beneficial), as the CyIpopt library appears to use the value of the appropriate variable at Python-start-up-time, rather than (somehow) using os.environ
.
tars_to_unpack = list(ptar) | ||
idaes_local_tarname = f"idaes-local-{platform}.tar.gz" | ||
if "darwin" in idaes_local_tarname: | ||
# We neglected to change the name of the idaes-local tar.gz file from *aarch64 | ||
# to *arm64 on ARM Mac, so we have to manually patch the name here. I believe | ||
# this is fixed in the idaes-ext main branch, so this can be removed when | ||
# we update to binaries compiled from this branch. -RBP | ||
idaes_local_tarname = idaes_local_tarname.replace("aarch64", "arm64") | ||
idaes_local_tarname = os.path.join(to_path, idaes_local_tarname) | ||
# In addition to the tar.gz files we downloaded, we want to unpack the idaes-local | ||
# tar.gz file. This is included in idaes-solvers, so we can unpack it in the same | ||
# directory after we've unpacked idaes-solvers. | ||
tars_to_unpack.append(idaes_local_tarname) | ||
links = {} | ||
for n, p in zip(pname, ptar): | ||
for p in tars_to_unpack: | ||
_log.debug(f"Extracting files in {p} to {to_path}") | ||
with tarfile.open(p, "r") as f: | ||
_verify_tar_member_targets(f, to_path, links) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we unpack idaes-local*
into .idaes/bin
, but I think there is no real reason not to unpack it into .idaes
, in which case we would end up with bin, lib, include, and share subdirectories of .idaes
.
A downside of unpacking idaes-local*
is that now we actually distribute two copies of libipopt.so
: one in .idaes/bin
, and one in idaes/bin/lib
... This will be fixed in new versions of idaes-ext.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1474 +/- ##
==========================================
- Coverage 76.38% 76.33% -0.06%
==========================================
Files 394 394
Lines 65121 65167 +46
Branches 14427 14436 +9
==========================================
+ Hits 49745 49747 +2
- Misses 12813 12858 +45
+ Partials 2563 2562 -1 ☔ View full report in Codecov by Sentry. |
Marking as WIP for now. As it stands, this may not be worth it compared to the alternative of simply documenting all the steps that are necessary to build CyIpopt with IDAES binaries. If we could do everything in a single command, I think it would be worth it. The barrier to this is loading our IPOPT library without relying on a library path from the environment. This may be possible with a patch to CyIpopt? Also, this command should be tested in our CI for Mac, Linux, and Windows. |
Closing as I'm not actively working on this. Will re-open if it looks like this will be worth the effort. |
Fixes
In conjuction with #1473, addresses part of IDAES/idaes-ext#261. (Not sure if this works on Windows...)
Summary/Motivation:
CyIpopt needs to be able to find a copy of the Ipopt shared library and header files, which it does (at least on Linux and Mac) using
pkg-config
. To install with Ipopt in a non-standard location (such as IDAES's Ipopt), we need to set thePKG_CONFIG_PATH
environment variable (to include.idaes/bin/lib/pkgconfig
, which will likely change in new idaes-ext releases). To make this a little bit easier for users, I propose to add a command to install CyIpopt in the current Python environment, e.g.:This basically just runs
pip install cyipopt
withPKG_CONFIG_PATH
set appropriately.I believe users will still need to set
LD_LIBRARY_PATH
(orDYLD_LIBRARY_PATH
/PATH
on Mac/Windows) to actually use CyIpopt.import idaes
does set these variables, but I believeimport cyipopt
uses the value of the variables at the time the Python process started, not the current values inos.environ
.This will only work with idaes-ext 3.4.2
Changes proposed in this PR:
idaes-local*
when theget-extensions
command is runinstall-cyipopt
commandLegal Acknowledgement
By contributing to this software project, I agree to the following terms and conditions for my contribution: