How to add cyipopt to Docker Fenicsx environment

Dear All,
I am using Pycharm and Fenicsx from the Docker remote interpreter. Now I would like to add cyipopt in my environment. Unfortunately, cyipopt is not available as a package that can be installed via pip. It is available as install in anaconda. I see two ways to proceed:

  1. Install cyipopt in anaconda. I did this but then I have the situation that somehow I need to tell Pycharm to look for the Fenicsx functions in Docker and look for the cyipopt functions in Anaconda (from anaconda import cyipopt; from docker import dolfinx, but these statements are not possible). How can I resolve this problem?
  2. Build my own docker image which includes cyipopt. I am new to docker so I do not know much. In my directory β€œdocker4fenicsx” there are 4 subdirectories: basix, dolfinx, ffcx, ufl. The Dockerfile is located in dolfinx/docker. But cyipopt is not available as a package, so my questions are:
  • what do I need to do to create cyipopt so that it can be included in my own build?
  • what lines of code do I need to add to the Dockerfile and where? Perhaps something similar to this (but then substituting cyipopt for xtl; this is a guess):
    RUN git clone -b ${XTL_VERSION} --single-branch --depth 1 GitHub - xtensor-stack/xtl: The x template library &&
    cd xtl &&
    cmake -G Ninja . &&
    ninja install &&
    rm -rf /tmp/*

If possible, I would prefer option 1 (seems least error prone).

1 Like

Hi michiel,

Regarding 1. you cannot β€œmix and match” Python environments. Either you have everything installed in anaconda Python, or everything installed in the docker Python.

Regarding 2. You can simply build any extra software you need on top of our existing images by writing your own Dockerfile and using our image as the base image.

FROM dolfinx/dolfinx:v0.5.0

RUN <your shell commands to install cyipopt>

Hi Jack,

Thanks for the reply.
I created a Dockerfile with the following content:

FROM dolfinx/dolfinx:v0.5.0

RUN pip3 install --no-cache-dir cyipopt

I execute it using: docker build -t myimage .

Extracting dolfinx works fine, but I get errors when trying to add cyipopt. It seems some file is missing (Package ipopt was not found in the pkg-config search path):

C:\Users\michi\Documents\TUE\docker4fenicsx>docker build -t myimage .
[+] Building 103.0s (5/5) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 107B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/dolfinx/dolfinx:v0.5.0 2.1s
=> [1/2] FROM docker.io/dolfinx/dolfinx:v0.5.0@sha256:1d6f1589082314b1f239efb8dfc85d7245c20d05c67754e91400a8c82 97.0s
=> => resolve docker.io/dolfinx/dolfinx:v0.5.0@sha256:1d6f1589082314b1f239efb8dfc85d7245c20d05c67754e91400a8c82b 0.0s
=> => sha256:c8a734c5dcfc287bfc771d5118447861a754d89a267bb33a79bb21f72123af78 21.41kB / 21.41kB 0.0s
=> => sha256:855ab12da7478edde949734288afe4558f7eb1908b521c751c9624dc04f3158a 590.31MB / 590.31MB 44.6s
=> => sha256:1d6f1589082314b1f239efb8dfc85d7245c20d05c67754e91400a8c82bc64e74 743B / 743B 0.0s
=> => sha256:2bda86ec4585a2d6ecf7f85c3d3bac4693a6dedd34f896554e47997dcdf9b0df 3.48kB / 3.48kB 0.0s
=> => sha256:817f304a786d927f75393960e3d39d2603d1e0b275113a9825530bdd9c1a1a9a 28.28MB / 28.28MB 3.2s
=> => sha256:ad31d547c4fa6aa08f4585095c51db482844443469c7625b06eefc0123164754 181.28MB / 181.28MB 22.8s
=> => sha256:5e7311608b7fbccd2c8fadae966e01c4eaa376b3dd16cac1a057f6da2dc6d5d8 364.00kB / 364.00kB 3.5s
=> => sha256:03b896a421c6715d33b4df5747e984a2417f928e664d1d1cf7495f6fd9b6d030 11.23MB / 11.23MB 4.9s
=> => sha256:6918cdb990ab4d2cf942ce467236014da657d992129ad4e6a1aec71947570a82 40.87MB / 40.87MB 12.1s
=> => sha256:f4654c21976f4f77a2c82d4c569871fa2aa3125a3e0acdeb28e178d3da8d4299 5.10MB / 5.10MB 13.7s
=> => sha256:b1e31cb34545f6b0711e3b365b7672ae9acf040416f59c4f5a1afdde6af1ceb1 12.72MB / 12.72MB 15.8s
=> => sha256:48e5a837012444474a5cf27d913cbbb474ef7f9d99ce11ebdd986a0fedfad21b 127.77MB / 127.77MB 31.7s
=> => sha256:5ab09367c15ead8b7b9e6354991a1a0904a9305966bcadf3633c7b1b348db015 14.65MB / 14.65MB 25.5s
=> => sha256:4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1 32B / 32B 25.7s
=> => sha256:3f0175c3521d3ce98713962945e4baa1c1c587043315d5b070fb309b1739a18c 44.14MB / 44.14MB 31.1s
=> => sha256:03331ccd2afa9fe740b166a398a60003556bebe95950caaa3c5b6bb4b0b16ddb 286B / 286B 31.8s
=> => extracting sha256:855ab12da7478edde949734288afe4558f7eb1908b521c751c9624dc04f3158a 28.5s
=> => extracting sha256:817f304a786d927f75393960e3d39d2603d1e0b275113a9825530bdd9c1a1a9a 1.4s
=> => extracting sha256:ad31d547c4fa6aa08f4585095c51db482844443469c7625b06eefc0123164754 9.4s
=> => extracting sha256:5e7311608b7fbccd2c8fadae966e01c4eaa376b3dd16cac1a057f6da2dc6d5d8 0.1s
=> => extracting sha256:03b896a421c6715d33b4df5747e984a2417f928e664d1d1cf7495f6fd9b6d030 0.4s
=> => extracting sha256:6918cdb990ab4d2cf942ce467236014da657d992129ad4e6a1aec71947570a82 1.5s
=> => extracting sha256:f4654c21976f4f77a2c82d4c569871fa2aa3125a3e0acdeb28e178d3da8d4299 0.3s
=> => extracting sha256:b1e31cb34545f6b0711e3b365b7672ae9acf040416f59c4f5a1afdde6af1ceb1 0.6s
=> => extracting sha256:48e5a837012444474a5cf27d913cbbb474ef7f9d99ce11ebdd986a0fedfad21b 5.3s
=> => extracting sha256:5ab09367c15ead8b7b9e6354991a1a0904a9305966bcadf3633c7b1b348db015 1.0s
=> => extracting sha256:4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1 0.0s
=> => extracting sha256:3f0175c3521d3ce98713962945e4baa1c1c587043315d5b070fb309b1739a18c 2.2s
=> => extracting sha256:03331ccd2afa9fe740b166a398a60003556bebe95950caaa3c5b6bb4b0b16ddb 0.0s
=> ERROR [2/2] RUN pip3 install --no-cache-dir cyipopt 3.8s

[2/2] RUN pip3 install --no-cache-dir cyipopt:
#5 1.073 Collecting cyipopt
#5 1.175 Downloading cyipopt-1.1.0.tar.gz (44 kB)
#5 1.197 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 44.6/44.6 KB 1.8 MB/s eta 0:00:00
#5 1.210 Preparing metadata (setup.py): started
#5 2.721 Preparing metadata (setup.py): finished with status β€˜error’
#5 2.728 error: subprocess-exited-with-error
#5 2.728
#5 2.728 Γ— python setup.py egg_info did not run successfully.
#5 2.728 β”‚ exit code: 1
#5 2.728 ╰─> [16 lines of output]
#5 2.728 /usr/lib/python3/dist-packages/setuptools/installer.py:27: SetuptoolsDeprecationWarning: setuptools.installer is deprecated. Requirements should be satisfied by a PEP 517 installer.
#5 2.728 warnings.warn(
#5 2.728 Package ipopt was not found in the pkg-config search path.
#5 2.728 Perhaps you should add the directory containing `ipopt.pc’
#5 2.728 to the PKG_CONFIG_PATH environment variable
#5 2.728 No package β€˜ipopt’ found
#5 2.728 Traceback (most recent call last):
#5 2.728 File β€œβ€, line 2, in
#5 2.728 File β€œβ€, line 34, in
#5 2.728 File β€œ/tmp/pip-install-5b9holof/cyipopt_3158ea35ba084579b650459fd682324c/setup.py”, line 192, in
#5 2.728 ext_module_data = handle_ext_modules_general_os()
#5 2.728 File β€œ/tmp/pip-install-5b9holof/cyipopt_3158ea35ba084579b650459fd682324c/setup.py”, line 171, in handle_ext_modules_general_os
#5 2.728 **pkgconfig(β€œipopt”))
#5 2.728 File β€œ/tmp/pip-install-5b9holof/cyipopt_3158ea35ba084579b650459fd682324c/setup.py”, line 105, in pkgconfig
#5 2.728 raise OSError(msg.format(list(packages)))
#5 2.728 OSError: pkg-config was not able to find any of the requested packages [β€˜ipopt’] on your system. Make sure pkg-config can discover the .pc files associated with the installed packages.
#5 2.728 [end of output]
#5 2.728
#5 2.728 note: This error originates from a subprocess, and is likely not a problem with pip.
#5 2.730 error: metadata-generation-failed
#5 2.730
#5 2.730 Γ— Encountered error while generating package metadata.
#5 2.730 ╰─> See above for output.
#5 2.730
#5 2.730 note: This is an issue with the package mentioned above, not pip.
#5 2.730 hint: See above for details.


executor failed running [/bin/sh -c pip3 install --no-cache-dir cyipopt]: exit code: 1

What should I do to fix this error? I have no idea how to proceed…
Interestingly, when I install cyipopt in anaconda I do not get these errors.

See here for more info on how to resolve this: python setup.py failed Β· Issue #38 Β· mechmotum/cyipopt (github.com)