1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
# Copyright (C) 2017 Chris N. Richardson and Garth N. Wells
#
# This file is part of DOLFINx (https://www.fenicsproject.org)
#
# SPDX-License-Identifier: LGPL-3.0-or-later
"""Main module for DOLFINx"""
# flake8: noqa
import sys
# Template placeholder for injecting Windows dll directories in CI
# WINDOWSDLL
try:
from petsc4py import PETSc as _PETSc
# Additional sanity check that DOLFINx was built with petsc4py support.
import dolfinx.common
assert dolfinx.common.has_petsc4py
default_scalar_type = _PETSc.ScalarType # type: ignore
default_real_type = _PETSc.RealType # type: ignore
except ImportError:
import numpy as _np
default_scalar_type = _np.float64
default_real_type = _np.float64
import pusimp
def pip_uninstall_call(executable: str, dependency_pypi_name: str, dependency_actual_path: str) -> str:
"""Report to the user how to uninstall a dependency with pip."""
output = f"{executable} -m pip uninstall --break-system-packages {dependency_pypi_name}"
if dependency_actual_path.startswith("/usr"):
return f"sudo {output}"
else:
return output
pusimp.prevent_user_site_imports(
"dolfinx", "apt", "https://fenicsproject.discourse.group/",
"/usr/lib/python3/dist-packages",
["basix", "ffcx", "ufl"],
["fenics-basix", "fenics-ffcx", "fenics-ufl"],
[False, False, False],
["", "", ""],
pip_uninstall_call
)
del pip_uninstall_call, pusimp
from dolfinx import common
from dolfinx import cpp as _cpp
from dolfinx import fem, geometry, graph, io, jit, la, log, mesh, nls, plot, utils
from dolfinx.common import (
git_commit_hash,
has_adios2,
has_complex_ufcx_kernels,
has_debug,
has_kahip,
has_parmetis,
has_petsc,
has_petsc4py,
has_ptscotch,
has_slepc,
ufcx_signature,
)
from dolfinx.cpp import __version__
_cpp.common.init_logging(sys.argv)
del _cpp, sys
def get_include(user=False):
import os
d = os.path.dirname(__file__)
if os.path.exists(os.path.join(d, "wrappers")):
# Package is installed
return os.path.join(d, "wrappers")
else:
# Package is from a source directory
return os.path.join(os.path.dirname(d), "src")
__all__ = [
"fem",
"common",
"geometry",
"graph",
"io",
"jit",
"la",
"log",
"mesh",
"nls",
"plot",
"utils",
"git_commit_hash",
"has_adios2",
"has_complex_ufcx_kernels",
"has_debug",
"has_kahip",
"has_parmetis",
"has_petsc",
"has_petsc4py",
"has_ptscotch",
"has_slepc",
"ufcx_signature",
]
|