From 3e21484e5c8476572a6743af78d8acf52dd43def Mon Sep 17 00:00:00 2001 From: jalvesz Date: Sat, 20 Apr 2024 10:42:03 +0200 Subject: [PATCH 01/17] start replacement of deployement sh script by python script --- ci/fpm.toml | 2 + ci/fypp_deployment.py | 205 ++++++++++++++++++++++++++++++++++++++++++ ci/requirements.txt | 2 + 3 files changed, 209 insertions(+) create mode 100644 ci/fypp_deployment.py create mode 100644 ci/requirements.txt diff --git a/ci/fpm.toml b/ci/fpm.toml index 6a0509007..bf8dfc530 100644 --- a/ci/fpm.toml +++ b/ci/fpm.toml @@ -11,3 +11,5 @@ test-drive.tag = "v0.4.0" [preprocess] [preprocess.cpp] +suffixes = [".F90", ".f90"] +macros = ["MAXRANK=7"] diff --git a/ci/fypp_deployment.py b/ci/fypp_deployment.py new file mode 100644 index 000000000..f4258e53d --- /dev/null +++ b/ci/fypp_deployment.py @@ -0,0 +1,205 @@ +import os +import shutil +import fypp +import argparse +from joblib import Parallel, delayed + +def copy_folder_with_filter(source_folder, destination_folder, filter_list=None, filter_suffix=None): + # Create destination folder if it doesn't exist + if not os.path.exists(destination_folder): + os.makedirs(destination_folder) + + # Iterate over the files and folders in the source folder + for item in os.listdir(source_folder): + source_item = os.path.join(source_folder, item) + destination_item = os.path.join(destination_folder, item) + + # If it's a folder, recursively copy it + if os.path.isdir(source_item): + copy_folder_with_filter(source_item, destination_item, filter_list, filter_suffix) + else: + # If filter_list is provided, check if the filename is in the list to avoid it + should_copy = False if filter_list and item in filter_list else True + should_copy = False if filter_suffix and item.endswith(filter_suffix) else should_copy + if should_copy: + shutil.copy2(source_item, destination_item) + +def pre_process_toml(args): + """ + Pre-process the fpm.toml + """ + from tomlkit import table, dumps + data = table() + data.add("name", "stdlib") + data.add("version", str(args.vmajor)+ + "."+str(args.vminor)+ + "."+str(args.vpatch) ) + data.add("license", "MIT") + data.add("author", "stdlib contributors") + data.add("maintainer", "@fortran-lang/stdlib") + data.add("copyright", "2019-2021 stdlib contributors") + + if(args.with_blp): + build = table() + build.add("link", ["lapack", "blas"] ) + data.add("build", build) + + dev_dependencies = table() + dev_dependencies.add("test-drive", {"git" : "https://github.com/fortran-lang/test-drive", + "tag" : "v0.4.0"}) + data.add("dev-dependencies", dev_dependencies) + + preprocess = table() + preprocess.add("cpp", {} ) + preprocess['cpp'].add("suffixes", [".F90", ".f90"] ) + preprocess['cpp'].add("macros", ["MAXRANK="+str(args.maxrank)] ) + data.add("preprocess", preprocess) + + if args.destdir == 'stdlib-fpm': + if not os.path.exists('stdlib-fpm'): + os.makedirs('stdlib-fpm') + name = 'stdlib-fpm'+os.sep+'fpm.toml' + else: + name = "fpm.toml" + with open(name, "w") as f: + f.write(dumps(data)) + return + +C_PREPROCESSED = ( + "stdlib_linalg_constants" , + "stdlib_linalg_blas" , + "stdlib_linalg_blas_aux", + "stdlib_linalg_blas_s", + "stdlib_linalg_blas_d", + "stdlib_linalg_blas_q", + "stdlib_linalg_blas_c", + "stdlib_linalg_blas_z", + "stdlib_linalg_blas_w", + "stdlib_linalg_lapack", + "stdlib_linalg_lapack_aux", + "stdlib_linalg_lapack_s", + "stdlib_linalg_lapack_d", + "stdlib_linalg_lapack_q", + "stdlib_linalg_lapack_c", + "stdlib_linalg_lapack_z", + "stdlib_linalg_lapack_w" +) + +def pre_process_fypp(args): + kwd = [] + kwd.append("-DMAXRANK="+str(args.maxrank)) + kwd.append("-DPROJECT_VERSION_MAJOR="+str(args.vmajor)) + kwd.append("-DPROJECT_VERSION_MINOR="+str(args.vminor)) + kwd.append("-DPROJECT_VERSION_PATCH="+str(args.vpatch)) + if args.with_qp: + kwd.append("-DWITH_QP=True") + if args.with_xqp: + kwd.append("-DWITH_XDP=True") + + optparser = fypp.get_option_parser() + options, leftover = optparser.parse_args(args=kwd) + options.includes = ['include'] + # options.line_numbering = True + tool = fypp.Fypp(options) + + # Check destination folder for preprocessing. if not 'stdlib-fpm', it is assumed to be the root folder. + in_place = False if args.destdir == 'stdlib-fpm' else True + src = 'src' if in_place else 'stdlib-fpm'+os.sep+'src' + test = 'test' if in_place else 'stdlib-fpm'+os.sep+'test' + example = 'example' if in_place else 'stdlib-fpm'+os.sep+'example' + if not in_place: + copy_folder_with_filter('src', src, + filter_list=['CMakeLists.txt',"f18estop.f90"]) + copy_folder_with_filter('test', test, + filter_list=['CMakeLists.txt',"test_always_fail.f90", + "test_always_skip.f90","test_hash_functions.f90"], + filter_suffix='manual') + copy_folder_with_filter('example',example, + filter_list=['CMakeLists.txt']) + shutil.copy2('ci'+os.sep+'fpm.toml', 'stdlib-fpm'+os.sep+'fpm.toml') + shutil.copy2('LICENSE', 'stdlib-fpm'+os.sep+'LICENSE') + + # Define the folders to search for *.fypp files + folders = [src,test] + # Process all folders + fypp_files = [os.path.join(root, file) for folder in folders + for root, _, files in os.walk(folder) + for file in files if file.endswith(".fypp")] + + def process_f(file): + source_file = file + root = os.path.dirname(file) + basename = os.path.splitext(os.path.basename(source_file))[0] + sfx = 'f90' if basename not in C_PREPROCESSED else 'F90' + target_file = root + os.sep + basename + '.' + sfx + tool.process_file(source_file, target_file) + # if folder different from root + if not in_place: + os.remove(source_file) + + Parallel(n_jobs=args.njob)(delayed(process_f)(f) for f in fypp_files) + + return + +def fpm_build(unknown): + import subprocess + #========================================== + # check compilers + FPM_FC = os.environ['FPM_FC'] if "FPM_FC" in os.environ else "gfortran" + FPM_CC = os.environ['FPM_CC'] if "FPM_CC" in os.environ else "gcc" + FPM_CXX = os.environ['FPM_CXX'] if "FPM_CXX" in os.environ else "gcc" + #========================================== + # Filter out the macro definitions. + macros = [arg for arg in unknown if arg.startswith("-D")] + # Filter out the include paths with -I prefix. + include_paths = [arg for arg in unknown if arg.startswith("-I")] + # Filter out flags + flags = " " + for idx, arg in enumerate(unknown): + if arg.startswith("--flag"): + flags= unknown[idx+1] + #========================================== + # build with fpm + subprocess.run(["fpm build"]+ + [" --compiler "]+[FPM_FC]+ + [" --c-compiler "]+[FPM_CC]+ + [" --cxx-compiler "]+[FPM_CXX]+ + [" --flag "]+[flags], shell=True, check=True) + return + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Preprocess stdlib source files.') + # fypp arguments + parser.add_argument("--vmajor", type=int, default=0, help="Project Version Major") + parser.add_argument("--vminor", type=int, default=5, help="Project Version Minor") + parser.add_argument("--vpatch", type=int, default=0, help="Project Version Patch") + + parser.add_argument("--njob", type=int, default=4, help="Number of parallel jobs for preprocessing") + parser.add_argument("--maxrank",type=int, default=7, help="Set the maximum allowed rank for arrays") + parser.add_argument("--with_qp",type=bool, default=False, help="Include WITH_QP in the command") + parser.add_argument("--with_xqp",type=bool, default=False, help="Include WITH_XDP in the command") + + parser.add_argument('--destdir', action='store', type=str, default='stdlib-fpm', help='destination directory for the fypp preprocessing.') + # external libraries arguments + parser.add_argument("--with_blp",type=bool, default=False, help="Link against OpenBLAS") + parser.add_argument("--build",type=bool, default=False, help="Build the project") + + args, unknown = parser.parse_known_args() + #========================================== + # read current manifest + import tomlkit + with open('ci'+os.sep+'fpm.toml', 'r') as file: + manifest = tomlkit.parse(file.read()) + version = manifest['version'].split(".") + if version != ['VERSION']: + vmajor, vminor, vpatch = [int(value) for value in version] + #========================================== + # pre process the fpm manifest + #pre_process_toml(args) + #========================================== + # pre process the meta programming fypp files + pre_process_fypp(args) + #========================================== + # build using fpm + if args.build: + fpm_build(unknown) \ No newline at end of file diff --git a/ci/requirements.txt b/ci/requirements.txt new file mode 100644 index 000000000..d08247534 --- /dev/null +++ b/ci/requirements.txt @@ -0,0 +1,2 @@ +fypp +joblib \ No newline at end of file From d0da408cd99da90d117be8ca6e43bc4d34a08a82 Mon Sep 17 00:00:00 2001 From: jalvesz Date: Sat, 20 Apr 2024 10:59:56 +0200 Subject: [PATCH 02/17] copy the VERSION file --- ci/fypp_deployment.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ci/fypp_deployment.py b/ci/fypp_deployment.py index f4258e53d..adb0542df 100644 --- a/ci/fypp_deployment.py +++ b/ci/fypp_deployment.py @@ -117,6 +117,7 @@ def pre_process_fypp(args): copy_folder_with_filter('example',example, filter_list=['CMakeLists.txt']) shutil.copy2('ci'+os.sep+'fpm.toml', 'stdlib-fpm'+os.sep+'fpm.toml') + shutil.copy2('VERSION', 'stdlib-fpm'+os.sep+'VERSION') shutil.copy2('LICENSE', 'stdlib-fpm'+os.sep+'LICENSE') # Define the folders to search for *.fypp files @@ -141,7 +142,7 @@ def process_f(file): return -def fpm_build(unknown): +def fpm_build(args,unknown): import subprocess #========================================== # check compilers @@ -154,12 +155,13 @@ def fpm_build(unknown): # Filter out the include paths with -I prefix. include_paths = [arg for arg in unknown if arg.startswith("-I")] # Filter out flags - flags = " " + flags = "-cpp " for idx, arg in enumerate(unknown): if arg.startswith("--flag"): - flags= unknown[idx+1] + flags= flags + unknown[idx+1] #========================================== # build with fpm + os.chdir(args.destdir) subprocess.run(["fpm build"]+ [" --compiler "]+[FPM_FC]+ [" --c-compiler "]+[FPM_CC]+ @@ -202,4 +204,4 @@ def fpm_build(unknown): #========================================== # build using fpm if args.build: - fpm_build(unknown) \ No newline at end of file + fpm_build(args,unknown) \ No newline at end of file From e79c643620177696bc58527d89cb1eb088ac9333 Mon Sep 17 00:00:00 2001 From: jalvesz Date: Sun, 21 Apr 2024 15:14:22 +0200 Subject: [PATCH 03/17] ignore temp folders --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 144ecbe56..cec93bccf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ build/ - +temp/ # FORD generated documentation # !WARNING! This folder gets deleted and overwritten API-doc/ From 5979ae93dea194fc864c5602bbd4097f07a9ccdd Mon Sep 17 00:00:00 2001 From: jalvesz Date: Sun, 21 Apr 2024 15:15:36 +0200 Subject: [PATCH 04/17] change temp with wildcars for any level --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index cec93bccf..246122db7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ build/ -temp/ +**/temp/ # FORD generated documentation # !WARNING! This folder gets deleted and overwritten API-doc/ From 9c363d87834306be36630315c07cebf0bcb43f21 Mon Sep 17 00:00:00 2001 From: jalvesz Date: Sun, 21 Apr 2024 15:38:46 +0200 Subject: [PATCH 05/17] fypp preprocessing at root using temp subfolders --- {ci => config}/fypp_deployment.py | 64 ++++++++----------------------- {ci => config}/requirements.txt | 0 fpm.toml | 15 ++++++++ 3 files changed, 30 insertions(+), 49 deletions(-) rename {ci => config}/fypp_deployment.py (70%) rename {ci => config}/requirements.txt (100%) create mode 100644 fpm.toml diff --git a/ci/fypp_deployment.py b/config/fypp_deployment.py similarity index 70% rename from ci/fypp_deployment.py rename to config/fypp_deployment.py index adb0542df..8122ec3fd 100644 --- a/ci/fypp_deployment.py +++ b/config/fypp_deployment.py @@ -1,29 +1,8 @@ import os -import shutil import fypp import argparse from joblib import Parallel, delayed -def copy_folder_with_filter(source_folder, destination_folder, filter_list=None, filter_suffix=None): - # Create destination folder if it doesn't exist - if not os.path.exists(destination_folder): - os.makedirs(destination_folder) - - # Iterate over the files and folders in the source folder - for item in os.listdir(source_folder): - source_item = os.path.join(source_folder, item) - destination_item = os.path.join(destination_folder, item) - - # If it's a folder, recursively copy it - if os.path.isdir(source_item): - copy_folder_with_filter(source_item, destination_item, filter_list, filter_suffix) - else: - # If filter_list is provided, check if the filename is in the list to avoid it - should_copy = False if filter_list and item in filter_list else True - should_copy = False if filter_suffix and item.endswith(filter_suffix) else should_copy - if should_copy: - shutil.copy2(source_item, destination_item) - def pre_process_toml(args): """ Pre-process the fpm.toml @@ -93,7 +72,7 @@ def pre_process_fypp(args): kwd.append("-DPROJECT_VERSION_PATCH="+str(args.vpatch)) if args.with_qp: kwd.append("-DWITH_QP=True") - if args.with_xqp: + if args.with_xdp: kwd.append("-DWITH_XDP=True") optparser = fypp.get_option_parser() @@ -103,25 +82,13 @@ def pre_process_fypp(args): tool = fypp.Fypp(options) # Check destination folder for preprocessing. if not 'stdlib-fpm', it is assumed to be the root folder. - in_place = False if args.destdir == 'stdlib-fpm' else True - src = 'src' if in_place else 'stdlib-fpm'+os.sep+'src' - test = 'test' if in_place else 'stdlib-fpm'+os.sep+'test' - example = 'example' if in_place else 'stdlib-fpm'+os.sep+'example' - if not in_place: - copy_folder_with_filter('src', src, - filter_list=['CMakeLists.txt',"f18estop.f90"]) - copy_folder_with_filter('test', test, - filter_list=['CMakeLists.txt',"test_always_fail.f90", - "test_always_skip.f90","test_hash_functions.f90"], - filter_suffix='manual') - copy_folder_with_filter('example',example, - filter_list=['CMakeLists.txt']) - shutil.copy2('ci'+os.sep+'fpm.toml', 'stdlib-fpm'+os.sep+'fpm.toml') - shutil.copy2('VERSION', 'stdlib-fpm'+os.sep+'VERSION') - shutil.copy2('LICENSE', 'stdlib-fpm'+os.sep+'LICENSE') + if not os.path.exists('src'+os.sep+'temp'): + os.makedirs('src'+os.sep+'temp') + if not os.path.exists('test'+os.sep+'temp'): + os.makedirs('test'+os.sep+'temp') # Define the folders to search for *.fypp files - folders = [src,test] + folders = ['src','test'] # Process all folders fypp_files = [os.path.join(root, file) for folder in folders for root, _, files in os.walk(folder) @@ -130,13 +97,12 @@ def pre_process_fypp(args): def process_f(file): source_file = file root = os.path.dirname(file) + if not os.path.exists(root+os.sep+'temp'): + os.makedirs(root+os.sep+'temp') basename = os.path.splitext(os.path.basename(source_file))[0] sfx = 'f90' if basename not in C_PREPROCESSED else 'F90' - target_file = root + os.sep + basename + '.' + sfx + target_file = root+os.sep+'temp' + os.sep + basename + '.' + sfx tool.process_file(source_file, target_file) - # if folder different from root - if not in_place: - os.remove(source_file) Parallel(n_jobs=args.njob)(delayed(process_f)(f) for f in fypp_files) @@ -179,7 +145,7 @@ def fpm_build(args,unknown): parser.add_argument("--njob", type=int, default=4, help="Number of parallel jobs for preprocessing") parser.add_argument("--maxrank",type=int, default=7, help="Set the maximum allowed rank for arrays") parser.add_argument("--with_qp",type=bool, default=False, help="Include WITH_QP in the command") - parser.add_argument("--with_xqp",type=bool, default=False, help="Include WITH_XDP in the command") + parser.add_argument("--with_xdp",type=bool, default=False, help="Include WITH_XDP in the command") parser.add_argument('--destdir', action='store', type=str, default='stdlib-fpm', help='destination directory for the fypp preprocessing.') # external libraries arguments @@ -189,15 +155,15 @@ def fpm_build(args,unknown): args, unknown = parser.parse_known_args() #========================================== # read current manifest + with open('VERSION', 'r') as file: + version = file.read().split(".") + vmajor, vminor, vpatch = [int(value) for value in version] import tomlkit - with open('ci'+os.sep+'fpm.toml', 'r') as file: + with open('fpm.toml', 'r') as file: manifest = tomlkit.parse(file.read()) - version = manifest['version'].split(".") - if version != ['VERSION']: - vmajor, vminor, vpatch = [int(value) for value in version] #========================================== # pre process the fpm manifest - #pre_process_toml(args) + # pre_process_toml(args) #========================================== # pre process the meta programming fypp files pre_process_fypp(args) diff --git a/ci/requirements.txt b/config/requirements.txt similarity index 100% rename from ci/requirements.txt rename to config/requirements.txt diff --git a/fpm.toml b/fpm.toml new file mode 100644 index 000000000..bf8dfc530 --- /dev/null +++ b/fpm.toml @@ -0,0 +1,15 @@ +name = "stdlib" +version = "VERSION" +license = "MIT" +author = "stdlib contributors" +maintainer = "@fortran-lang/stdlib" +copyright = "2019-2021 stdlib contributors" + +[dev-dependencies] +test-drive.git = "https://github.com/fortran-lang/test-drive" +test-drive.tag = "v0.4.0" + +[preprocess] +[preprocess.cpp] +suffixes = [".F90", ".f90"] +macros = ["MAXRANK=7"] From 5f5a0587d0c6c3896e28f34f6e12d072b87d04cb Mon Sep 17 00:00:00 2001 From: jalvesz Date: Sun, 21 Apr 2024 16:05:27 +0200 Subject: [PATCH 06/17] focus on preprocessing and building --- config/fypp_deployment.py | 53 +++------------------------------------ 1 file changed, 3 insertions(+), 50 deletions(-) diff --git a/config/fypp_deployment.py b/config/fypp_deployment.py index 8122ec3fd..6e3b9c3b0 100644 --- a/config/fypp_deployment.py +++ b/config/fypp_deployment.py @@ -3,47 +3,6 @@ import argparse from joblib import Parallel, delayed -def pre_process_toml(args): - """ - Pre-process the fpm.toml - """ - from tomlkit import table, dumps - data = table() - data.add("name", "stdlib") - data.add("version", str(args.vmajor)+ - "."+str(args.vminor)+ - "."+str(args.vpatch) ) - data.add("license", "MIT") - data.add("author", "stdlib contributors") - data.add("maintainer", "@fortran-lang/stdlib") - data.add("copyright", "2019-2021 stdlib contributors") - - if(args.with_blp): - build = table() - build.add("link", ["lapack", "blas"] ) - data.add("build", build) - - dev_dependencies = table() - dev_dependencies.add("test-drive", {"git" : "https://github.com/fortran-lang/test-drive", - "tag" : "v0.4.0"}) - data.add("dev-dependencies", dev_dependencies) - - preprocess = table() - preprocess.add("cpp", {} ) - preprocess['cpp'].add("suffixes", [".F90", ".f90"] ) - preprocess['cpp'].add("macros", ["MAXRANK="+str(args.maxrank)] ) - data.add("preprocess", preprocess) - - if args.destdir == 'stdlib-fpm': - if not os.path.exists('stdlib-fpm'): - os.makedirs('stdlib-fpm') - name = 'stdlib-fpm'+os.sep+'fpm.toml' - else: - name = "fpm.toml" - with open(name, "w") as f: - f.write(dumps(data)) - return - C_PREPROCESSED = ( "stdlib_linalg_constants" , "stdlib_linalg_blas" , @@ -127,7 +86,6 @@ def fpm_build(args,unknown): flags= flags + unknown[idx+1] #========================================== # build with fpm - os.chdir(args.destdir) subprocess.run(["fpm build"]+ [" --compiler "]+[FPM_FC]+ [" --c-compiler "]+[FPM_CC]+ @@ -147,9 +105,7 @@ def fpm_build(args,unknown): parser.add_argument("--with_qp",type=bool, default=False, help="Include WITH_QP in the command") parser.add_argument("--with_xdp",type=bool, default=False, help="Include WITH_XDP in the command") - parser.add_argument('--destdir', action='store', type=str, default='stdlib-fpm', help='destination directory for the fypp preprocessing.') # external libraries arguments - parser.add_argument("--with_blp",type=bool, default=False, help="Link against OpenBLAS") parser.add_argument("--build",type=bool, default=False, help="Build the project") args, unknown = parser.parse_known_args() @@ -158,12 +114,9 @@ def fpm_build(args,unknown): with open('VERSION', 'r') as file: version = file.read().split(".") vmajor, vminor, vpatch = [int(value) for value in version] - import tomlkit - with open('fpm.toml', 'r') as file: - manifest = tomlkit.parse(file.read()) - #========================================== - # pre process the fpm manifest - # pre_process_toml(args) + args.vmajor = max(vmajor,args.vmajor) + args.vminor = max(vminor,args.vminor) + args.vpatch = max(vpatch,args.vpatch) #========================================== # pre process the meta programming fypp files pre_process_fypp(args) From a4def724c2dc0badfc6821c5d62333a2e374c71b Mon Sep 17 00:00:00 2001 From: jalvesz Date: Sun, 21 Apr 2024 16:12:58 +0200 Subject: [PATCH 07/17] preprocessor flag by compilers --- config/fypp_deployment.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/fypp_deployment.py b/config/fypp_deployment.py index 6e3b9c3b0..9c933c199 100644 --- a/config/fypp_deployment.py +++ b/config/fypp_deployment.py @@ -80,7 +80,8 @@ def fpm_build(args,unknown): # Filter out the include paths with -I prefix. include_paths = [arg for arg in unknown if arg.startswith("-I")] # Filter out flags - flags = "-cpp " + preprocessor = { 'gfortran':'-cpp ' , 'ifort':'-fpp ' , 'ifx':'-fpp ' } + flags = preprocessor[FPM_FC] for idx, arg in enumerate(unknown): if arg.startswith("--flag"): flags= flags + unknown[idx+1] From 0ede7872a13ded19b4f8d6b8beea6bbaa6824d60 Mon Sep 17 00:00:00 2001 From: jalvesz Date: Sun, 21 Apr 2024 23:31:15 +0200 Subject: [PATCH 08/17] add function to copy files after preprocessing --- config/fypp_deployment.py | 47 +++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/config/fypp_deployment.py b/config/fypp_deployment.py index 9c933c199..7e02742ce 100644 --- a/config/fypp_deployment.py +++ b/config/fypp_deployment.py @@ -24,6 +24,15 @@ ) def pre_process_fypp(args): + """use fypp to preprocess all source files. + + Processed files will be dumped at /temp/ or + + Parameters + ---------- + args : + CLI arguments. + """ kwd = [] kwd.append("-DMAXRANK="+str(args.maxrank)) kwd.append("-DPROJECT_VERSION_MAJOR="+str(args.vmajor)) @@ -67,6 +76,37 @@ def process_f(file): return + +def deploy_stdlib_fpm(): + """create the stdlib-fpm folder for backwards compatibility (to be deprecated) + """ + import shutil + prune=( + "test_always_fail.f90", + "test_always_skip.f90", + "test_hash_functions.f90", + "f18estop.f90", + ) + if not os.path.exists('stdlib-fpm'+os.sep+'src'): + os.makedirs('stdlib-fpm'+os.sep+'src') + if not os.path.exists('stdlib-fpm'+os.sep+'test'): + os.makedirs('stdlib-fpm'+os.sep+'test') + if not os.path.exists('stdlib-fpm'+os.sep+'example'): + os.makedirs('stdlib-fpm'+os.sep+'example') + + def recursive_copy(folder): + for root, _, files in os.walk(folder): + for file in files: + if file not in prune: + if file.endswith(".f90") or file.endswith(".F90") or file.endswith(".dat") or file.endswith(".npy"): + shutil.copy2(os.path.join(root, file), 'stdlib-fpm'+os.sep+folder+os.sep+file) + recursive_copy('src') + recursive_copy('test') + recursive_copy('example') + for file in ['.gitignore','fpm.toml','LICENSE','VERSION']: + shutil.copy2(file, 'stdlib-fpm'+os.sep+file) + return + def fpm_build(args,unknown): import subprocess #========================================== @@ -75,10 +115,6 @@ def fpm_build(args,unknown): FPM_CC = os.environ['FPM_CC'] if "FPM_CC" in os.environ else "gcc" FPM_CXX = os.environ['FPM_CXX'] if "FPM_CXX" in os.environ else "gcc" #========================================== - # Filter out the macro definitions. - macros = [arg for arg in unknown if arg.startswith("-D")] - # Filter out the include paths with -I prefix. - include_paths = [arg for arg in unknown if arg.startswith("-I")] # Filter out flags preprocessor = { 'gfortran':'-cpp ' , 'ifort':'-fpp ' , 'ifx':'-fpp ' } flags = preprocessor[FPM_FC] @@ -106,6 +142,7 @@ def fpm_build(args,unknown): parser.add_argument("--with_qp",type=bool, default=False, help="Include WITH_QP in the command") parser.add_argument("--with_xdp",type=bool, default=False, help="Include WITH_XDP in the command") + parser.add_argument("--deploy_stdlib_fpm",type=bool, default=False, help="create the stdlib-fpm folder") # external libraries arguments parser.add_argument("--build",type=bool, default=False, help="Build the project") @@ -121,6 +158,8 @@ def fpm_build(args,unknown): #========================================== # pre process the meta programming fypp files pre_process_fypp(args) + if args.deploy_stdlib_fpm: + deploy_stdlib_fpm() #========================================== # build using fpm if args.build: From 4ca323ecd66854a46ec737f734d849ba161a6998 Mon Sep 17 00:00:00 2001 From: jalvesz Date: Sun, 21 Apr 2024 23:32:32 +0200 Subject: [PATCH 09/17] refactor fpm action using root folder --- .github/workflows/fpm-deployment.yml | 82 ++++++++++++++-------------- 1 file changed, 40 insertions(+), 42 deletions(-) diff --git a/.github/workflows/fpm-deployment.yml b/.github/workflows/fpm-deployment.yml index de19693f2..665486ca9 100644 --- a/.github/workflows/fpm-deployment.yml +++ b/.github/workflows/fpm-deployment.yml @@ -1,51 +1,49 @@ name: fpm-deployment on: [push, pull_request] -env: - GCC_V: "10" jobs: - Build: - runs-on: ubuntu-latest + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + toolchain: {compiler: gcc, version: 13, flags: ['-cpp -O3']} steps: - - name: Checkout 🛎️ - uses: actions/checkout@v2.3.1 - - - name: Set up Python 3.x - uses: actions/setup-python@v1 - with: - python-version: 3.x - - - name: Install fypp - run: pip install --upgrade fypp - - - name: Generate stdlib-fpm package 🔧 - run: | - bash ./ci/fpm-deployment.sh - - - name: Install GFortran - run: | - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ env.GCC_V }} 100 \ - --slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${{ env.GCC_V }} \ - --slave /usr/bin/gcov gcov /usr/bin/gcov-${{ env.GCC_V }} - - - name: Install fpm latest release - uses: fortran-lang/setup-fpm@v5 - with: - fpm-version: 'v0.10.0' - - - name: Run fpm test ⚙ - run: | - cp -r stdlib-fpm stdlib-fpm-test - cd stdlib-fpm-test - fpm test - fpm test --profile release + - name: Checkout code + uses: actions/checkout@v2.3.1 + + - name: Set up Python 3.x + uses: actions/setup-python@v1 + with: + python-version: 3.x + + - name: Install requirements + run: pip install --upgrade -r config/requirements.txt + + - uses: fortran-lang/setup-fortran@main + id: setup-fortran + with: + compiler: ${{ matrix.toolchain.compiler }} + version: ${{ matrix.toolchain.version }} + + - name: Setup Fortran Package Manager + uses: fortran-lang/setup-fpm@v5 + with: + fpm-version: 'v0.10.0' + + - run: | + python config/fypp_deployment.py --deploy_stdlib_fpm + fpm test --flag "${{ join(matrix.toolchain.flags, ' ') }}" # Update and deploy the f90 files generated by github-ci to the `stdlib-fpm` branch. - - name: Deploy 🚀 - uses: JamesIves/github-pages-deploy-action@4.1.5 - if: github.event_name != 'pull_request' - with: - BRANCH: stdlib-fpm - FOLDER: stdlib-fpm + # might no longer be needed + - name: Deploy 🚀 + uses: JamesIves/github-pages-deploy-action@4.1.5 + if: github.event_name != 'pull_request' + with: + BRANCH: stdlib-fpm + FOLDER: stdlib-fpm \ No newline at end of file From 7683b327c937606dd4543fa3812718db10cb5f22 Mon Sep 17 00:00:00 2001 From: jalvesz Date: Sun, 21 Apr 2024 23:43:10 +0200 Subject: [PATCH 10/17] forgottent argument --- .github/workflows/fpm-deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fpm-deployment.yml b/.github/workflows/fpm-deployment.yml index 665486ca9..e2b8867cc 100644 --- a/.github/workflows/fpm-deployment.yml +++ b/.github/workflows/fpm-deployment.yml @@ -36,7 +36,7 @@ jobs: fpm-version: 'v0.10.0' - run: | - python config/fypp_deployment.py --deploy_stdlib_fpm + python config/fypp_deployment.py --deploy_stdlib_fpm 1 fpm test --flag "${{ join(matrix.toolchain.flags, ' ') }}" # Update and deploy the f90 files generated by github-ci to the `stdlib-fpm` branch. From e5d91dca58b555c9e88cabced7a4f3e123e238ae Mon Sep 17 00:00:00 2001 From: Jose Alves Date: Thu, 25 Apr 2024 23:18:52 +0200 Subject: [PATCH 11/17] deprecate tests always_fail and always_skip --- test/CMakeLists.txt | 7 +------ test/test_always_fail.f90 | 8 -------- test/test_always_skip.f90 | 8 -------- 3 files changed, 1 insertion(+), 22 deletions(-) delete mode 100644 test/test_always_fail.f90 delete mode 100644 test/test_always_skip.f90 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8e199182d..857aaa142 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -29,9 +29,4 @@ add_subdirectory(system) add_subdirectory(quadrature) add_subdirectory(math) add_subdirectory(stringlist) -add_subdirectory(terminal) - -ADDTEST(always_skip) -set_tests_properties(always_skip PROPERTIES SKIP_RETURN_CODE 77) -ADDTEST(always_fail) -set_tests_properties(always_fail PROPERTIES WILL_FAIL true) +add_subdirectory(terminal) \ No newline at end of file diff --git a/test/test_always_fail.f90 b/test/test_always_fail.f90 deleted file mode 100644 index c52b5788d..000000000 --- a/test/test_always_fail.f90 +++ /dev/null @@ -1,8 +0,0 @@ -program test_always_fail - -use stdlib_error, only: check -implicit none - -call check(.false.) - -end program diff --git a/test/test_always_skip.f90 b/test/test_always_skip.f90 deleted file mode 100644 index 2d10c3daa..000000000 --- a/test/test_always_skip.f90 +++ /dev/null @@ -1,8 +0,0 @@ -program test_always_skip - -use stdlib_error, only: check -implicit none - -call check(.false., code=77) - -end program From 85ac351bcf79ca988e03860eb2b470d86f1e3b1f Mon Sep 17 00:00:00 2001 From: Jose Alves Date: Sat, 27 Apr 2024 11:08:07 +0200 Subject: [PATCH 12/17] no longer needed files in prune list --- config/fypp_deployment.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/config/fypp_deployment.py b/config/fypp_deployment.py index 7e02742ce..f3b469039 100644 --- a/config/fypp_deployment.py +++ b/config/fypp_deployment.py @@ -82,8 +82,6 @@ def deploy_stdlib_fpm(): """ import shutil prune=( - "test_always_fail.f90", - "test_always_skip.f90", "test_hash_functions.f90", "f18estop.f90", ) From d1f7b2bbc03d6c5850738c77a7fc05245671d7c8 Mon Sep 17 00:00:00 2001 From: Jose Alves Date: Sat, 27 Apr 2024 20:50:05 +0200 Subject: [PATCH 13/17] Include README info regarding python script preprocessing --- README.md | 29 ++++++++++-- ci/.gitignore | 7 --- ci/fpm-deployment.sh | 99 --------------------------------------- ci/fpm.toml | 15 ------ config/fypp_deployment.py | 5 +- 5 files changed, 27 insertions(+), 128 deletions(-) delete mode 100644 ci/.gitignore delete mode 100644 ci/fpm-deployment.sh delete mode 100644 ci/fpm.toml diff --git a/README.md b/README.md index 6180bea0e..e0fe8d80d 100644 --- a/README.md +++ b/README.md @@ -179,19 +179,38 @@ earlier builds do not affect the new build. Fortran Package Manager (fpm) is a package manager and build system for Fortran. You can build `stdlib` using provided `fpm.toml`: +**Option 1**: From root folder + +As `fpm` does not currently support `fypp` natively, `stdlib` now proposes a python script to preprocess and build. This script enables modification of the different `fypp` macros available in `stdlib`. The preprocessed files will be dumped at `/temp/*.f90` or `*.F90`. You can use the following command line: + ```sh -git checkout stdlib-fpm +python config/fypp_deployment.py fpm build --profile release ``` -**Alternative**: as `fpm` does not currently support `fypp` natively, building `stdlib` with `fpm` can be done in two steps: a) launch the preprocessor through the `fpm-deployment.sh` script, which creates a subfolder `stdlib-fpm` and b) build the project using the processed files within the latter subfolder. This process can be done with the following commands: +or the short-cut ```sh -source ./ci/fpm-deployment.sh -cd stdlib-fpm/ -fpm build --profile release +python config/fypp_deployment.py --build 1 +``` + +To modify the `maxrank` macro for instance: +```sh +python config/fypp_deployment.py --maxrank 7 --build 1 ``` +To see all the options: +```sh +python config/fypp_deployment.py --help +``` +**Note**: If you use a compiler different than GNU compilers, the script will try to catch it from the environment variables `FPM_FC`, `FPM_CC`, `FPM_CXX`. + +**Option 2**: From the `stdlib-fpm` branch which has already been preprocessed with default macros: +```sh +git checkout stdlib-fpm +fpm build --profile release +``` +#### Runing the examples You can run the examples with `fpm` as: ```sh diff --git a/ci/.gitignore b/ci/.gitignore deleted file mode 100644 index 160063cfb..000000000 --- a/ci/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -# Files generated by tests -scratch.txt -*.bin -*log*.txt -*test*.txt -*.dat -*.stream diff --git a/ci/fpm-deployment.sh b/ci/fpm-deployment.sh deleted file mode 100644 index 608a2b9be..000000000 --- a/ci/fpm-deployment.sh +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/env bash - -set -ex - -# Target directory to deploy stdlib to -destdir="${DESTDIR:-stdlib-fpm}" - -# Get fypp preprocessor -fypp="${FYPP:-$(which fypp)}" - -# Arguments for the fypp preprocessor -maxrank=4 -fyflags="${FYFLAGS:--DMAXRANK=$maxrank}" - -# Number of parallel jobs for preprocessing -if [ $(uname) = "Darwin" ]; then - njob="$(sysctl -n hw.ncpu)" -else - njob="$(nproc)" -fi - -# Additional files to include -include=( - "ci/fpm.toml" - "ci/.gitignore" - "LICENSE" - "VERSION" -) - -# Files to remove from collection -prune=( - "$destdir/test/test_always_fail.f90" - "$destdir/test/test_always_skip.f90" - "$destdir/test/test_hash_functions.f90" - "$destdir/src/f18estop.f90" -) - -# Files that need preprocessed Fortran extension -> .F90 -preprocessed=( - "$destdir/src/stdlib_linalg_constants" - "$destdir/src/stdlib_linalg_blas" - "$destdir/src/stdlib_linalg_blas_aux" - "$destdir/src/stdlib_linalg_blas_s" - "$destdir/src/stdlib_linalg_blas_d" - "$destdir/src/stdlib_linalg_blas_q" - "$destdir/src/stdlib_linalg_blas_c" - "$destdir/src/stdlib_linalg_blas_z" - "$destdir/src/stdlib_linalg_blas_w" - "$destdir/src/stdlib_linalg_lapack" - "$destdir/src/stdlib_linalg_lapack_aux" - "$destdir/src/stdlib_linalg_lapack_s" - "$destdir/src/stdlib_linalg_lapack_d" - "$destdir/src/stdlib_linalg_lapack_q" - "$destdir/src/stdlib_linalg_lapack_c" - "$destdir/src/stdlib_linalg_lapack_z" - "$destdir/src/stdlib_linalg_lapack_w" -) - -major=$(cut -d. -f1 VERSION) -minor=$(cut -d. -f2 VERSION) -patch=$(cut -d. -f3 VERSION) -fyflags="${fyflags} -DPROJECT_VERSION_MAJOR=${major} -DPROJECT_VERSION_MINOR=${minor} -DPROJECT_VERSION_PATCH=${patch} -I include" - -mkdir -p "$destdir/src" "$destdir/test" "$destdir/example" - -# Preprocess stdlib sources -find src -maxdepth 1 -iname "*.fypp" \ - | cut -f1 -d. | xargs -P "$njob" -I{} "$fypp" "{}.fypp" "$destdir/{}.f90" $fyflags - -find test -name "test_*.fypp" -exec cp {} "$destdir/test/" \; -fyflags="${fyflags} -I src" -find $destdir/test -maxdepth 1 -iname "*.fypp" \ - | cut -f1 -d. | xargs -P "$njob" -I{} "$fypp" "{}.fypp" "{}.f90" $fyflags -find $destdir/test -name "test_*.fypp" -exec rm {} \; - -# Collect stdlib source files -find src -maxdepth 1 -iname "*.f90" -exec cp {} "$destdir/src/" \; -find test -name "test_*.f90" -exec cp {} "$destdir/test/" \; -find test -name "*.dat" -exec cp {} "$destdir/" \; -find example -name "example_*.f90" -exec cp {} "$destdir/example/" \; -find example -name "*.dat" -exec cp {} "$destdir/" \; -find example -name "*.npy" -exec cp {} "$destdir/" \; - -# Include additional files -cp "${include[@]}" "$destdir/" - -# Source file workarounds for fpm; ignore missing files -rm "${prune[@]}" - -# Capitalize .f90 -> .F90 for preprocessed files -for pp_source in "${preprocessed[@]}" -do - # workaround for case-insensitive fs - mv "$pp_source.f90" "$pp_source.rename" - mv "$pp_source.rename" "$pp_source.F90" -done - -# List stdlib-fpm package contents -ls -R "$destdir" diff --git a/ci/fpm.toml b/ci/fpm.toml deleted file mode 100644 index bf8dfc530..000000000 --- a/ci/fpm.toml +++ /dev/null @@ -1,15 +0,0 @@ -name = "stdlib" -version = "VERSION" -license = "MIT" -author = "stdlib contributors" -maintainer = "@fortran-lang/stdlib" -copyright = "2019-2021 stdlib contributors" - -[dev-dependencies] -test-drive.git = "https://github.com/fortran-lang/test-drive" -test-drive.tag = "v0.4.0" - -[preprocess] -[preprocess.cpp] -suffixes = [".F90", ".f90"] -macros = ["MAXRANK=7"] diff --git a/config/fypp_deployment.py b/config/fypp_deployment.py index f3b469039..433178a4b 100644 --- a/config/fypp_deployment.py +++ b/config/fypp_deployment.py @@ -46,7 +46,8 @@ def pre_process_fypp(args): optparser = fypp.get_option_parser() options, leftover = optparser.parse_args(args=kwd) options.includes = ['include'] - # options.line_numbering = True + if args.lnumbering: + options.line_numbering = True tool = fypp.Fypp(options) # Check destination folder for preprocessing. if not 'stdlib-fpm', it is assumed to be the root folder. @@ -139,7 +140,7 @@ def fpm_build(args,unknown): parser.add_argument("--maxrank",type=int, default=7, help="Set the maximum allowed rank for arrays") parser.add_argument("--with_qp",type=bool, default=False, help="Include WITH_QP in the command") parser.add_argument("--with_xdp",type=bool, default=False, help="Include WITH_XDP in the command") - + parser.add_argument("--lnumbering",type=bool, default=False, help="Add line numbering in preprocessed files") parser.add_argument("--deploy_stdlib_fpm",type=bool, default=False, help="create the stdlib-fpm folder") # external libraries arguments parser.add_argument("--build",type=bool, default=False, help="Build the project") From 18cdae125ccbda7f93d9b5e51cbe3baf8c75a8b7 Mon Sep 17 00:00:00 2001 From: Jose Alves Date: Sat, 27 Apr 2024 20:56:04 +0200 Subject: [PATCH 14/17] clean up deployment workflow --- .github/workflows/fpm-deployment.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/fpm-deployment.yml b/.github/workflows/fpm-deployment.yml index e2b8867cc..a0e919991 100644 --- a/.github/workflows/fpm-deployment.yml +++ b/.github/workflows/fpm-deployment.yml @@ -10,7 +10,7 @@ jobs: matrix: include: - os: ubuntu-latest - toolchain: {compiler: gcc, version: 13, flags: ['-cpp -O3']} + toolchain: {compiler: gcc, version: 13} steps: - name: Checkout code @@ -37,10 +37,9 @@ jobs: - run: | python config/fypp_deployment.py --deploy_stdlib_fpm 1 - fpm test --flag "${{ join(matrix.toolchain.flags, ' ') }}" + fpm test --profile release # Update and deploy the f90 files generated by github-ci to the `stdlib-fpm` branch. - # might no longer be needed - name: Deploy 🚀 uses: JamesIves/github-pages-deploy-action@4.1.5 if: github.event_name != 'pull_request' From 6bca02739f553af0b87bec29900870c7c9966254 Mon Sep 17 00:00:00 2001 From: jalvesz <102541118+jalvesz@users.noreply.github.com> Date: Sun, 28 Apr 2024 11:36:15 +0200 Subject: [PATCH 15/17] Update README.md Co-authored-by: Jeremie Vandenplas --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e0fe8d80d..43ad84208 100644 --- a/README.md +++ b/README.md @@ -181,7 +181,9 @@ You can build `stdlib` using provided `fpm.toml`: **Option 1**: From root folder -As `fpm` does not currently support `fypp` natively, `stdlib` now proposes a python script to preprocess and build. This script enables modification of the different `fypp` macros available in `stdlib`. The preprocessed files will be dumped at `/temp/*.f90` or `*.F90`. You can use the following command line: +As `fpm` does not currently support `fypp` natively, `stdlib` now proposes a python script to preprocess and build it. +This script enables modification of the different `fypp` macros available in `stdlib`. The preprocessed files will be dumped at `/temp/*.f90` or `*.F90`. +You can use the following command line: ```sh python config/fypp_deployment.py From 95ee064fa3d61d5b6d4107bface789af6d6ae462 Mon Sep 17 00:00:00 2001 From: Jose Alves Date: Sun, 28 Apr 2024 17:26:02 +0200 Subject: [PATCH 16/17] use action='store_true' to avoid need of int parameter --- .github/workflows/fpm-deployment.yml | 2 +- README.md | 10 ++++++++-- config/fypp_deployment.py | 10 +++++----- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/fpm-deployment.yml b/.github/workflows/fpm-deployment.yml index a0e919991..2e4a3203c 100644 --- a/.github/workflows/fpm-deployment.yml +++ b/.github/workflows/fpm-deployment.yml @@ -36,7 +36,7 @@ jobs: fpm-version: 'v0.10.0' - run: | - python config/fypp_deployment.py --deploy_stdlib_fpm 1 + python config/fypp_deployment.py --deploy_stdlib_fpm fpm test --profile release # Update and deploy the f90 files generated by github-ci to the `stdlib-fpm` branch. diff --git a/README.md b/README.md index 43ad84208..f2fb63af6 100644 --- a/README.md +++ b/README.md @@ -193,18 +193,24 @@ fpm build --profile release or the short-cut ```sh -python config/fypp_deployment.py --build 1 +python config/fypp_deployment.py --build ``` To modify the `maxrank` macro for instance: ```sh -python config/fypp_deployment.py --maxrank 7 --build 1 +python config/fypp_deployment.py --maxrank 7 --build ``` To see all the options: ```sh python config/fypp_deployment.py --help ``` + +Dependencies can be intalled from the `requirement.txt` +```sh +pip install --upgrade -r config/requirements.txt +``` + **Note**: If you use a compiler different than GNU compilers, the script will try to catch it from the environment variables `FPM_FC`, `FPM_CC`, `FPM_CXX`. **Option 2**: From the `stdlib-fpm` branch which has already been preprocessed with default macros: diff --git a/config/fypp_deployment.py b/config/fypp_deployment.py index 433178a4b..9f3549e4f 100644 --- a/config/fypp_deployment.py +++ b/config/fypp_deployment.py @@ -138,12 +138,12 @@ def fpm_build(args,unknown): parser.add_argument("--njob", type=int, default=4, help="Number of parallel jobs for preprocessing") parser.add_argument("--maxrank",type=int, default=7, help="Set the maximum allowed rank for arrays") - parser.add_argument("--with_qp",type=bool, default=False, help="Include WITH_QP in the command") - parser.add_argument("--with_xdp",type=bool, default=False, help="Include WITH_XDP in the command") - parser.add_argument("--lnumbering",type=bool, default=False, help="Add line numbering in preprocessed files") - parser.add_argument("--deploy_stdlib_fpm",type=bool, default=False, help="create the stdlib-fpm folder") + parser.add_argument("--with_qp",action='store_true', help="Include WITH_QP in the command") + parser.add_argument("--with_xdp",action='store_true', help="Include WITH_XDP in the command") + parser.add_argument("--lnumbering",action='store_true', help="Add line numbering in preprocessed files") + parser.add_argument("--deploy_stdlib_fpm",action='store_true', help="create the stdlib-fpm folder") # external libraries arguments - parser.add_argument("--build",type=bool, default=False, help="Build the project") + parser.add_argument("--build", action='store_true', help="Build the project") args, unknown = parser.parse_known_args() #========================================== From a5978340d587361e6ffded32f8f5715740fbc20b Mon Sep 17 00:00:00 2001 From: Jose Alves Date: Thu, 2 May 2024 10:34:09 +0200 Subject: [PATCH 17/17] add argparse to requirements and update README --- README.md | 13 +++++++------ config/requirements.txt | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f2fb63af6..b329d2713 100644 --- a/README.md +++ b/README.md @@ -183,7 +183,13 @@ You can build `stdlib` using provided `fpm.toml`: As `fpm` does not currently support `fypp` natively, `stdlib` now proposes a python script to preprocess and build it. This script enables modification of the different `fypp` macros available in `stdlib`. The preprocessed files will be dumped at `/temp/*.f90` or `*.F90`. -You can use the following command line: + +Make sure to install the dependencies from the `requirement.txt` +```sh +pip install --upgrade -r config/requirements.txt +``` + +To build, you can use the following command line: ```sh python config/fypp_deployment.py @@ -206,11 +212,6 @@ To see all the options: python config/fypp_deployment.py --help ``` -Dependencies can be intalled from the `requirement.txt` -```sh -pip install --upgrade -r config/requirements.txt -``` - **Note**: If you use a compiler different than GNU compilers, the script will try to catch it from the environment variables `FPM_FC`, `FPM_CC`, `FPM_CXX`. **Option 2**: From the `stdlib-fpm` branch which has already been preprocessed with default macros: diff --git a/config/requirements.txt b/config/requirements.txt index d08247534..74e6082b0 100644 --- a/config/requirements.txt +++ b/config/requirements.txt @@ -1,2 +1,3 @@ fypp +argparse joblib \ No newline at end of file