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

pip installation error #34

Open
theonov13 opened this issue Sep 14, 2023 · 9 comments
Open

pip installation error #34

theonov13 opened this issue Sep 14, 2023 · 9 comments

Comments

@theonov13
Copy link

Hi,

I'm aiming to install mpi4py-fft using pip.
However, I ended up with the following error

[...]
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
    cimport fftwf_xfftn
            ^
    ------------------------------------------------------------
    
    mpi4py_fft/fftw/fftwf_xfftn.pyx:1:8: 'fftwf_xfftn.pxd' not found

[...]
 Cython.Compiler.Errors.CompileError: /scratch/pip-build-bwiiwole/mpi4py-fft/mpi4py_fft/fftw/fftwf_xfftn.pyx

The error is reproducible under various conditions

  • mpi4py_fft versions (master, 2.0.5 - 2.0.0)
  • gnu compiler version (11, 9)
  • python version (3.6,3.7,3.9,3.10)
  • operating systems (Ubuntu 22.04.3 LTS, Red Hat Enterprise Linux release 8.6 (Ootpa))

I would be grateful for any hint on how to resolve this issue.

Best,
Sebastian

@theonov13
Copy link
Author

Checking out dalcinl/cython3, i.e.,

git checkout dalcinl/cython3
python3 -m pip install -e .

seems to solve this issue.
Thus someone might want to merge these changes into main. ;)

@gurcani
Copy link

gurcani commented Feb 1, 2024

Thanks!
This was driving me nuts.

@benlandrum
Copy link

There is a PR #30 up for this.

@benlandrum
Copy link

The author looks pretty busy. @dalcinl, let me know if I can help. Thanks for all your work.

@dalcinl
Copy link
Member

dalcinl commented Mar 29, 2024

@benlandrum Yes, I'm quite busy, my open source workload is becoming unbearable. Are you able to build locally with the changes in #30? Maybe we should think of making a release that solves build issues, and address any issues with our CI infrastructure later.

@benlandrum
Copy link

I'm able to make on Python 3.12 after patching the setup.py file according to remove distutils and grab a compiler according to pypa/setuptools#2806 (comment).

The fix is probably version-dependent, so it'd benefit from CI. How bad are the CI problems right now?

@benlandrum
Copy link

index d05d89b..983c06c 100644
--- a/setup.py
+++ b/setup.py
@@ -6,7 +6,6 @@ import sys
 import re
 import platform
 import sysconfig
-from distutils import ccompiler
 from setuptools import setup
 from setuptools.dist import Distribution
 from setuptools.extension import Extension
@@ -58,9 +57,29 @@ def get_library_dirs():
         append(dirs, prefix, 'lib')
     return dirs
 
+def get_compiler():
+    """
+    Return a new compiler.
+
+    From https://github.com/pypa/setuptools/issues/2806#issuecomment-961805789.
+    """
+    build_ext = Distribution().get_command_obj("build_ext")
+    build_ext.finalize_options()
+
+    # Register an extension to ensure a compiler is created.
+    build_ext.extensions = [Extension("ignored", ["ignored.c"])]
+
+    # Disable building fake extensions.
+    build_ext.build_extensions = lambda: None
+
+    # Populate self.compiler.
+    build_ext.run()
+
+    return build_ext.compiler
+
 def get_fftw_libs():
     """Return FFTW libraries"""
-    compiler = ccompiler.new_compiler()
+    compiler = get_compiler()
     library_dirs = get_library_dirs()
     libs = {}
     for d in ('float', 'double', 'long double'):

@benlandrum
Copy link

Enabled the pipelines on a fork of mine https://github.com/benlandrum/mpi4py-fft. Will give them a shot and get back to you. Running into numpy module problems, likely familiar to you.

@benlandrum
Copy link

My patch above was probably in the wrong direction. Please ignore.

I started from your branch and edited the FFTW setup. It now runs on all Python versions, all MPI implementations, and on Ubuntu and macOS.

Please let me know what you think, @dalcinl.
#40

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants