Skip to content

Commit

Permalink
chore: update workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovizro committed Sep 4, 2022
1 parent c40c371 commit c8c8150
Show file tree
Hide file tree
Showing 10 changed files with 291 additions and 185 deletions.
123 changes: 102 additions & 21 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,114 @@ name: Upload Python Package

on:
release:
types: [published]
types: [created]
workflow_dispatch:

permissions:
contents: read

jobs:
deploy:
deploy-wheels:
name: Deploy wheels on ${{ matrix.os }} for ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [36, 37, 38, 39, 310]
manylinux-image: [manylinux2010, manylinux2014, manylinux_2_24]
arch: [auto]
include:
- os: ubuntu-latest
manylinux-image: manylinux2014
arch: aarch64
python-version: 36
- os: ubuntu-latest
manylinux-image: manylinux2014
arch: aarch64
python-version: 37
- os: ubuntu-latest
manylinux-image: manylinux2014
arch: aarch64
python-version: 38
- os: ubuntu-latest
manylinux-image: manylinux2014
arch: aarch64
python-version: 39
- os: ubuntu-latest
manylinux-image: manylinux2014
arch: aarch64
python-version: 310
exclude:
# manyliunx image is not a valid variation on MacOS and Windows
- os: macos-latest
manylinux-image: manylinux2010
- os: windows-latest
manylinux-image: manylinux2010
- os: macos-latest
manylinux-image: manylinux2014
- os: windows-latest
manylinux-image: manylinux2014

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up QEMU
if: ${{ matrix.arch == 'aarch64' }}
uses: docker/setup-qemu-action@v1
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install twine flake8 setuptools wheel
- name: Install cibuildwheel
run: python -m pip install cibuildwheel -U

- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: 'cp${{ matrix.python-version }}-*'
CIBW_SKIP: '*musllinux*'
CIBW_ARCHS: ${{matrix.arch}}
CIBW_MANYLINUX_*_IMAGE: ${{ matrix.manylinux-image }}
CIBW_MANYLINUX_I686_IMAGE: ${{ matrix.manylinux-image }}

- name: Publish wheels to PyPI Unix
if: matrix.os != 'windows-latest'
continue-on-error: true
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
twine upload wheelhouse/*.whl
- name: Publish wheels to PyPI Windows
if: matrix.os == 'windows-latest'
continue-on-error: true
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
twine upload (Get-ChildItem wheelhouse/*.whl)
deploy-tar:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.6'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools --upgrade
pip install wheel
- name: Build package
run: |
python setup.py sdist
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install twine flake8 setuptools wheel
- name: Build source tar
run: |
python setup.py sdist
- name: Publish wheels to PyPI
continue-on-error: true
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
twine upload dist/*tar*
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Simple python module for KoiLang parsing.

[![License](https://img.shields.io/github/license/Ovizro/Kola.svg)](LICENSE)
[![PyPI](https://img.shields.io/pypi/v/KoiLang.svg)](https://pypi.python.org/pypi/KoiLang)
![Python Version](https://img.shields.io/badge/python-3.6|3.7|3.8|3.9|3.10-blue.svg)
![Python Version](https://img.shields.io/badge/python-3.6%20|%203.7%20|%203.8%20|%203.9%20|%203.10-blue.svg)

## Installation
From pip:
Expand Down Expand Up @@ -86,7 +86,7 @@ And there are all my friends.
#space hello
#file "bob.txt"
#file "Bob.txt"
Hello Bob.
#file "Alice.txt"
Expand Down Expand Up @@ -157,4 +157,22 @@ if __name__ = "__main__":
FMultiFileManager().parse_file("kolafile.kola")
```

You will see new files in your work dir.
You will see new files in your work dir.

workdir
│ hello.txt
└─hello
Alice.txt
Bob.txt

## What is more

The most difference between KoiLang and other markup language like YAML which is data-centric is that KoiLang more pay attention to the command. Yeah, text in Kola file is a special command named `@text` too. In fact, the core idea of Kola is to separate data and instructions. The kola file is the data to execute commands, and the python script is the instructions. Then Kola module just mix they together. It can be considered as a simple virtual machine engine. if you want, you can even build a Python virtual machine (of course, I guess no one like to do that).

On the other hand, text is also an important feature of Kola, which is a separate part, independent of context during parsing. The text is the soul of a Kola file. Any commands just are used to tell the computer what to do with the text. Though you can make a Kola file with only commands, it is not recommended. Instead, you ought to consider switching to another language.

## Bugs/Requests

Please send bug reports and feature requests through [github issue tracker](https://github.com/Ovizro/Kola/issues). Kola is open to any constructive suggestions.
2 changes: 1 addition & 1 deletion examples/example1.kola
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ And there are all my friends.

#space hello

#file "bob.txt"
#file "Bob.txt"
Hello Bob.

#file "Alice.txt"
Expand Down
16 changes: 10 additions & 6 deletions kola/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def mkdir(self, dir: str, mode: int = 777) -> None:
os.mkdir(dir, mode)

@kola_command
def open(self, path: str, mode: str = "r", *, encoding: str = "utf-8") -> None:
def open(self, path: str, mode: str = "w", *, encoding: str = "utf-8") -> None:
if hasattr(self, "file"):
self.file.close()
self.file = open(path, mode, encoding=encoding)
Expand All @@ -92,6 +92,10 @@ def close(self) -> None:
self.file.close()
del self.file

@kola_command
def remove(self, path: str) -> None:
os.remove(path)

@kola_command
def load(self, path: str, type: str = "kola", *, encoding: str = "utf-8") -> None:
if type == "kola":
Expand Down Expand Up @@ -155,11 +159,11 @@ def exit(self, code: int = 0) -> None:
print(f"KoiLang Command Debugger {__version__} on {sys.platform}")
while True:
try:
sys.stdout.write("$kola : ")
sys.stdout.write("$kola: ")
sys.stdout.flush()
i = sys.stdin.readline()
while i.endswith("\\\n"):
sys.stdout.write("$kola . ")
sys.stdout.write("$...: ")
sys.stdout.flush()
i += sys.stdin.readline()
Parser(StringLexer(i), CommandDebugger).exec_once()
Expand All @@ -181,14 +185,14 @@ def exit(self, code: int = 0) -> None:
print(f"KoiLang Runner {__version__} on {sys.platform}")
while True:
try:
sys.stdout.write("$kola #: ")
sys.stdout.write("$kola: ")
sys.stdout.flush()
i = sys.stdin.readline()
while i.endswith("\\\n"):
sys.stdout.write("$kola .: ")
sys.stdout.write("$... : ")
sys.stdout.flush()
i += sys.stdin.readline()
command_set.parse_command(i)
command_set.parse(i)
except KeyboardInterrupt:
break
except KoiLangError:
Expand Down
17 changes: 9 additions & 8 deletions kola/_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ enum TokenSyn {
} TokenSyn;

static const uint8_t yy_goto[7][8] = {
15, 63, 0, 0, 0, 0, 0, 0, // CMD | CMD_N | TEXT
34, 162, 35, 117, 0, 151, 0, 40, // LITERAL
17, 49, 35, 117, 0, 151, 0, 40, // NUM | STRING
0, 0, 134, 0, 0, 0, 0, 6, // CLN
0, 0, 100, 0, 4, 0, 8, 0, // CMA
0, 3, 0, 0, 0, 0, 0, 0, // SLP
0, 0, 65, 0, 81, 0, 81, 0 // SRP
{15, 63, 0, 0, 0, 0, 0, 0}, // CMD | CMD_N | TEXT
{34, 162, 35, 117, 0, 151, 0, 40}, // LITERAL
{17, 49, 35, 117, 0, 151, 0, 40}, // NUM | STRING
{0, 0, 134, 0, 0, 0, 0, 6}, // CLN
{0, 0, 100, 0, 4, 0, 8, 0}, // CMA
{0, 3, 0, 0, 0, 0, 0, 0}, // SLP
{0, 0, 65, 0, 81, 0, 81, 0} // SRP
};

#ifndef FLEX_SCANNER
Expand Down Expand Up @@ -59,9 +59,10 @@ static const char* get_format(int code) {
ERR_MSG(unknown symbol '%s');
case 10:
ERR_MSG(end of line in incurrect place);
case 28:
ERR_MSG(keyword must be a literal);
case 201:
case 202:
ERR_MSG(keyword must be a literal);
case 210:
ERR_MSG(bad argument count);
}
Expand Down
Loading

0 comments on commit c8c8150

Please sign in to comment.