-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automate build date generation with hatch
- Loading branch information
1 parent
bf7c1a7
commit 24928ab
Showing
4 changed files
with
45 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,14 +3,12 @@ | |
# SPDX-FileCopyrightText: 2021-2022 Raphaël Doursenaud <[email protected]> | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
import os | ||
from datetime import datetime | ||
|
||
from PyInstaller.building.api import PYZ, EXE | ||
from PyInstaller.building.api import EXE, PYZ | ||
from PyInstaller.building.build_main import Analysis | ||
from PyInstaller.building.datastruct import Tree | ||
from kivy.tools.packaging.pyinstaller_hooks import get_deps_minimal, hookspath, runtime_hooks | ||
from kivy_deps import sdl2, glew | ||
from kivy_deps import glew, sdl2 | ||
|
||
from denonremote.__about__ import __version__ | ||
|
||
|
@@ -29,12 +27,6 @@ dependencies = get_deps_minimal(exclude_ignored=False, window=True, text=True, i | |
dependencies['hiddenimports'].append('twisted.internet._threadedselect') | ||
dependencies['excludes'].remove('twisted') | ||
|
||
# Set build date | ||
BUILD_FILE = 'src/denonremote/__build__.py' | ||
__build_date__ = datetime.now().isoformat() | ||
with open(BUILD_FILE, 'w') as f: | ||
f.write(f'__build_date__ = "{__build_date__}"\r') | ||
|
||
a = Analysis( | ||
cipher=block_cipher, | ||
datas=added_files, | ||
|
@@ -71,9 +63,3 @@ exe = EXE( | |
upx_exclude=[], | ||
*[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)], | ||
) | ||
|
||
# Cleanup the build date file | ||
try: | ||
os.remove(BUILD_FILE) | ||
except FileNotFoundError: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# This Python file uses the following encoding: utf-8 | ||
# | ||
# SPDX-FileCopyrightText: 2023 Raphaël Doursenaud <[email protected]> | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
import os | ||
from datetime import datetime | ||
from typing import Any | ||
|
||
from hatchling.builders.hooks.plugin.interface import BuildHookInterface | ||
|
||
BUILD_FILE = 'src/denonremote/__build__.py' | ||
|
||
|
||
class CustomBuildHook(BuildHookInterface): | ||
|
||
def _get_build_file(self): | ||
return os.path.join(self.root, BUILD_FILE) | ||
|
||
def clean(self, versions: list[str]) -> None: | ||
# Cleanup the build file | ||
try: | ||
os.remove(self._get_build_file()) | ||
except FileNotFoundError: | ||
pass | ||
|
||
def initialize(self, version: str, build_data: dict[str, Any]) -> None: | ||
print(version) | ||
# Create the build | ||
__build_date__ = datetime.now().isoformat() | ||
build_file = self._get_build_file() | ||
with open(build_file, 'w') as f: | ||
f.write(f'__build_date__ = "{__build_date__}"\r') | ||
# __build__.py is in .gitignore. We must force its inclusion | ||
self.build_config.force_include[build_file] = BUILD_FILE | ||
print(self.build_config.force_include) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters