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

Compile with language C by default, added console options

parent 28535464
Branches
Tags
1 merge request!18Compile with language C by default
Pipeline #183991 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. * Compile with language C by default.
\ No newline at end of file * 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" ...@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project] [project]
name = "gvec-to-python" name = "gvec-to-python"
version = "1.1.3" version = "1.2.0"
readme = "README.md" readme = "README.md"
requires-python = ">=3.7" requires-python = ">=3.7"
license = {file = "LICENSE"} license = {file = "LICENSE"}
...@@ -21,13 +21,14 @@ classifiers = [ ...@@ -21,13 +21,14 @@ classifiers = [
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",
] ]
dependencies = [ dependencies = [
'matplotlib>=3.3.3', 'matplotlib',
'numpy>=1.19.5', 'numpy',
'pandas>=1.2.1', 'pandas',
'pyccel', 'pyccel',
'scipy>=1.6.0', 'scipy',
'tqdm>=4.56.0', 'tqdm',
'vtk>=9.0.3', 'vtk',
'argcomplete',
] ]
[project.urls] [project.urls]
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
PYTHON := python3 PYTHON := python3
SO_EXT := $(shell $(PYTHON) -c "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))") 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'))") 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) FLAGS := --libdir $(LIBDIR) $(flags)
#-------------------------------------- #--------------------------------------
...@@ -28,10 +30,10 @@ OUTPUTS := $(SOURCES:.py=$(SO_EXT)) ...@@ -28,10 +30,10 @@ OUTPUTS := $(SOURCES:.py=$(SO_EXT))
all: $(OUTPUTS) all: $(OUTPUTS)
$(BK)$(SO_EXT) : $(BK).py $(BK)$(SO_EXT) : $(BK).py
pyccel $< $(FLAGS) pyccel $(FLAGS) $<
$(BEV1)$(SO_EXT) : $(BEV1).py $(BK)$(SO_EXT) $(BEV1)$(SO_EXT) : $(BEV1).py $(BK)$(SO_EXT)
pyccel $< $(FLAGS) pyccel $(FLAGS) $<
#-------------------------------------- #--------------------------------------
......
...@@ -4,23 +4,85 @@ def compile_gvec_to_python(): ...@@ -4,23 +4,85 @@ def compile_gvec_to_python():
import os import os
import gvec_to_python import gvec_to_python
import pyccel 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 parser.add_argument('--language',
flags = '' 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('.') # parse argument
_num = int(_li[0])*100 + int(_li[1])*10 + int(_li[2]) argcomplete.autocomplete(parser)
if _num >= 180: args = parser.parse_args()
flags += '--conda-warnings off' 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 ...') else:
subprocess.run(['make', # pyccel flags
'-f', flags = '--language=' + kwargs['language']
os.path.join(libpath, 'Makefile'), flags += ' --compiler=' + kwargs['compiler']
'flags=' + flags,
'install_path=' + libpath, _li = pyccel.__version__.split('.')
], check=True, cwd=libpath) _num = int(_li[0])*100 + int(_li[1])*10 + int(_li[2])
print('Done.') 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