日本工资明细转换工具
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # -*- coding: utf-8 -*-
  2. """
  3. Build script for Excel Converter application
  4. This script uses PyInstaller to build an executable from the Python code
  5. """
  6. import os
  7. import sys
  8. import subprocess
  9. import shutil
  10. def main():
  11. # Package name and path
  12. package_name = "ExcelConverter"
  13. main_script = "main.py"
  14. icon_path = "icon.ico"
  15. # Make sure we're in the right directory
  16. script_dir = os.path.dirname(os.path.abspath(__file__))
  17. os.chdir(script_dir)
  18. # Create build command
  19. cmd = [
  20. "pyinstaller",
  21. "--name={}".format(package_name),
  22. "--onefile",
  23. "--windowed",
  24. "--clean",
  25. "--paths={}".format(script_dir),
  26. "--add-data={}{}config.py;.".format(script_dir, os.path.sep),
  27. "--add-data={}{}template.xlsx;.".format(script_dir, os.path.sep)
  28. ]
  29. # Add icon if it exists
  30. if os.path.exists(icon_path):
  31. cmd.append("--icon={}".format(icon_path))
  32. # Add main script
  33. cmd.append(main_script)
  34. # Print command
  35. print("Running command: {}".format(" ".join(cmd)))
  36. # Run PyInstaller
  37. try:
  38. subprocess.check_call(cmd)
  39. print("\nBuild completed successfully!")
  40. # Copy necessary files to dist folder
  41. dist_dir = os.path.join(script_dir, "dist", package_name)
  42. if not os.path.exists(dist_dir):
  43. dist_dir = os.path.join(script_dir, "dist")
  44. # Copy template file to dist folder
  45. if os.path.exists("template.xlsx"):
  46. shutil.copy("template.xlsx", dist_dir)
  47. print("Copied template.xlsx to {}".format(dist_dir))
  48. # Create empty config file if it doesn't exist
  49. config_path = os.path.join(dist_dir, "employee_info.json")
  50. if not os.path.exists(config_path):
  51. with open(config_path, 'w', encoding='utf-8') as f:
  52. f.write("[]")
  53. print("Created empty employee_info.json in {}".format(dist_dir))
  54. print("\nBuild is ready in: {}".format(dist_dir))
  55. except subprocess.CalledProcessError as e:
  56. print("Build failed with error:")
  57. print(e)
  58. return 1
  59. except Exception as e:
  60. print("An error occurred:")
  61. print(e)
  62. return 1
  63. return 0
  64. if __name__ == "__main__":
  65. sys.exit(main())