From df6c461f3be4e5e4cb8481634f454177bf374a97 Mon Sep 17 00:00:00 2001 From: egeakman Date: Mon, 22 Jan 2024 16:04:13 +0100 Subject: [PATCH] Migrate to hatch --- .pre-commit-config.yaml | 2 -- bootstrapper/__init__.py | 3 +++ bootstrapper/bootstrapper.py | 13 ++++------- {bootstrapper/data => data}/.gitignore | 0 {bootstrapper/data => data}/Makefile | 0 {bootstrapper/data => data}/README.md | 0 pyproject.toml | 32 ++++++++++++++------------ 7 files changed, 24 insertions(+), 26 deletions(-) rename {bootstrapper/data => data}/.gitignore (100%) rename {bootstrapper/data => data}/Makefile (100%) rename {bootstrapper/data => data}/README.md (100%) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c662a92..e06adab 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,6 @@ repos: rev: 5.13.2 hooks: - id: isort - name: isort (python) - repo: https://github.com/psf/black-pre-commit-mirror rev: 23.12.0 @@ -24,7 +23,6 @@ repos: rev: 1.5.3 hooks: - id: pyproject-fmt - additional_dependencies: [tox] - repo: https://github.com/abravalheri/validate-pyproject rev: v0.15 diff --git a/bootstrapper/__init__.py b/bootstrapper/__init__.py index cf41824..42dc645 100644 --- a/bootstrapper/__init__.py +++ b/bootstrapper/__init__.py @@ -1 +1,4 @@ from .bootstrapper import Bootstrapper + +__all__ = ["Bootstrapper"] +__version__ = "0.1.2" diff --git a/bootstrapper/bootstrapper.py b/bootstrapper/bootstrapper.py index 8708a4e..29aee58 100644 --- a/bootstrapper/bootstrapper.py +++ b/bootstrapper/bootstrapper.py @@ -36,6 +36,7 @@ def __init__( self.readme_url = "https://raw.githubusercontent.com/egeakman/python-docs-bootstrapper/master/bootstrapper/data/README.md" self.gitignore_url = "https://raw.githubusercontent.com/egeakman/python-docs-bootstrapper/master/bootstrapper/data/.gitignore" self.makefile_url = "https://raw.githubusercontent.com/egeakman/python-docs-bootstrapper/master/bootstrapper/data/Makefile" + self.data_dir = f"{os.path.dirname(__file__)}/../python-docs-bootstrapper-data" def _request(self, url: str) -> str: with urllib.request.urlopen(url) as response: @@ -126,9 +127,7 @@ def create_readme(self) -> None: self.logger.warning( "\n ⚠️ Failed to fetch README.md from GitHub, using local copy..." ) - readme = Path(f"{os.path.dirname(__file__)}/data/README.md").read_text( - encoding="utf-8" - ) + readme = Path(f"{self.data_dir}/README.md").read_text(encoding="utf-8") readme = readme.replace("{{translation.language}}", self.language) with open(f"{self.translation_repo}/README.md", "w", encoding="utf-8") as f: f.write(readme) @@ -142,9 +141,7 @@ def create_gitignore(self) -> None: self.logger.warning( "\n ⚠️ Failed to fetch .gitignore from GitHub, using local copy..." ) - gitignore = Path(f"{os.path.dirname(__file__)}/data/.gitignore").read_text( - encoding="utf-8" - ) + gitignore = Path(f"{self.data_dir}/.gitignore").read_text(encoding="utf-8") with open(f"{self.translation_repo}/.gitignore", "w", encoding="utf-8") as f: f.write(gitignore) self.logger.info("✅\n") @@ -157,9 +154,7 @@ def create_makefile(self) -> None: self.logger.warning( "\n ⚠️ Failed to fetch Makefile from GitHub, using local copy..." ) - makefile = Path(f"{os.path.dirname(__file__)}/data/Makefile").read_text( - encoding="utf-8" - ) + makefile = Path(f"{self.data_dir}/Makefile").read_text(encoding="utf-8") head = ( subprocess.run( ["git", "-C", self.cpython_repo, "rev-parse", "HEAD"], diff --git a/bootstrapper/data/.gitignore b/data/.gitignore similarity index 100% rename from bootstrapper/data/.gitignore rename to data/.gitignore diff --git a/bootstrapper/data/Makefile b/data/Makefile similarity index 100% rename from bootstrapper/data/Makefile rename to data/Makefile diff --git a/bootstrapper/data/README.md b/data/README.md similarity index 100% rename from bootstrapper/data/README.md rename to data/README.md diff --git a/pyproject.toml b/pyproject.toml index 0cd5b43..da0d123 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,11 @@ [build-system] -build-backend = "setuptools.build_meta" +build-backend = "hatchling.build" requires = [ - "setuptools>=61.2", + "hatchling", ] [project] name = "python-docs-bootstrapper" -version = "0.1.2" description = "Bootstrapper for Python documentation translations" readme = "README.md" keywords = [ @@ -35,8 +34,11 @@ classifiers = [ "Programming Language :: Python :: 3.12", "Topic :: Utilities", ] +dynamic = [ + "version", +] dependencies = [ - "sphinx==4.5", + "sphinx", ] [project.urls] Homepage = "https://github.com/egeakman/python-docs-bootstrapper" @@ -45,16 +47,16 @@ Releases = "https://github.com/egeakman/python-docs-bootstrapper/releases" [project.scripts] bootstrapper = "bootstrapper.bootstrapper:main" -[tool.setuptools] -include-package-data = true +[tool.hatch.build] +packages = ["bootstrapper"] +isolated = true -[tool.setuptools.packages.find] -where = ["."] -namespaces = false +[tool.hatch.build.force-include] +"data" = "python-docs-bootstrapper-data" -[tool.setuptools.package-data] -bootstrapper = [ - "data/.gitignore", - "data/Makefile", - "data/README.md", -] +[tool.hatch.version] +path = "bootstrapper/__init__.py" + +[tool.isort] +profile = "black" +known_first_party = "bootstrapper"