Last active
December 28, 2018 00:29
-
-
Save parzibyte/0079ac6f33435c7191dfb0fdf53f49f4 to your computer and use it in GitHub Desktop.
Agregar assets con PyInstaller. Mira https://parzibyte.me/blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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