pyinstaller funzionante
This commit is contained in:
parent
d8c8520950
commit
5a40d24798
4 changed files with 72 additions and 8 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -3,3 +3,5 @@
|
|||
*~
|
||||
build/
|
||||
dist/
|
||||
rec/
|
||||
*.egg-info/
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
import os.path
|
||||
import sys
|
||||
from argparse import ArgumentParser, Action
|
||||
from datetime import datetime
|
||||
|
@ -74,7 +75,10 @@ def common_pre():
|
|||
logger.warn("Configuration file '%s' does not exist; skipping" % path)
|
||||
continue
|
||||
configs.append(path)
|
||||
os.chdir(os.path.dirname(os.path.realpath(__file__)))
|
||||
if getattr(sys, 'frozen', False):
|
||||
os.chdir(sys._MEIPASS)
|
||||
else:
|
||||
os.chdir(os.path.dirname(os.path.realpath(__file__)))
|
||||
for conf in configs:
|
||||
get_config().from_pyfile(conf)
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import logging
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
HOST = "localhost"
|
||||
PORT = "8000"
|
||||
|
@ -28,13 +30,18 @@ TAG_EXTRA = {}
|
|||
# LICENSE URI is special because date need to be added
|
||||
TAG_LICENSE_URI = None
|
||||
|
||||
# defaults
|
||||
STATIC_FILES = "static/"
|
||||
STATIC_PAGES = "pages/"
|
||||
try:
|
||||
from pkg_resources import resource_filename, resource_isdir
|
||||
if getattr(sys, 'frozen', False): # pyinstaller
|
||||
STATIC_FILES = os.path.join(sys._MEIPASS, STATIC_FILES)
|
||||
STATIC_PAGES = os.path.join(sys._MEIPASS, STATIC_PAGES)
|
||||
else:
|
||||
try:
|
||||
from pkg_resources import resource_filename, resource_isdir
|
||||
|
||||
if resource_isdir("techrec", "pages"):
|
||||
STATIC_PAGES = resource_filename("techrec", "pages")
|
||||
STATIC_FILES = resource_filename("techrec", "static")
|
||||
except ImportError:
|
||||
logging.exception("Error loading resources from installed part")
|
||||
if resource_isdir("techrec", "pages"):
|
||||
STATIC_PAGES = resource_filename("techrec", "pages")
|
||||
STATIC_FILES = resource_filename("techrec", "static")
|
||||
except ImportError:
|
||||
logging.exception("Error loading resources from installed part")
|
||||
|
|
51
techrec.spec
Normal file
51
techrec.spec
Normal file
|
@ -0,0 +1,51 @@
|
|||
# -*- mode: python ; coding: utf-8 -*-
|
||||
|
||||
block_cipher = None
|
||||
|
||||
|
||||
a = Analysis(
|
||||
["server/cli.py"],
|
||||
pathex=["."],
|
||||
binaries=[],
|
||||
datas=[
|
||||
("server/default_config.py", "."),
|
||||
("server/pages/", "pages/"),
|
||||
("server/static/", "static/"),
|
||||
],
|
||||
hiddenimports=[
|
||||
"techrec.cli",
|
||||
"techrec.config_manager",
|
||||
"techrec.db",
|
||||
"techrec.default_config",
|
||||
"techrec.forge",
|
||||
"techrec.maint",
|
||||
"techrec.processqueue",
|
||||
"techrec.server",
|
||||
"techrec.test_forge",
|
||||
],
|
||||
hookspath=[],
|
||||
runtime_hooks=[],
|
||||
excludes=[],
|
||||
win_no_prefer_redirects=False,
|
||||
win_private_assemblies=False,
|
||||
cipher=block_cipher,
|
||||
noarchive=False,
|
||||
)
|
||||
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
|
||||
exe = EXE(
|
||||
pyz,
|
||||
a.scripts,
|
||||
a.binaries,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
[],
|
||||
name="techrec",
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=True,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
runtime_tmpdir=None,
|
||||
console=True,
|
||||
)
|
||||
# vim: set ft=python:
|
Loading…
Reference in a new issue