-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add installer for standalone objdictedit
* Change objdictedit title
- Loading branch information
Showing
6 changed files
with
182 additions
and
4 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
|
||
import os | ||
import re | ||
import warnings | ||
import objdictgen | ||
from setuptools import SetuptoolsDeprecationWarning | ||
from setuptools.config import read_configuration | ||
|
||
warnings.filterwarnings("ignore", category=SetuptoolsDeprecationWarning) | ||
|
||
|
||
def convert(infile, outfile): | ||
''' Tool to replace @@{VAR_NAME} in files.''' | ||
|
||
pat = re.compile(r'^(.*?)@@{(.[^}]+)}(.*)$', re.S) | ||
|
||
config = read_configuration('setup.cfg')["metadata"] | ||
|
||
# Some hacks | ||
config['version_tuple'] = objdictgen.__version_tuple__ | ||
config['copyright'] = objdictgen.__copyright__ | ||
|
||
with open(infile, "r", encoding="utf-8") as fin: | ||
out = '' | ||
for line in fin: | ||
|
||
while True: | ||
m = pat.fullmatch(line) | ||
if not m: | ||
out += line | ||
break | ||
|
||
out += m[1] | ||
name = m[2] | ||
line = m[3] # Remainder for the next iteration | ||
if name in config: | ||
out += str(config[m[2]]) | ||
|
||
elif name in os.environ: | ||
out += os.environ[name] | ||
|
||
else: | ||
raise Exception(f"The variable {name} is not defined") | ||
|
||
if out: | ||
with open(outfile, 'w', encoding="utf-8") as fout: | ||
fout.write(out) | ||
|
||
|
||
if __name__ == '__main__': | ||
import argparse | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('input', help='Input file') | ||
parser.add_argument('output', help='Output file') | ||
args = parser.parse_args() | ||
|
||
convert(args.input, args.output) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# -*- mode: python ; coding: utf-8 -*- | ||
import os | ||
import sys | ||
sys.path.append("packaging") | ||
from filereplacer import convert | ||
|
||
basepath = os.path.dirname(os.path.dirname(os.path.abspath(SPEC))) | ||
|
||
workpath = basepath | ||
os.chdir(workpath) | ||
|
||
script = """ | ||
from objdictgen.ui import objdictedit | ||
objdictedit.main() | ||
""" | ||
|
||
os.makedirs("build", exist_ok=True) | ||
with open("build/objdictedit.py", "w", encoding="utf-8") as f: | ||
f.write(script) | ||
|
||
icon = basepath + "/src/objdictgen/img/networkedit.ico" | ||
|
||
convert("packaging/objdictedit.ver.in", "build/objdictedit.ver") | ||
|
||
a = Analysis( | ||
[basepath + '/build/objdictedit.py'], | ||
pathex=[], | ||
binaries=[], | ||
datas=[ | ||
(basepath + "/src/objdictgen/img/networkedit.ico", "objdictgen/img"), | ||
], | ||
hiddenimports=[], | ||
hookspath=[], | ||
hooksconfig={}, | ||
runtime_hooks=[], | ||
excludes=[], | ||
noarchive=False, | ||
optimize=0, | ||
) | ||
pyz = PYZ(a.pure) | ||
|
||
exe = EXE( | ||
pyz, | ||
a.scripts, | ||
a.binaries, | ||
a.datas, | ||
[], | ||
name='objdictedit', | ||
debug=False, | ||
bootloader_ignore_signals=False, | ||
strip=False, | ||
upx=True, | ||
upx_exclude=[], | ||
runtime_tmpdir=None, | ||
console=True, | ||
disable_windowed_traceback=False, | ||
argv_emulation=False, | ||
target_arch=None, | ||
codesign_identity=None, | ||
entitlements_file=None, | ||
icon=icon, | ||
version=basepath + '/build/objdictedit.ver', | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# UTF-8 | ||
# | ||
# For more details about fixed file info 'ffi' see: | ||
# http://msdn.microsoft.com/en-us/library/ms646997.aspx | ||
VSVersionInfo( | ||
ffi=FixedFileInfo( | ||
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4) | ||
# Set not needed items to zero 0. | ||
filevers=@@{version_tuple}, | ||
prodvers=@@{version_tuple}, | ||
# Contains a bitmask that specifies the valid bits 'flags'r | ||
mask=0x3f, | ||
# Contains a bitmask that specifies the Boolean attributes of the file. | ||
flags=0x0, | ||
# The operating system for which this file was designed. | ||
# 0x4 - NT and there is no need to change it. | ||
OS=0x4, | ||
# The general type of file. | ||
# 0x1 - the file is an application. | ||
fileType=0x1, | ||
# The function of the file. | ||
# 0x0 - the function is not defined for this fileType | ||
subtype=0x0, | ||
# Creation date and time stamp. | ||
date=(0, 0) | ||
), | ||
kids=[ | ||
StringFileInfo( | ||
[ | ||
StringTable( | ||
u'040904B0', | ||
[StringStruct(u'CompanyName', u'Object Dictionary Editor'), | ||
StringStruct(u'FileDescription', u'@@{description}'), | ||
StringStruct(u'FileVersion', u'@@{version}'), | ||
StringStruct(u'InternalName', u'objdictedit'), | ||
StringStruct(u'LegalCopyright', u'@@{copyright}'), | ||
StringStruct(u'OriginalFilename', u'objdictedit.exe'), | ||
StringStruct(u'ProductName', u'objdictedit'), | ||
StringStruct(u'ProductVersion', u'@@{version}')]) | ||
]), | ||
VarFileInfo([VarStruct(u'Translation', [1033, 1200])]) | ||
] | ||
) |
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
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