Skip to content

Commit

Permalink
chore: update build tool
Browse files Browse the repository at this point in the history
  • Loading branch information
cupen committed Mar 27, 2024
1 parent 039da13 commit f2edfa7
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ jobs:
permissions:
id-token: write
steps:
- name: Build package
run: pipx run build --sdist --wheel

- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ reinit:


build: clean
python setup.py sdist bdist_wheel
# python setup.py sdist bdist_wheel
$(python) -m build --sdist --wheel


clean:
Expand Down
9 changes: 6 additions & 3 deletions excel2xx/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ def toJson(excel, output, encoding="utf-8"):
def toMako(excel, output, template, encoding="utf-8"):
data = auto.export(excel)
with open(output, "w", encoding=encoding) as fp:
text = ""
with open(template, "r", encoding=encoding) as f:
text = Template(f.read()).render(excel=data, format=pformat)
context = {
"excel": data,
"format": pformat,
}
with open(template, "r", encoding=encoding) as fpTmpl:
text = Template(fpTmpl.read()).render(**context)
fp.write(text)
pass

Expand Down
10 changes: 8 additions & 2 deletions excel2xx/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
excel2xx.py json <excel> [options]
excel2xx.py msgpack <excel> [options]
excel2xx.py mako <excel> --template=FILE [options]
excel2xx.py build --from=DIR --to=DIR [options]
excel2xx.py codegen --from=DIR --to=GLOB [options]
excel2xx.py --version
Arguments:
<excel> Excel file path.
Options:
-h --help show this help message and exit.
-h --help show this help infomation and exit.
--version show version and exit.
-o --output=FILE output to file.
--name-row=NAME_ROW name row number. [default: 1]
Expand Down Expand Up @@ -61,9 +63,13 @@ def main(args):
elif args["mako"]:
template = args["--template"]
if not dest:
print("missing '--template', which is mako template file.")
print("Missing '--template', which is mako template file.")
return 1
export.toMako(excel, dest, template)
elif args["build"]:
raise NotImplementedError("build is developing.")
elif args["codegen"]:
raise NotImplementedError("codegen is developing.")
else:
print("Invalid subcmd.")
return 2
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-r requirements.txt
wheel
build
mypy
pytest
pytest-sugar
2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ def _open(fname):
deps = list(deps)
pass

print(deps)

print(f"requirements={deps}")

setup(
name="excel2xx",
version="0.11.6",
packages=find_packages(),
url="https://github.com/cupen/excel2xx",
license="WTFPL",
author="cupen",
Expand Down Expand Up @@ -55,4 +53,5 @@ def _open(fname):
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Software Development :: Libraries :: Python Modules",
],
packages=find_packages(),
)

0 comments on commit f2edfa7

Please sign in to comment.