Skip to content

Commit eb350ac

Browse files
committed
pyproject.toml updated, hatch_build.py updated
1 parent 95450e7 commit eb350ac

2 files changed

Lines changed: 22 additions & 22 deletions

File tree

hatch_build.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,26 @@ def initialize(self, version, build_data):
5555
current_os = platform.system().lower()
5656
arch = platform.machine().lower()
5757
print(f"OS: {current_os}, arch: {arch}")
58-
lua_dir = os.path.join(os.path.dirname(__file__), "python_lua_helper", "lua")
5958
# Build lua for linux
6059
lua_version = "5.4.8"
6160
lua_src = f"lua-{lua_version}.tar.gz"
6261
lua_checksum = f"lua-{lua_version}.sha256"
62+
root_dir = os.path.dirname(__file__)
63+
package_dir = os.path.join(root_dir, "python_lua_helper")
6364
if current_os == "linux":
6465
print("Linux detected - building Lua from source...")
65-
# Change to lua directory
66-
os.chdir(lua_dir)
66+
# Change to root directory
67+
os.chdir(root_dir)
68+
# Clean/create build directory
69+
build_dir = os.path.join(root_dir, "build")
70+
if os.path.exists(build_dir):
71+
shutil.rmtree(build_dir)
72+
os.makedirs(build_dir, exist_ok=False)
6773
# Download Lua source if it doesn't exist
6874
if not os.path.exists(lua_src):
6975
print(f"Downloading {lua_src}")
7076
self.run(
71-
lua_dir,
77+
build_dir,
7278
"curl",
7379
"-s",
7480
"-L",
@@ -79,20 +85,14 @@ def initialize(self, version, build_data):
7985
# Check checksum
8086
print(f"Checking {lua_src}")
8187
self.check_sha256(lua_src, lua_checksum)
82-
# Remove and recreate build directory
83-
build_dir = os.path.join(lua_dir, "build")
84-
# Use python native methods for removing and creating dirs below
85-
if os.path.exists(build_dir):
86-
shutil.rmtree(build_dir)
87-
os.makedirs(build_dir, exist_ok=False)
8888
# Extract archive
8989
shutil.unpack_archive(lua_src, build_dir)
9090
# Change to extracted Lua source directory
9191
lua_build_dir = os.path.join(build_dir, f"lua-{lua_version}")
9292
os.chdir(lua_build_dir)
9393
# Apply patch
9494
print("Applying build patch...")
95-
patch_file = os.path.join(lua_dir, "build.patch")
95+
patch_file = os.path.join(root_dir, "build.patch")
9696
self.run(lua_build_dir, "patch", "-p1", "-i", patch_file)
9797
# Build Lua with optimization flags
9898
print("Building Lua...")
@@ -109,17 +109,17 @@ def initialize(self, version, build_data):
109109
self.run(lua_build_dir, "strip", "--strip-unneeded", lua_binary)
110110
# Copy result
111111
print("Copying Lua binary...")
112-
dest_lua = os.path.join(lua_dir, "lua")
113-
shutil.copy2(lua_binary, dest_lua)
112+
target_binary = os.path.join(package_dir, "lua")
113+
shutil.copy2(lua_binary, target_binary)
114114
elif current_os == "windows":
115115
print(
116116
f"Windows detected (architecture: {arch}) - selecting pre-built Lua binary..."
117117
)
118-
target_binary = os.path.join(lua_dir, "lua.exe")
118+
target_binary = os.path.join(package_dir, "lua.exe")
119119
if arch in ["x86_64", "amd64"]:
120-
source_binary = os.path.join(lua_dir, "lua-windows-x86_64")
120+
source_binary = os.path.join(root_dir, "lua-windows-x86_64")
121121
elif arch in ["i386", "i586", "i686", "x86"]:
122-
source_binary = os.path.join(lua_dir, "lua-windows-i686")
122+
source_binary = os.path.join(root_dir, "lua-windows-i686")
123123
else:
124124
print(
125125
f"Warning: Unsupported Windows architecture '{arch}' - no Lua binary available"

pyproject.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ source = "vcs"
2222

2323
[tool.hatch.build.targets.sdist]
2424
packages = ["python_lua_helper"]
25+
include = [
26+
"build-mingw.sh",
27+
"*.patch",
28+
"*.sha256",
29+
"lua-windows-*",
30+
]
2531

2632
[tool.hatch.build.targets.wheel]
2733
packages = ["python_lua_helper"]
28-
exclude = [
29-
"python_lua_helper/lua/*.sh",
30-
"python_lua_helper/lua/*.patch",
31-
"python_lua_helper/lua/*.sha256",
32-
"python_lua_helper/lua/lua-*",
33-
]
3434

3535
[tool.hatch.build.targets.wheel.hooks.custom]

0 commit comments

Comments
 (0)