Skip to content

Commit 34a284a

Browse files
Modernising install process: added pyproject and removed distutils deps
1 parent 3742b88 commit 34a284a

File tree

3 files changed

+53
-12
lines changed

3 files changed

+53
-12
lines changed

AUTHORS.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

pyproject.toml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[project]
2+
name = "fidimag"
3+
dynamic = ["version"]
4+
description = "Atomistic and Finite-DIfference microMAGnetic code, based on Python, Cython and C "
5+
readme = "README.md"
6+
license-files = ["LICENSE.txt"]
7+
license = "BSD-2-Clause"
8+
requires-python = ">= 3.10"
9+
dependencies = [
10+
'numpy',
11+
'scipy',
12+
'cython>=3.0.0',
13+
'pytest',
14+
'matplotlib',
15+
'ipywidgets',
16+
'pyvtk',
17+
'ipython',
18+
'psutil'
19+
]
20+
authors = [
21+
{ name = "Weiwei Wang" },
22+
{ name = "David Cortes Ortuno" },
23+
{ name = "Ryan Pepper" },
24+
{ name = "Hans Fangohr" },
25+
{ name = "Marc-Antonio Bisotti" },
26+
{ name = "Thomas Kluyver" },
27+
{ name = "Mark Vousden" },
28+
{ name = "Oliver Laslett" },
29+
{ name = "Rebecca Carey" },
30+
]
31+
32+
maintainers = [
33+
{name = "David Cortes Ortuno", email = "[email protected]"},
34+
{name = "Ryan Pepper"}
35+
]
36+
37+
[build-system]
38+
build-backend = "setuptools.build_meta"
39+
requires = [
40+
"setuptools",
41+
"numpy",
42+
"cython>=3.0.0",
43+
]

setup.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from distutils.core import setup
2-
from distutils.extension import Extension
1+
from setuptools import setup
2+
from setuptools import Extension
33
import multiprocessing
44
from Cython.Build import cythonize
55
import numpy
@@ -17,8 +17,10 @@ class BuildError(Exception):
1717
os.environ["CC"] = "gcc"
1818
print("Using CC={} (set by setup.py)".format(os.environ['CC']))
1919

20-
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
20+
# setup.py requires relative paths:
21+
MODULE_DIR = os.path.dirname(os.path.relpath(__file__))
2122
SRC_DIR = os.path.join(MODULE_DIR, "fidimag")
23+
#
2224
SUNDIALS_DIR = os.path.join(SRC_DIR, "common", "sundials")
2325
NEB_DIR = os.path.join(SRC_DIR, "common", "neb")
2426
NEBM_DIR = os.path.join(SRC_DIR, "common", "neb_method")
@@ -50,9 +52,6 @@ def get_version():
5052
raise Exception("Couldn't find __version__ in %s" % pkg_init_path)
5153

5254

53-
version = get_version()
54-
55-
5655
def glob_cfiles(path, excludes, extension="*.c"):
5756
cfiles = []
5857
for cfile in glob.glob(os.path.join(path, extension)):
@@ -231,10 +230,11 @@ def glob_cfiles(path, excludes, extension="*.c"):
231230
)
232231
]
233232

234-
233+
yellow = "\x1b[33;49m"
234+
reset = "\x1b[0m"
235235
for folder in glob.glob(os.path.join(USER_DIR, '*/')):
236236
module_name = folder.split('/')[-2]
237-
print('Found User Module: {}'.format(module_name))
237+
print(yellow + f'Found User Module: {module_name}' + reset)
238238
user_sources = glob.glob(folder + '/*.pyx')
239239
if len(user_sources) != 1:
240240
raise BuildError("User Modules are only allowed one Cython .pyx file")
@@ -259,11 +259,10 @@ def glob_cfiles(path, excludes, extension="*.c"):
259259
)
260260

261261
nthreads = multiprocessing.cpu_count()
262-
print('Building with {} threads'.format(nthreads))
262+
print(yellow + f'Building with {nthreads} threads' + reset)
263263
setup(
264264
name='fidimag',
265-
version=version,
266-
description='Atomistic and finite-difference-micromagnetics code',
265+
version=get_version(),
267266
packages=['fidimag',
268267
'fidimag.atomistic',
269268
'fidimag.micro',

0 commit comments

Comments
 (0)