Update formatting

This commit is contained in:
IamTheFij 2022-01-06 13:49:07 -08:00
parent cdf473d5e3
commit a9d7cce8ca
3 changed files with 35 additions and 23 deletions

View File

@ -23,4 +23,6 @@ repos:
hooks: hooks:
- id: mypy - id: mypy
exclude: docs/ exclude: docs/
additional_dependencies: [ "types-requests" ] additional_dependencies:
- "types-requests"
- "types-toml"

View File

@ -5,8 +5,8 @@ release-gitter based on a pyproject.toml file
from pathlib import Path from pathlib import Path
from shutil import copytree from shutil import copytree
from wheel.wheelfile import WheelFile
import toml import toml
from wheel.wheelfile import WheelFile
import release_gitter as rg import release_gitter as rg
@ -61,12 +61,14 @@ class _PseudoBuildBackend:
# Should allow passing args as `--build-option` # Should allow passing args as `--build-option`
_gitter_args = None _gitter_args = None
def prepare_metadata_for_build_wheel(self, metadata_directory, config_settings=None): def prepare_metadata_for_build_wheel(
self, metadata_directory, config_settings=None
):
# Createa .dist-info directory containing wheel metadata inside metadata_directory. Eg {metadata_directory}/{package}-{version}.dist-info/ # Createa .dist-info directory containing wheel metadata inside metadata_directory. Eg {metadata_directory}/{package}-{version}.dist-info/
print("Prepare meta", metadata_directory, config_settings) print("Prepare meta", metadata_directory, config_settings)
metadata = read_metadata() metadata = read_metadata()
version = metadata.version.removeprefix('v') version = metadata.version.removeprefix("v")
# Returns distinfo dir? # Returns distinfo dir?
dist_info = Path(metadata_directory) / f"{PACKAGE_NAME}-{version}.dist-info" dist_info = Path(metadata_directory) / f"{PACKAGE_NAME}-{version}.dist-info"
@ -74,20 +76,28 @@ class _PseudoBuildBackend:
# Write metadata # Write metadata
pkg_info = dist_info / "METADATA" pkg_info = dist_info / "METADATA"
pkg_info.write_text("\n".join([ pkg_info.write_text(
"Metadata-Version: 2.1", "\n".join(
f"Name: {PACKAGE_NAME}", [
f"Version: {version}", "Metadata-Version: 2.1",
])) f"Name: {PACKAGE_NAME}",
f"Version: {version}",
]
)
)
# Write wheel info # Write wheel info
wheel_info = dist_info / "WHEEL" wheel_info = dist_info / "WHEEL"
wheel_info.write_text("\n".join([ wheel_info.write_text(
"Wheel-Version: 1.0", "\n".join(
"Root-Is-Purelib: true", [
"Tag: py2-none-any", "Wheel-Version: 1.0",
"Tag: py3-none-any", "Root-Is-Purelib: true",
])) "Tag: py2-none-any",
"Tag: py3-none-any",
]
)
)
return str(dist_info) return str(dist_info)
@ -96,14 +106,16 @@ class _PseudoBuildBackend:
# That should contain a toplevel drectory of `name-version` containing source files and the pyproject.toml # That should contain a toplevel drectory of `name-version` containing source files and the pyproject.toml
# HACK: This isn't needed or used # HACK: This isn't needed or used
p = Path(sdist_directory+".dist-info") p = Path(sdist_directory + ".dist-info")
return p return p
def build_wheel(self, wheel_directory, config_settings=None, metadata_directory=None): def build_wheel(
self, wheel_directory, config_settings=None, metadata_directory=None
):
metadata_directory = Path(metadata_directory) metadata_directory = Path(metadata_directory)
metadata = read_metadata() metadata = read_metadata()
version = metadata.version.removeprefix('v') version = metadata.version.removeprefix("v")
wheel_directory = Path(wheel_directory) wheel_directory = Path(wheel_directory)
wheel_directory.mkdir(exist_ok=True) wheel_directory.mkdir(exist_ok=True)
@ -122,8 +134,8 @@ class _PseudoBuildBackend:
print(f"ls {wheel_directory}: {list(wheel_directory.glob('*'))}") print(f"ls {wheel_directory}: {list(wheel_directory.glob('*'))}")
wheel_filename = f"{PACKAGE_NAME}-{version}-py2.py3-none-any.whl" wheel_filename = f"{PACKAGE_NAME}-{version}-py2.py3-none-any.whl"
with WheelFile(wheel_directory / wheel_filename, 'w') as wf: with WheelFile(wheel_directory / wheel_filename, "w") as wf:
print("Repacking wheel as {}...".format(wheel_filename), end='') print("Repacking wheel as {}...".format(wheel_filename), end="")
# sys.stdout.flush() # sys.stdout.flush()
wf.write_files(wheel_directory) wf.write_files(wheel_directory)

View File

@ -39,9 +39,7 @@ setup(
] ]
), ),
install_requires=["requests"], install_requires=["requests"],
extras_require={ extras_require={"builder": ["toml", "wheel"]},
"builder": ["toml", "wheel"]
},
entry_points={ entry_points={
"console_scripts": [ "console_scripts": [
"release-gitter=release_gitter:main", "release-gitter=release_gitter:main",