Skip to content

Commit

Permalink
Builder updates
Browse files Browse the repository at this point in the history
  • Loading branch information
F33RNI committed Feb 11, 2023
1 parent 7fa3bad commit 3521606
Showing 1 changed file with 32 additions and 23 deletions.
55 changes: 32 additions & 23 deletions Builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

from main import WEBINAR_HACKER_VERSION

# True to delete dist and build folder every time and build with --clean flag
CLEAN_BUILD = True

MAIN_FILE = 'main'
FINAL_NAME = 'Webinar-hacker'

Expand All @@ -49,16 +52,17 @@

if __name__ == '__main__':
pyi_command = []

# Remove dist folder is exists
if 'dist' in os.listdir('./'):
shutil.rmtree('dist', ignore_errors=True)
print('dist folder deleted')

# Remove build folder is exists
if 'build' in os.listdir('./'):
shutil.rmtree('build', ignore_errors=True)
print('build folder deleted')
if CLEAN_BUILD:
print('Deleting dist and build folders...')
# Remove dist folder is exists
if 'dist' in os.listdir('./'):
shutil.rmtree('dist', ignore_errors=True)
print('dist folder deleted')

# Remove build folder is exists
if 'build' in os.listdir('./'):
shutil.rmtree('build', ignore_errors=True)
print('build folder deleted')

# Add all .py files to pyi_command
for file in os.listdir('./'):
Expand All @@ -78,6 +82,9 @@
pyi_command.insert(0, 'torch')
pyi_command.insert(0, '--collect-data')

pyi_command.insert(0, 'whisper-timestamped')
pyi_command.insert(0, '--collect-data')

pyi_command.insert(0, 'tensorflow')
pyi_command.insert(0, '--collect-data')

Expand Down Expand Up @@ -108,7 +115,7 @@
pyi_command.insert(0, 'tokenizers')
pyi_command.insert(0, '--copy-metadata')

pyi_command.insert(0, 'tokenizers')
pyi_command.insert(0, 'whisper-timestamped')
pyi_command.insert(0, '--copy-metadata')

pyi_command.insert(0, 'pyi-makespec')
Expand Down Expand Up @@ -159,7 +166,7 @@
'(\'' + os.path.join(site_packages_path,'huggingsound').replace('\\','\\\\') + '\', \'huggingsound\'),'
'(\'' + os.path.join(site_packages_path, 'datasets').replace('\\','\\\\') + '\', \'datasets\'),'
'(\'' + os.path.join(site_packages_path, 'transformers').replace('\\','\\\\') + '\', \'transformers\'),'
'(\'' + 'dict-ru' + '\', \'enchant/data/mingw64/share/enchant/hunspell\')'
'(\'' + os.path.join(site_packages_path, 'whisper').replace('\\','\\\\') + '\', \'whisper\')'
']')

# Set final name
Expand All @@ -173,24 +180,26 @@
# exit(0)

# Create new pyi command
# pyi_command = ['pyinstaller', MAIN_FILE + '.spec']
pyi_command = ['pyinstaller', MAIN_FILE + '.spec', '--clean']
if CLEAN_BUILD:
pyi_command = ['pyinstaller', MAIN_FILE + '.spec', '--clean']
else:
pyi_command = ['pyinstaller', MAIN_FILE + '.spec']

# Execute pyi
print(pyi_command)
subprocess.run(pyi_command, text=True)

# If dist folder created
if 'dist' in os.listdir('.') and FINAL_NAME in os.listdir('./dist'):

# Remove build folder is exists
if 'build' in os.listdir('./'):
shutil.rmtree('build', ignore_errors=True)
print('build folder deleted')

# Wait some time
print('Waiting 1 second...')
time.sleep(1)
if CLEAN_BUILD:
# Remove build folder is exists
if 'build' in os.listdir('./'):
shutil.rmtree('build', ignore_errors=True)
print('build folder deleted')

# Wait some time
print('Waiting 1 second...')
time.sleep(1)

# Copy include files to it
for file in INCLUDE_FILES:
Expand Down

0 comments on commit 3521606

Please sign in to comment.