Skip to content
Snippets Groups Projects
Commit d2c87885 authored by Stefan Possanner's avatar Stefan Possanner
Browse files

Merge branch 'compile-c' into 'master'

Compile with language C by default

See merge request !18
parents 28535464 1b1317c7
No related branches found
No related tags found
1 merge request!18Compile with language C by default
Pipeline #183993 passed
## Version 1.1.3
## Version 1.2.0
* Add compile flag `--conda-warnings off` only if pyccel version is 1.8.0 or greater.
\ No newline at end of file
* Compile with language C by default.
* Added command line options, seen with `compile-gvec-tp -h`
* The "--compiler" option can now take the four compilers available in pyccel ("GNU" is the default, "intel", "PGI", "nvidia").
Moreover, a JSON file can be specified to define a custom compiler (see pyccel doc).
\ No newline at end of file
......@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "gvec-to-python"
version = "1.1.3"
version = "1.2.0"
readme = "README.md"
requires-python = ">=3.7"
license = {file = "LICENSE"}
......@@ -21,13 +21,14 @@ classifiers = [
"Programming Language :: Python :: 3",
]
dependencies = [
'matplotlib>=3.3.3',
'numpy>=1.19.5',
'pandas>=1.2.1',
'matplotlib',
'numpy',
'pandas',
'pyccel',
'scipy>=1.6.0',
'tqdm>=4.56.0',
'vtk>=9.0.3',
'scipy',
'tqdm',
'vtk',
'argcomplete',
]
[project.urls]
......
......@@ -5,6 +5,8 @@
PYTHON := python3
SO_EXT := $(shell $(PYTHON) -c "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))")
LIBDIR := $(shell $(PYTHON) -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")
install_path := $(shell $(PYTHON) -c "import gvec_to_python as _; print(_.__path__[0])")
FLAGS := --libdir $(LIBDIR) $(flags)
#--------------------------------------
......@@ -28,10 +30,10 @@ OUTPUTS := $(SOURCES:.py=$(SO_EXT))
all: $(OUTPUTS)
$(BK)$(SO_EXT) : $(BK).py
pyccel $< $(FLAGS)
pyccel $(FLAGS) $<
$(BEV1)$(SO_EXT) : $(BEV1).py $(BK)$(SO_EXT)
pyccel $< $(FLAGS)
pyccel $(FLAGS) $<
#--------------------------------------
......
......@@ -4,23 +4,85 @@ def compile_gvec_to_python():
import os
import gvec_to_python
import pyccel
import argparse
import importlib.metadata
import argcomplete
libpath = gvec_to_python.__path__[0]
# setup argument parser
parser = argparse.ArgumentParser(prog='gvec_to_python',
description='3D MHD equilibria from GVEC in Python.')
# version message
__version__ = importlib.metadata.version("gvec_to_python")
version_message = f'gvec_to_python {__version__}\n'
version_message += 'Copyright 2022 (c) T.K. Cheng, F. Hindenlang, S. Possanner | Max Planck Institute for Plasma Physics\n'
version_message += 'MIT license\n'
# arguments
parser.add_argument('-v', '--version', action='version',
version=version_message)
# pyccel flags
flags = ''
parser.add_argument('--language',
type=str,
metavar='LANGUAGE',
help='either "c" (default) or "fortran"',
default='c')
parser.add_argument('--compiler',
type=str,
metavar='COMPILER',
help='either "GNU" (default), "intel", "PGI", "nvidia" or the path to a JSON compiler file.',
default='GNU')
parser.add_argument('-d', '--delete',
help='remove .f90/.c and .so files (for running pure Python code)',
action='store_true')
parser.add_argument('--verbose',
help='call pyccel with --verbose compiler option',
action='store_true')
_li = pyccel.__version__.split('.')
_num = int(_li[0])*100 + int(_li[1])*10 + int(_li[2])
if _num >= 180:
flags += '--conda-warnings off'
# parse argument
argcomplete.autocomplete(parser)
args = parser.parse_args()
kwargs = vars(args)
libpath = gvec_to_python.__path__[0]
if any([s == ' ' for s in libpath]):
raise NameError(
f'gvec-to.python installation path MUST NOT contain blank spaces. Please rename "{libpath}".')
if kwargs['delete']:
# (change dir not to be in source path)
print('\nDeleting .f90/.c and .so files ...')
subprocess.run(['make',
'clean',
'-f',
os.path.join(libpath, 'Makefile'),
], check=True, cwd=libpath)
print('Done.')
print('\nCompiling gvec-to-python kernels ...')
subprocess.run(['make',
'-f',
os.path.join(libpath, 'Makefile'),
'flags=' + flags,
'install_path=' + libpath,
], check=True, cwd=libpath)
print('Done.')
else:
# pyccel flags
flags = '--language=' + kwargs['language']
flags += ' --compiler=' + kwargs['compiler']
_li = pyccel.__version__.split('.')
_num = int(_li[0])*100 + int(_li[1])*10 + int(_li[2])
if _num >= 180:
flags += ' --conda-warnings off'
if kwargs['verbose']:
flags += ' --verbose'
print('\nCompiling gvec-to-python kernels ...')
subprocess.run(['make',
'-f',
os.path.join(libpath, 'Makefile'),
'flags=' + flags,
'install_path=' + libpath,
], check=True, cwd=libpath)
print('Done.')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment