Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TetraX
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Micromagnetic modeling
TetraX
Commits
1f806626
Commit
1f806626
authored
1 month ago
by
Kakay, Dr. Attila (FWIN) - 9524
Browse files
Options
Downloads
Patches
Plain Diff
Added C extensions similar to setup.py as an extension to the toml file.
parent
4eb34c35
No related branches found
Branches containing commit
No related tags found
2 merge requests
!88
Release of 2.0.0
,
!87
Replacing setup.py with pyproject.toml
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
_custom_build.py
+75
-0
75 additions, 0 deletions
_custom_build.py
pyproject.toml
+8
-24
8 additions, 24 deletions
pyproject.toml
with
83 additions
and
24 deletions
_custom_build.py
0 → 100644
+
75
−
0
View file @
1f806626
import
os
import
platform
from
pathlib
import
Path
from
setuptools
import
Extension
from
setuptools.command.build_py
import
build_py
as
_build_py
from
numpy
import
get_include
MODULE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
LOCAL_DIR
=
os
.
path
.
join
(
MODULE_DIR
,
"
local
"
)
LIB_DIR
=
os
.
path
.
join
(
LOCAL_DIR
,
"
lib
"
)
LIB_DIR64
=
os
.
path
.
join
(
LOCAL_DIR
,
"
lib64
"
)
print
(
MODULE_DIR
)
fem_core_path
=
Path
(
"
../tetrax/sample/mesh/fem_core
"
).
resolve
()
c_sourcefiles
=
[
str
(
fem_core_path
/
p
)
for
p
in
[
"
dense2D_onthefly.c
"
,
"
bessel_K1.c
"
,
"
akmag.c
"
,
"
rotation_mat.c
"
,
"
matutils.c
"
,
"
sorting.c
"
,
"
utils.c
"
,
"
bnd2d.c
"
,
"
opmatspm.c
"
,
"
galerkin.c
"
,
"
fempreproc.c
"
,
"
hotriang.c
"
,
"
dense3D.c
"
,
"
integration_of_functions.c
"
,
]
]
compiler_extra_args
=
[
"
-O3
"
,
"
-Wno-cpp
"
,
"
-Wno-unused-function
"
,
"
-Wall
"
]
if
platform
.
system
()
==
"
Windows
"
:
compiler_extra_args
=
[]
# compiler_extra_args.append("-fopenmp")
compiler_extra_args
.
append
(
"
-std=c99
"
)
#compiler_extra_links = ["-Wl,-rpath,{},-rpath,{}".format(LIB_DIR, LIB_DIR64)]
# com_link.append('-fopenmp')
class
build_py
(
_build_py
):
def
run
(
self
):
self
.
run_command
(
"
build_ext
"
)
return
super
().
run
()
def
initialize_options
(
self
):
super
().
initialize_options
()
if
self
.
distribution
.
ext_modules
==
None
:
self
.
distribution
.
ext_modules
=
[]
self
.
distribution
.
ext_modules
.
append
(
Extension
(
"
tetrax.sample.mesh.fem_core.cythoncore
"
,
sources
=
[
*
c_sourcefiles
,
"
tetrax/sample/mesh/fem_core/cythoncore.pyx
"
],
libraries
=
[],
library_dirs
=
[],
include_dirs
=
[
str
(
fem_core_path
),
"
main
"
,
get_include
()],
extra_compile_args
=
compiler_extra_args
,
# extra_link_args=compiler_extra_links,
)
#
# Extension(
# "termial_random.random",
# sources=["termial_random/random.c"],
# extra_compile_args=["-std=c17", "-lm"],
# )
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
pyproject.toml
+
8
−
24
View file @
1f806626
[build-system]
[build-system]
requires
=
[
"setuptools"
,
"cython"
]
requires
=
[
"setuptools"
,
"cython"
,
"numpy"
]
build-backend
=
"setuptools.build_meta"
build-backend
=
"setuptools.build_meta"
[project]
[project]
...
@@ -32,11 +32,18 @@ dependencies = [
...
@@ -32,11 +32,18 @@ dependencies = [
"pooch"
,
"pooch"
,
]
]
[tool.setuptools]
py-modules
=
[
"_custom_build"
]
[tool.setuptools.cmdclass]
build_py
=
"_custom_build.build_py"
[project.optional-dependencies]
[project.optional-dependencies]
#dev = ["pytest", "pre-commit", "nbsphinx", "pydata-sphinx-theme", "jupyterlab"]
#dev = ["pytest", "pre-commit", "nbsphinx", "pydata-sphinx-theme", "jupyterlab"]
#torch = ["torch", "torchdiffeq"]
#torch = ["torch", "torchdiffeq"]
#jax = ["jax[cuda]>=0.4.31", "diffrax", "optax"]
#jax = ["jax[cuda]>=0.4.31", "diffrax", "optax"]
[tool.setuptools.packages.find]
[tool.setuptools.packages.find]
#include = ["neuralmag*"]
#include = ["neuralmag*"]
...
@@ -47,26 +54,3 @@ dependencies = [
...
@@ -47,26 +54,3 @@ dependencies = [
#profile = "black"
#profile = "black"
#skip_gitignore = true # ignores files listed in .gitignore
#skip_gitignore = true # ignores files listed in .gitignore
#skip_glob = ["/neuralmag/field_terms/code/*"]
#skip_glob = ["/neuralmag/field_terms/code/*"]
[tool.setuptools]
ext-modules
=
[
{name
=
"tetrax.sample.mesh.fem_core.cythoncore"
,
sources
=
[
"tetrax/sample/mesh/fem_core/cythoncore.pyx"
,
"tetrax/sample/mesh/fem_core/dense2D_onthefly.c"
,
"tetrax/sample/mesh/fem_core/bessel_K1.c"
,
"tetrax/sample/mesh/fem_core/akmag.c"
,
"tetrax/sample/mesh/fem_core/rotation_mat.c"
,
"tetrax/sample/mesh/fem_core/matutils.c"
,
"tetrax/sample/mesh/fem_core/sorting.c"
,
"tetrax/sample/mesh/fem_core/utils.c"
,
"tetrax/sample/mesh/fem_core/bnd2d.c"
,
"tetrax/sample/mesh/fem_core/opmatspm.c"
,
"tetrax/sample/mesh/fem_core/galerkin.c"
,
"tetrax/sample/mesh/fem_core/fempreproc.c"
,
"tetrax/sample/mesh/fem_core/hotriang.c"
,
"tetrax/sample/mesh/fem_core/dense3D.c"
,
"tetrax/sample/mesh/fem_core/integration_of_functions.c"
]
}
]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment