Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Last active December 28, 2018 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/0079ac6f33435c7191dfb0fdf53f49f4 to your computer and use it in GitHub Desktop.
Save parzibyte/0079ac6f33435c7191dfb0fdf53f49f4 to your computer and use it in GitHub Desktop.
Agregar assets con PyInstaller. Mira https://parzibyte.me/blog
Hola, soy un archivo de texto para demostrar algunos tutoriales de parzibyte.me. Puedo contener cualquier tipo de contenido, por ejemplo, saltos,
tabulaciones
y cualquier
otra
cosa.
"""
Agregar assets con PyInstaller. Ejemplo de
cómo empaquetar un archivo de texto junto
con el código fuente. El script lee un archivo
línea a línea
@author parzibyte
"""
import os, sys
def resolver_ruta(ruta_relativa):
if hasattr(sys, '_MEIPASS'):
return os.path.join(sys._MEIPASS, ruta_relativa)
return os.path.join(os.path.abspath('.'), ruta_relativa)
nombre_archivo = resolver_ruta("archivo.txt")
with open(nombre_archivo, "r") as archivo:
for linea in archivo:
print("Aquí hay una línea: ", linea)
input("Presiona Enter para salir")
# -*- mode: python -*-
block_cipher = None
a = Analysis(['main.py'],
pathex=['D:\\desarrollo\\ejercicios'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
a.datas += [("./archivo.txt", "archivo.txt", "DATA")]
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='main',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
runtime_tmpdir=None,
console=True )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment