fix: bug for dev mode deployment
This commit is contained in:
@@ -0,0 +1,37 @@
|
|||||||
|
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
|
||||||
|
import os
|
||||||
|
|
||||||
|
class CustomHook(BuildHookInterface):
|
||||||
|
def initialize(self, version, build_data):
|
||||||
|
target = self.target_name
|
||||||
|
force_include = build_data.setdefault("force_include", {})
|
||||||
|
|
||||||
|
# Check if we are in original source tree or in an sdist
|
||||||
|
is_sdist_build = os.path.exists(os.path.join(self.root, "PKG-INFO")) or os.path.exists(os.path.join(self.root, "frontend", "dist"))
|
||||||
|
|
||||||
|
if is_sdist_build:
|
||||||
|
frontend_dist = os.path.join(self.root, "frontend", "dist")
|
||||||
|
nanobot_dir = os.path.join(self.root, "nanobot")
|
||||||
|
else:
|
||||||
|
frontend_dist = os.path.join(self.root, "..", "frontend", "dist")
|
||||||
|
nanobot_dir = os.path.join(self.root, "..", "nanobot", "nanobot")
|
||||||
|
|
||||||
|
main_py = os.path.join(self.root, "main.py")
|
||||||
|
|
||||||
|
if target == "wheel":
|
||||||
|
if os.path.exists(frontend_dist):
|
||||||
|
force_include[frontend_dist] = "app/webui"
|
||||||
|
if os.path.exists(nanobot_dir):
|
||||||
|
force_include[nanobot_dir] = "nanobot"
|
||||||
|
if os.path.exists(main_py):
|
||||||
|
force_include[main_py] = "main.py"
|
||||||
|
|
||||||
|
elif target == "sdist":
|
||||||
|
# For sdist, we only pack them if we are in the original source tree
|
||||||
|
if not is_sdist_build:
|
||||||
|
if os.path.exists(frontend_dist):
|
||||||
|
force_include[frontend_dist] = "frontend/dist"
|
||||||
|
if os.path.exists(nanobot_dir):
|
||||||
|
force_include[nanobot_dir] = "nanobot"
|
||||||
|
if os.path.exists(main_py):
|
||||||
|
force_include[main_py] = "main.py"
|
||||||
@@ -76,12 +76,7 @@ packages = ["app"]
|
|||||||
[tool.hatch.build.targets.wheel.sources]
|
[tool.hatch.build.targets.wheel.sources]
|
||||||
"app" = "app"
|
"app" = "app"
|
||||||
|
|
||||||
[tool.hatch.build.targets.wheel.force-include]
|
|
||||||
"../frontend/dist" = "app/webui"
|
|
||||||
"../nanobot/nanobot" = "nanobot"
|
|
||||||
"main.py" = "main.py"
|
|
||||||
|
|
||||||
[tool.hatch.build.targets.sdist.force-include]
|
[tool.hatch.build.hooks.custom]
|
||||||
"../frontend/dist" = "frontend/dist"
|
path = "hatch_build.py"
|
||||||
"../nanobot/nanobot" = "nanobot"
|
|
||||||
"main.py" = "main.py"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user