Commit bbd9f978 authored by Xavier Thompson's avatar Xavier Thompson

Add pyproject.toml and reorganise repository

parent d859887b
[submodule "runtime"] [submodule "runtime"]
path = runtime path = typon/runtime
url = https://lab.nexedi.com/typon/typon-concurrency.git url = https://lab.nexedi.com/typon/typon-concurrency.git
recursive-include typon/runtime/ *
recursive-include typon/include/ *
[build-system]
requires = ["setuptools"]
[project]
name = "typon"
version = "0.0.1"
dependencies = [
"clang-format == 15.0.7",
"dataclasses ~= 0.6",
"nanobind ~= 1.4.0",
"colorama ~= 0.4.6",
"pygments ~= 2.15.1",
"colorful ~= 0.5.5",
"pybind11 ~= 2.11.1",
]
[project.optional-dependencies]
test = [
"numpy ~= 1.25.1",
]
[project.scripts]
typon = "typon.trans.main:main"
[tool.setuptools]
include-package-data = true
"""
usage:
typon --cpp-flags
or
typon in.py [-o out.py] [-v]
"""
import argparse
import logging
from pathlib import Path
import sys
compiler_path = Path(__file__).parent
stdlib_path = compiler_path.parent / "include"
runtime_path = compiler_path.parent / "runtime" / "rt" / "include"
sys.path.insert(0, str(compiler_path))
parser = argparse.ArgumentParser()
parser.add_argument("input", help="input file", nargs="?" if "--cpp-flags" in sys.argv else 1)
parser.add_argument("-o", "--output", help="output file")
parser.add_argument("--cpp-flags", help="print cpp flags", action="store_true")
parser.add_argument(
'-d', '--debug',
help="Print lots of debugging statements",
action="store_const", dest="loglevel", const=logging.DEBUG,
default=logging.WARNING,
)
parser.add_argument(
'-v', '--verbose',
help="Be verbose",
action="store_const", dest="loglevel", const=logging.INFO,
)
args = parser.parse_args()
logging.basicConfig(level=args.loglevel)
if args.cpp_flags:
import pybind11.commands
import sysconfig
include_dirs = [
str(stdlib_path),
str(runtime_path),
sysconfig.get_path("include"),
sysconfig.get_path("platinclude"),
pybind11.commands.get_include()
]
include_dirs = list(dict.fromkeys(include_dirs))
cpp_flags = [
*["-I" + d for d in include_dirs],
"-pthread", "-luring", "-lfmt", "-lssl", "-lcrypto", "-lpython3.10"
]
print(" ".join(cpp_flags))
exit(0)
path = Path(args.input[0])
with open(path, "r", encoding="utf-8") as f:
code = f.read()
from transpiler import transpile
from transpiler.format import format_code
raw_cpp = transpile(code, path.name, path)
formatted = format_code(raw_cpp)
output_name = args.output or path.with_suffix('.cpp')
with open(output_name, "w", encoding="utf-8") as f:
f.write(formatted)
# TODO
"""
webserver => investiguer
scanfs => fork
promesse => faire
self/this => bind/dot
stocker smart ptr dans closures
"""
File moved
from main import main
main()
"""
usage:
typon --cpp-flags
or
typon in.py [-o out.py] [-v]
"""
import argparse
import logging
from pathlib import Path
import sys
def main():
compiler_path = Path(__file__).parent
stdlib_path = compiler_path.parent / "include"
runtime_path = compiler_path.parent / "runtime" / "rt" / "include"
sys.path.insert(0, str(compiler_path))
parser = argparse.ArgumentParser()
parser.add_argument("input", help="input file", nargs="?" if "--cpp-flags" in sys.argv else 1)
parser.add_argument("-o", "--output", help="output file")
parser.add_argument("--cpp-flags", help="print cpp flags", action="store_true")
parser.add_argument(
'-d', '--debug',
help="Print lots of debugging statements",
action="store_const", dest="loglevel", const=logging.DEBUG,
default=logging.WARNING,
)
parser.add_argument(
'-v', '--verbose',
help="Be verbose",
action="store_const", dest="loglevel", const=logging.INFO,
)
args = parser.parse_args()
logging.basicConfig(level=args.loglevel)
if args.cpp_flags:
import pybind11.commands
import sysconfig
include_dirs = [
str(stdlib_path),
str(runtime_path),
sysconfig.get_path("include"),
sysconfig.get_path("platinclude"),
pybind11.commands.get_include()
]
include_dirs = list(dict.fromkeys(include_dirs))
cpp_flags = [
*["-I" + d for d in include_dirs],
"-pthread", "-luring", "-lfmt", "-lssl", "-lcrypto", "-lpython3.10"
]
print(" ".join(cpp_flags))
exit(0)
path = Path(args.input[0])
with open(path, "r", encoding="utf-8") as f:
code = f.read()
from transpiler import transpile
from transpiler.format import format_code
raw_cpp = transpile(code, path.name, path)
formatted = format_code(raw_cpp)
output_name = args.output or path.with_suffix('.cpp')
with open(output_name, "w", encoding="utf-8") as f:
f.write(formatted)
# TODO
"""
webserver => investiguer
scanfs => fork
promesse => faire
self/this => bind/dot
stocker smart ptr dans closures
"""
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment