Skip to content

Commit

Permalink
Remove extensions from setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
nbouziani committed Jan 21, 2024
1 parent d09486b commit 3e14805
Showing 1 changed file with 32 additions and 34 deletions.
66 changes: 32 additions & 34 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,50 +1,48 @@

import os
import sys

import petsc4py
import numpy as np
# import os
# import sys

from pathlib import Path
from setuptools import setup, find_packages, Extension
from Cython.Distutils import build_ext
from setuptools import setup, find_packages
# from setuptools import setup, find_packages, Extension
# from Cython.Distutils import build_ext


# Read README's content
dir = Path(__file__).parent
long_description = (dir / "README.md").read_text()

# List of Cython extensions
cythonfiles = [("adjacency_dofs", ["petsc"])]
# # List of Cython extensions
# cythonfiles = [("adjacency_dofs", ["petsc"])]


def get_petsc_dir():
try:
petsc_dir = os.environ["PETSC_DIR"]
petsc_arch = os.environ.get("PETSC_ARCH", "")
except KeyError:
try:
petsc_dir = os.path.join(os.environ["VIRTUAL_ENV"], "src", "petsc")
petsc_arch = "default"
except KeyError:
sys.exit("""Error: Firedrake venv not active.""")
# def get_petsc_dir():
# try:
# petsc_dir = os.environ["PETSC_DIR"]
# petsc_arch = os.environ.get("PETSC_ARCH", "")
# except KeyError:
# try:
# petsc_dir = os.path.join(os.environ["VIRTUAL_ENV"], "src", "petsc")
# petsc_arch = "default"
# except KeyError:
# sys.exit("""Error: Firedrake venv not active.""")

return (petsc_dir, os.path.join(petsc_dir, petsc_arch))
# return (petsc_dir, os.path.join(petsc_dir, petsc_arch))


petsc_dirs = get_petsc_dir()
if os.environ.get("HDF5_DIR"):
petsc_dirs = petsc_dirs + (os.environ.get("HDF5_DIR"), )
include_dirs = [np.get_include(), petsc4py.get_include()]
include_dirs += ["%s/include" % d for d in petsc_dirs]
dirs = (sys.prefix, *petsc_dirs)
link_args = ["-L%s/lib" % d for d in dirs] + ["-Wl,-rpath,%s/lib" % d for d in dirs]
# petsc_dirs = get_petsc_dir()
# if os.environ.get("HDF5_DIR"):
# petsc_dirs = petsc_dirs + (os.environ.get("HDF5_DIR"), )
# include_dirs = [np.get_include(), petsc4py.get_include()]
# include_dirs += ["%s/include" % d for d in petsc_dirs]
# dirs = (sys.prefix, *petsc_dirs)
# link_args = ["-L%s/lib" % d for d in dirs] + ["-Wl,-rpath,%s/lib" % d for d in dirs]

extensions = [Extension("physics_driven_ml.utils.graph.{}".format(ext),
sources=[os.path.join("physics_driven_ml", "utils", "graph", "{}.pyx".format(ext))],
include_dirs=include_dirs,
libraries=libs,
extra_link_args=link_args) for (ext, libs) in cythonfiles]
# extensions = [Extension("physics_driven_ml.utils.graph.{}".format(ext),
# sources=[os.path.join("physics_driven_ml", "utils", "graph", "{}.pyx".format(ext))],
# include_dirs=include_dirs,
# libraries=libs,
# extra_link_args=link_args) for (ext, libs) in cythonfiles]


setup(
Expand All @@ -57,6 +55,6 @@ def get_petsc_dir():
author_email="[email protected]",
packages=find_packages(),
install_requires=["tqdm"],
cmdclass=dict(build_ext=build_ext),
ext_modules=extensions,
# cmdclass=dict(build_ext=build_ext),
# ext_modules=extensions,
)

0 comments on commit 3e14805

Please sign in to comment.