Suggested change to dolfinx python package (wheel.license-files)

Hello. I have been building dolfinx 0.8.x for some time, and I would like to share that my installation works better when python/pyproject.toml has this:

cp -av "${_base_dir}"/{COPYING*,} "${_base_dir}"/python
from 59bcec35da
diff --git a/python/pyproject.toml b/python/pyproject.toml
index 68fcb70d43..cf0a8d4da4 100644
--- a/python/pyproject.toml
+++ b/python/pyproject.toml
@@ -15,9 +15,9 @@ build-backend = ""
 name = "fenics-dolfinx"
 version = "0.8.0.dev0"
 description = "DOLFINx Python interface"
-readme = "../"
+readme = ""
 requires-python = ">=3.9.0"
-license = { file = "../COPYING.LESSER" }
+license = { file = "COPYING.LESSER" }
 authors = [
       { email = "" },
       { name = "FEniCS Steering Council" },
@@ -52,7 +52,7 @@ ci = [
 wheel.packages = ["dolfinx"]
 sdist.exclude = ["*.cpp"] = "Release"
-wheel.license-files = ["../COPYING*"]
+wheel.license-files = ["COPYING*"]
 junit_family = "xunit2"

I do not have accounts with GitHub (Microsoft). If you want to use the code above, I don’t need attribution. If it’s not useful, that’s ok : ) . Thanks for FEniCS.

What does that mean?

The fear I have with what you propose is that the typical user will forget to run the cp instruction, and thus the installation will not work.

I’ll get the specific error message, but it happens during the installation with a PKGBUILD (pacman-based distro e.g. Parabola, Artix or Arch). The package is built and installed without pip, but with python build and install. In this type of distribution, that is the standard way.

Right now, I don’t have access to the code (my dog ate my Internet… can’t reach the repo). Trying to remember correctly, it may be hatchling (?) which tries to create the directory containing the target files. In this case, the file is ../COPYING. It fails, because the parent folder ../ already exists, and cannot be created again.

I agree: the user should not need to copy the file. It was mostly to show how I go around it.

It’s normal to have some patches for packaging, we have them for Debian/Ubuntu too. Some of them, like the one you propose, are not really meant to be integrated upstream.

1 Like

For completeness, here is the error message:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/lib/python3.11/site-packages/installer/", line 98, in <module>
    _main(sys.argv[1:], "python -m installer")
  File "/usr/lib/python3.11/site-packages/installer/", line 94, in _main
    installer.install(source, destination, {})
  File "/usr/lib/python3.11/site-packages/installer/", line 109, in install
    record = destination.write_file(
  File "/usr/lib/python3.11/site-packages/installer/", line 207, in write_file
    return self.write_to_fs(scheme, path_, stream, is_executable)
  File "/usr/lib/python3.11/site-packages/installer/", line 171, in write_to_fs
  File "<frozen os>", line 225, in makedirs
FileExistsError: [Errno 17] File exists: '/build-dir/dolfinx/pkg/dolfinx-git/usr/lib/python3.11/site-packages/fenics_dolfinx-0.8.0.dev0.dist-info/licenses/..'

The directories may be a little bit scrambled (they are automatically set by the building environment, and I am trying to reproduce them manually), but hopefully, this shows the logic

  # build
  cd /build-dir/dolfinx/src
    -S "${_base}"/cpp
    -B "${build_dir}"
  cmake ${CONFOPTS[@]}

  cmake --build "${build_dir}" --target all --parallel

  # package
  DESTDIR="${pkgdir}" cmake --install "${_base}"/cpp/build

  cd /build-dir/dolfinx/src/${_base}/python
  python -m build --wheel --no-isolation --skip-dependency-check
  PYTHONPYCACHEPREFIX="${PWD}/.cache/cpython/" \
                     python -m installer --destdir="$pkgdir" dist/*.whl