Skip to content

Commit 5c0e000

Browse files
authored
Merge pull request #54 from nschloe/flit
flit
2 parents fc97b15 + af659d2 commit 5c0e000

File tree

6 files changed

+52
-83
lines changed

6 files changed

+52
-83
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ jobs:
2020
uses: pre-commit/[email protected]
2121

2222
build:
23-
runs-on: ${{ matrix.os }}
2423
needs: [lint]
24+
runs-on: ${{ matrix.os }}
2525
strategy:
2626
matrix:
2727
os: [ubuntu-latest]

justfile

+4-13
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
1-
version := `python3 -c "from configparser import ConfigParser; p = ConfigParser(); p.read('setup.cfg'); print(p['metadata']['version'])"`
2-
name := `python3 -c "from configparser import ConfigParser; p = ConfigParser(); p.read('setup.cfg'); print(p['metadata']['name'])"`
3-
1+
version := `python3 -c "from src.blacktex.__about__ import __version__; print(__version__)"`
42

53
default:
64
@echo "\"just publish\"?"
75

8-
tag:
9-
@if [ "$(git rev-parse --abbrev-ref HEAD)" != "main" ]; then exit 1; fi
10-
curl -H "Authorization: token `cat ~/.github-access-token`" -d '{"tag_name": "v{{version}}"}' https://api.github.com/repos/nschloe/{{name}}/releases
11-
12-
upload: clean
6+
publish:
137
@if [ "$(git rev-parse --abbrev-ref HEAD)" != "main" ]; then exit 1; fi
14-
# https://stackoverflow.com/a/58756491/353337
15-
python3 -m build --sdist --wheel .
16-
twine upload dist/*
17-
18-
publish: tag upload
8+
gh release create "v{{version}}"
9+
flit publish
1910

2011
clean:
2112
@find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf

pyproject.toml

+37-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,41 @@
11
[build-system]
2-
requires = ["setuptools>=42", "wheel"]
3-
build-backend = "setuptools.build_meta"
2+
requires = ["flit_core >=3.2,<4"]
3+
build-backend = "flit_core.buildapi"
4+
5+
[project]
6+
name = "blacktex"
7+
authors = [{name = "Nico Schlömer", email = "[email protected]"}]
8+
description = "Clean up your LaTeX files"
9+
readme = "README.md"
10+
license = {file = "LICENSE"}
11+
classifiers = [
12+
"Development Status :: 4 - Beta",
13+
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
14+
"Operating System :: OS Independent",
15+
"Programming Language :: Python",
16+
"Programming Language :: Python :: 3",
17+
"Programming Language :: Python :: 3.6",
18+
"Programming Language :: Python :: 3.7",
19+
"Programming Language :: Python :: 3.8",
20+
"Programming Language :: Python :: 3.9",
21+
"Programming Language :: Python :: 3.10",
22+
"Topic :: Text Editors :: Text Processing",
23+
"Topic :: Text Processing",
24+
"Topic :: Text Processing :: Markup",
25+
"Topic :: Text Processing :: Markup :: LaTeX",
26+
"Topic :: Utilities",
27+
]
28+
keywords = ["latex", "linting"]
29+
dynamic = ["version"]
30+
requires-python = ">=3.6"
31+
32+
[project.urls]
33+
Code = "https://github.com/nschloe/blacktex"
34+
Issues = "https://github.com/nschloe/blacktex/issues"
35+
Funding = "https://github.com/sponsors/nschloe"
36+
37+
[project.scripts]
38+
blacktex = "blacktex.cli:main"
439

540
[tool.isort]
641
profile = "black"

setup.cfg

-48
This file was deleted.

src/blacktex/__about__.py

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1 @@
1-
try:
2-
# Python 3.8
3-
from importlib import metadata
4-
except ImportError:
5-
import importlib_metadata as metadata
6-
7-
try:
8-
__version__ = metadata.version("blacktex")
9-
except Exception:
10-
__version__ = "unknown"
1+
__version__ = "0.5.3"

src/blacktex/cli.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import argparse
2-
import sys
2+
from sys import version_info as vi
33

4-
import blacktex
4+
from .__about__ import __version__
5+
from .main import clean
56

67

78
def main(argv=None):
@@ -13,7 +14,7 @@ def main(argv=None):
1314
for fl in args.infiles:
1415
with open(fl.name, encoding=args.encoding) as f:
1516
content = f.read()
16-
out = blacktex.clean(content, args.keep_comments, args.keep_dollar_math)
17+
out = clean(content, args.keep_comments, args.keep_dollar_math)
1718
if args.in_place:
1819
return_code = return_code or int(content != out)
1920
with open(fl.name, "w", encoding=args.encoding) as f:
@@ -60,12 +61,11 @@ def _get_parser():
6061
help="keep inline math with $...$",
6162
)
6263

63-
version_text = "blacktex {}, Python {}.{}.{}".format(
64-
blacktex.__version__,
65-
sys.version_info.major,
66-
sys.version_info.minor,
67-
sys.version_info.micro,
64+
parser.add_argument(
65+
"--version",
66+
"-v",
67+
action="version",
68+
version=f"blacktex {__version__}, Python {vi.major}.{vi.minor}.{vi.micro}",
6869
)
69-
parser.add_argument("--version", "-v", action="version", version=version_text)
7070

7171
return parser

0 commit comments

Comments
 (0)