Skip to content

Commit

Permalink
Replace run_process by run_process_2 (#2524)
Browse files Browse the repository at this point in the history
* Replace `run_process` by `run_process_2`

* Do not catch `RuntimeError`

* Set Version: 1.0.640

* Set Version: 1.0.641

---------

Co-authored-by: Tamás Tóth <--show-origin>
Co-authored-by: devops <[email protected]>
  • Loading branch information
tothtamas28 and devops authored Jul 11, 2024
1 parent 4d59589 commit 492ad83
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 102 deletions.
2 changes: 1 addition & 1 deletion kevm-pyk/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "kevm-pyk"
version = "1.0.640"
version = "1.0.641"
description = ""
authors = [
"Runtime Verification, Inc. <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion kevm-pyk/src/kevm_pyk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
if TYPE_CHECKING:
from typing import Final

VERSION: Final = '1.0.640'
VERSION: Final = '1.0.641'
4 changes: 2 additions & 2 deletions kevm-pyk/src/kevm_pyk/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from pyk.kdist import kdist
from pyk.kore.parser import KoreParser
from pyk.utils import run_process
from pyk.utils import run_process_2

from .gst_to_kore import gst_to_kore

Expand All @@ -28,5 +28,5 @@ def interpret(gst_data: Any, schedule: str, mode: str, chainid: int, usegas: boo
def _interpret(gst_data: Any, schedule: str, mode: str, chainid: int, usegas: bool) -> CompletedProcess:
interpreter = kdist.get('evm-semantics.llvm') / 'interpreter'
init_kore = gst_to_kore(gst_data, schedule, mode, chainid, usegas)
proc_res = run_process([str(interpreter), '/dev/stdin', '-1', '/dev/stdout'], input=init_kore.text, check=False)
proc_res = run_process_2([str(interpreter), '/dev/stdin', '-1', '/dev/stdout'], input=init_kore.text, check=False)
return proc_res
7 changes: 2 additions & 5 deletions kevm-pyk/src/kevm_pyk/kdist/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pyk.kbuild.utils import k_version, sync_files
from pyk.kdist.api import Target
from pyk.kllvm.compiler import compile_kllvm, compile_runtime
from pyk.utils import run_process
from pyk.utils import run_process_2

from .. import config
from ..kompile import KompileTarget, kevm_kompile, lib_ccopts
Expand Down Expand Up @@ -63,10 +63,7 @@ def build(self, output_dir: Path, deps: dict[str, Any], args: dict[str, Any], ve
)

copy_tree(str(config.PLUGIN_DIR), '.')
run_process(
['make', 'libcryptopp', 'libff', 'blake2', '-j8'],
pipe_stdout=not verbose,
)
run_process_2(['make', 'libcryptopp', 'libff', 'blake2', '-j8'])

copy_tree('./build/libcryptopp', str(output_dir / 'libcryptopp'))
copy_tree('./build/libff', str(output_dir / 'libff'))
Expand Down
176 changes: 84 additions & 92 deletions kevm-pyk/src/kevm_pyk/kompile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pyk.kdist import kdist
from pyk.ktool import TypeInferenceMode
from pyk.ktool.kompile import HaskellKompile, KompileArgs, LLVMKompile, LLVMKompileType, MaudeKompile
from pyk.utils import run_process
from pyk.utils import run_process_2

from . import config

Expand Down Expand Up @@ -129,107 +129,99 @@ def run_kompile(
kernel = sys.platform
haskell_binary = kernel != 'darwin'

try:
match target:
case KompileTarget.LLVM:
kompile = LLVMKompile(
base_args=base_args,
ccopts=ccopts,
opt_level=optimization,
llvm_kompile_type=llvm_kompile_type,
enable_llvm_debug=enable_llvm_debug,
match target:
case KompileTarget.LLVM:
kompile = LLVMKompile(
base_args=base_args,
ccopts=ccopts,
opt_level=optimization,
llvm_kompile_type=llvm_kompile_type,
enable_llvm_debug=enable_llvm_debug,
)
return kompile(
output_dir=output_dir,
debug=debug,
verbose=verbose,
type_inference_mode=type_inference_mode,
ignore_warnings=ignore_warnings,
)

case KompileTarget.MAUDE:
kompile_maude = MaudeKompile(
base_args=base_args,
)
kompile_haskell = HaskellKompile(base_args=base_args)

maude_dir = output_dir / 'kompiled-maude'

def _kompile_maude() -> None:
kompile_maude(
output_dir=maude_dir, debug=debug, verbose=verbose, type_inference_mode=type_inference_mode
)
return kompile(

def _kompile_haskell() -> None:
kompile_haskell(
output_dir=output_dir,
debug=debug,
verbose=verbose,
type_inference_mode=type_inference_mode,
ignore_warnings=ignore_warnings,
)

case KompileTarget.MAUDE:
kompile_maude = MaudeKompile(
base_args=base_args,
)
kompile_haskell = HaskellKompile(base_args=base_args)

maude_dir = output_dir / 'kompiled-maude'

def _kompile_maude() -> None:
kompile_maude(
output_dir=maude_dir, debug=debug, verbose=verbose, type_inference_mode=type_inference_mode
)

def _kompile_haskell() -> None:
kompile_haskell(
output_dir=output_dir,
debug=debug,
verbose=verbose,
type_inference_mode=type_inference_mode,
ignore_warnings=ignore_warnings,
)

with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
futures = [
executor.submit(_kompile_maude),
executor.submit(_kompile_haskell),
]
[future.result() for future in futures]

return output_dir

case KompileTarget.HASKELL:
base_args_llvm = KompileArgs(
main_file=main_file,
main_module=main_module,
syntax_module=syntax_module,
include_dirs=include_dirs,
md_selector=KompileTarget.LLVM.md_selector,
hook_namespaces=HOOK_NAMESPACES,
emit_json=emit_json,
read_only=read_only,
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
futures = [
executor.submit(_kompile_maude),
executor.submit(_kompile_haskell),
]
[future.result() for future in futures]

return output_dir

case KompileTarget.HASKELL:
base_args_llvm = KompileArgs(
main_file=main_file,
main_module=main_module,
syntax_module=syntax_module,
include_dirs=include_dirs,
md_selector=KompileTarget.LLVM.md_selector,
hook_namespaces=HOOK_NAMESPACES,
emit_json=emit_json,
read_only=read_only,
)
kompile_llvm = LLVMKompile(
base_args=base_args_llvm, ccopts=ccopts, opt_level=optimization, llvm_kompile_type=LLVMKompileType.C
)
kompile_haskell = HaskellKompile(base_args=base_args, haskell_binary=haskell_binary)

def _kompile_llvm() -> None:
kompile_llvm(
output_dir=output_dir / 'llvm-library',
debug=debug,
verbose=verbose,
type_inference_mode=type_inference_mode,
ignore_warnings=ignore_warnings,
)
kompile_llvm = LLVMKompile(
base_args=base_args_llvm, ccopts=ccopts, opt_level=optimization, llvm_kompile_type=LLVMKompileType.C

def _kompile_haskell() -> None:
kompile_haskell(
output_dir=output_dir,
debug=debug,
verbose=verbose,
type_inference_mode=type_inference_mode,
ignore_warnings=ignore_warnings,
)
kompile_haskell = HaskellKompile(base_args=base_args, haskell_binary=haskell_binary)

def _kompile_llvm() -> None:
kompile_llvm(
output_dir=output_dir / 'llvm-library',
debug=debug,
verbose=verbose,
type_inference_mode=type_inference_mode,
ignore_warnings=ignore_warnings,
)

def _kompile_haskell() -> None:
kompile_haskell(
output_dir=output_dir,
debug=debug,
verbose=verbose,
type_inference_mode=type_inference_mode,
ignore_warnings=ignore_warnings,
)

with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
futures = [
executor.submit(_kompile_llvm),
executor.submit(_kompile_haskell),
]
[future.result() for future in futures]

return output_dir

case _:
raise ValueError(f'Unsupported target: {target.value}')
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
futures = [
executor.submit(_kompile_llvm),
executor.submit(_kompile_haskell),
]
[future.result() for future in futures]

return output_dir

except RuntimeError as err:
sys.stderr.write(f'\nkompile stdout:\n{err.args[1]}\n')
sys.stderr.write(f'\nkompile stderr:\n{err.args[2]}\n')
sys.stderr.write(f'\nkompile returncode:\n{err.args[3]}\n')
sys.stderr.flush()
raise
case _:
raise ValueError(f'Unsupported target: {target.value}')


def lib_ccopts(plugin_dir: Path, debug_build: bool = False) -> list[str]:
Expand Down Expand Up @@ -259,13 +251,13 @@ def lib_ccopts(plugin_dir: Path, debug_build: bool = False) -> list[str]:

if kernel == 'darwin':
if not config.NIX_LIBS:
brew_root = run_process(('brew', '--prefix'), pipe_stderr=True, logger=_LOGGER).stdout.strip()
brew_root = run_process_2(('brew', '--prefix'), logger=_LOGGER).stdout.strip()
ccopts += [
f'-I{brew_root}/include',
f'-L{brew_root}/lib',
]

openssl_root = run_process(('brew', '--prefix', 'openssl'), pipe_stderr=True, logger=_LOGGER).stdout.strip()
openssl_root = run_process_2(('brew', '--prefix', 'openssl'), logger=_LOGGER).stdout.strip()
ccopts += [
f'-I{openssl_root}/include',
f'-L{openssl_root}/lib',
Expand Down
2 changes: 1 addition & 1 deletion package/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.640
1.0.641

0 comments on commit 492ad83

Please sign in to comment.