Skip to content

Commit 4e00430

Browse files
authored
store project metadata in pyproject.toml (#45)
1 parent ee54c6a commit 4e00430

File tree

4 files changed

+60
-65
lines changed

4 files changed

+60
-65
lines changed

.github/workflows/release.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,24 @@ jobs:
3131

3232
- name: Set version
3333
# A specific version was set in the action trigger.
34-
# Change the version in setup.cfg to that version
34+
# Change the version in pyproject.toml to that version
3535
if: ${{ github.event.inputs.version != '~~version~~' }}
3636
run: |
3737
python .github/workflows/scripts/update_version.py --set-version ${{ github.event.inputs.version }}
3838
3939
- name: Commit version change
40-
# If the setup.cfg version was changed commit it.
40+
# If the pyproject.toml version was changed, commit it.
4141
if: ${{ github.event.inputs.version != '~~version~~' }}
4242
uses: sqlalchemyorg/git-auto-commit-action@sa
4343
with:
4444
commit_message: Version ${{ github.event.inputs.version }}
45-
file_pattern: setup.cfg
45+
file_pattern: pyproject.toml
4646

4747
- name: Get version
4848
# Get current version
4949
id: get-version
5050
run: |
51-
version=`grep 'version =' setup.cfg | awk '{print $NF}'`
51+
version=`grep 'version =' pyproject.toml | awk '{print $NF}'`
5252
echo $version
5353
echo "::set-output name=version::$version"
5454
@@ -81,7 +81,7 @@ jobs:
8181
# Get new current version
8282
id: get-new-version
8383
run: |
84-
version=`grep 'version =' setup.cfg | awk '{print $NF}'`
84+
version=`grep 'version =' pyproject.toml | awk '{print $NF}'`
8585
echo $version
8686
echo "::set-output name=version::$version"
8787
@@ -90,7 +90,7 @@ jobs:
9090
uses: sqlalchemyorg/git-auto-commit-action@sa
9191
with:
9292
commit_message: Start work on ${{ steps.get-new-version.outputs.version }}
93-
file_pattern: setup.cfg
93+
file_pattern: pyproject.toml
9494

9595
- name: Publish distribution
9696
# Publish to pypi

.github/workflows/scripts/update_version.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,30 @@ def go(args):
4242
if args.set_version and not is_canonical(args.set_version):
4343
raise RuntimeError(f"Cannot use {args.set_version!r} as version")
4444

45-
setup = pathlib.Path("setup.cfg")
46-
setup_text = setup.read_text()
47-
new_setup_text = []
45+
pyproject = pathlib.Path("pyproject.toml")
46+
pyproject_text = pyproject.read_text()
47+
new_pyproject_text = []
4848
found = False
49-
for line in setup_text.split("\n"):
49+
for line in pyproject_text.split("\n"):
5050
if not line.startswith("version = "):
51-
new_setup_text.append(line)
51+
new_pyproject_text.append(line)
5252
continue
5353
if found:
5454
raise RuntimeError(
5555
"Multiple lines starting with 'version =' found"
5656
)
5757
if args.set_version:
58-
new_setup_text.append(f"version = {args.set_version}")
58+
new_pyproject_text.append(f'version = "{args.set_version}"')
5959
version = args.set_version
6060
else:
61-
current_version = line.split(" ")[-1]
61+
current_version = line.split(" ")[-1].strip('"')
6262
version = next_version(current_version)
63-
new_setup_text.append(f"version = {version}")
63+
new_pyproject_text.append(f'version = "{version}"')
6464
found = True
6565
if not found:
6666
raise RuntimeError("No line found starting with 'version ='")
6767

68-
setup.write_text("\n".join(new_setup_text))
68+
pyproject.write_text("\n".join(new_pyproject_text))
6969
print("Updated version to", version)
7070

7171

pyproject.toml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,56 @@
22
build-backend = 'setuptools.build_meta'
33
requires = ['setuptools >= 44', 'wheel']
44

5+
[project]
6+
name = "zimports"
7+
version = "0.6.2"
8+
dependencies = [
9+
"pyflakes",
10+
"flake8-import-order",
11+
"tomli",
12+
"importlib-metadata;python_version<'3.10'",
13+
]
14+
requires-python = ">= 3.9"
15+
authors = [
16+
{name = "Mike Bayer", email = "mike_mp@zzzcomputing.com"}
17+
]
18+
description = "Yet another import fixing tool"
19+
readme = "README.rst"
20+
license = "MIT"
21+
license-files = ["LICENSE"]
22+
classifiers = [
23+
"Development Status :: 4 - Beta",
24+
"Intended Audience :: Developers",
25+
"Operating System :: OS Independent",
26+
"Programming Language :: Python :: 3",
27+
"Programming Language :: Python :: 3.9",
28+
"Programming Language :: Python :: 3.10",
29+
"Programming Language :: Python :: 3.11",
30+
"Programming Language :: Python :: 3.12",
31+
"Programming Language :: Python :: 3.13",
32+
"Programming Language :: Python :: Implementation :: CPython",
33+
"Programming Language :: Python :: Implementation :: PyPy",
34+
]
35+
36+
[project.urls]
37+
Homepage = "https://github.com/sqlalchemyorg/zimports"
38+
Issues = "https://github.com/sqlalchemyorg/zimports/issues"
39+
40+
[project.scripts]
41+
zimports = "zimports:main"
42+
543
[tool.black]
644
line-length = 79
745
target-version = ['py39']
846
exclude = './test_files'
947

48+
[tool.pytest.ini_options]
49+
addopts = "--tb native -v -r sfxX --maxfail=25 -p no:warnings -p no:logging"
50+
python_files = ["tests.py"]
51+
52+
[tool.setuptools.packages.find]
53+
include = ["zimports*"]
54+
1055
[tool.zimports]
1156
black-line-length = 79
1257
keep-unused-type-checking = true

setup.cfg

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,3 @@
1-
[metadata]
2-
name = zimports
3-
version = 0.6.2
4-
description = Yet another import fixing tool
5-
long_description = file: README.rst
6-
long_description_content_type = text/x-rst
7-
url = https://github.com/sqlalchemyorg/zimports
8-
author = Mike Bayer
9-
author_email = mike_mp@zzzcomputing.com
10-
license = MIT
11-
license_files = LICENSE
12-
classifiers =
13-
Development Status :: 4 - Beta
14-
Intended Audience :: Developers
15-
License :: OSI Approved :: MIT License
16-
Operating System :: OS Independent
17-
Programming Language :: Python :: 3
18-
Programming Language : Python :: 3.9
19-
Programming Language :: Python :: 3.10
20-
Programming Language :: Python :: 3.11
21-
Programming Language :: Python :: 3.12
22-
Programming Language :: Python :: 3.13
23-
Programming Language :: Python :: Implementation :: CPython
24-
Programming Language :: Python :: Implementation :: PyPy
25-
project_urls =
26-
Issue Tracker=https://github.com/sqlalchemyorg/zimports/issues
27-
28-
[options]
29-
zip_safe = False
30-
python_requires = >= 3.7
31-
packages = find:
32-
install_requires =
33-
pyflakes
34-
flake8-import-order
35-
tomli
36-
importlib-metadata;python_version<"3.10"
37-
38-
[options.entry_points]
39-
console_scripts =
40-
zimports = zimports:main
41-
42-
[options.packages.find]
43-
include=
44-
zimports*
45-
46-
[tool:pytest]
47-
addopts= --tb native -v -r sfxX --maxfail=25 -p no:warnings -p no:logging
48-
python_files=tests.py
49-
50-
511
[flake8]
522
enable-extensions = G
533
# E203 is due to https://github.com/PyCQA/pycodestyle/issues/373

0 commit comments

Comments
 (0)