Move MacOS plist info back to a template file, and simplify stuff in setup.py
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
setup.iss
|
||||
/novelwriter.desktop
|
||||
/novelWriter.pyw
|
||||
/setup/macos/Info.plist
|
||||
|
||||
# Translations
|
||||
/novelwriter/assets/i18n/*.qm
|
||||
|
||||
@@ -71,25 +71,6 @@ def extractVersion():
|
||||
|
||||
return numVers, hexVers, relDate
|
||||
|
||||
def extractCopyright():
|
||||
"""Extract the novelWriter copyright notice without having to import
|
||||
anything else from the main package.
|
||||
"""
|
||||
copyright = "Unknown"
|
||||
initFile = os.path.join("novelwriter", "__init__.py")
|
||||
try:
|
||||
with open(initFile, mode="r", encoding="utf-8") as inFile:
|
||||
for aLine in inFile:
|
||||
if aLine.startswith("__copyright__"):
|
||||
copyright = (aLine).partition("=")[2].strip().strip('"')
|
||||
except Exception as exc:
|
||||
print("Could not read file: %s" % initFile)
|
||||
print(str(exc))
|
||||
|
||||
print("novelWriter copyright: %s " % (copyright))
|
||||
|
||||
return copyright
|
||||
|
||||
|
||||
def compactVersion(numVers):
|
||||
"""Make the version number more compact."""
|
||||
@@ -414,102 +395,36 @@ def buildQtI18nTS(sysArgs):
|
||||
|
||||
return
|
||||
|
||||
|
||||
##
|
||||
# Generage MacOS PList
|
||||
##
|
||||
|
||||
def genMacOSPlist():
|
||||
|
||||
# Set Up Folder
|
||||
# =============
|
||||
|
||||
"""Set necessary values for .plist file.
|
||||
"""
|
||||
numVers, _, _ = extractVersion()
|
||||
pkgVers = compactVersion(numVers)
|
||||
|
||||
outDir = "setup/macos"
|
||||
|
||||
macosBundleName = "novelWriter"
|
||||
macosBundleExeName = "novelWriter"
|
||||
macosBundleInfo = "novelWriter: A markdown-like text editor for planning and writing novels."
|
||||
macosBundleIcon = "novelwriter.icns"
|
||||
macosBundleIdent = "io.novelwriter.novelWriter"
|
||||
macosBundleSVers = pkgVers
|
||||
macosBundleVers = numVers
|
||||
macosBundleCopyright = extractCopyright()
|
||||
copyrightYear = datetime.datetime.now().year
|
||||
|
||||
# These keys are no longer used but are present for compatability
|
||||
macosBundleVersMajor, macosBundleVersMinor, _ = pkgVers.split(".")
|
||||
pkgVersMaj, pkgVersMin, _ = pkgVers.split(".")
|
||||
|
||||
|
||||
plistXML = (
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||
"<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
|
||||
"<plist version=\"1.0\">\n"
|
||||
"<dict>\n"
|
||||
"<key>NSPrincipalClass</key>\n"
|
||||
"<string>NSApplication</string>\n"
|
||||
"<key>NSHighResolutionCapable</key>\n"
|
||||
"<string>True</string>\n"
|
||||
"<key>CFBundleDevelopmentRegion</key>\n"
|
||||
"<string>English</string>\n"
|
||||
"<key>CFBundleExecutable</key>\n"
|
||||
f"<string>{macosBundleExeName}</string>\n"
|
||||
"<key>CFBundleGetInfoString</key>\n"
|
||||
f"<string>{macosBundleInfo}</string>\n"
|
||||
"<key>CFBundleIconFile</key>\n"
|
||||
f"<string>{macosBundleIcon}</string>\n"
|
||||
"<key>CFBundleIdentifier</key>\n"
|
||||
f"<string>{macosBundleIdent}</string>\n"
|
||||
"<key>CFBundleName</key>\n"
|
||||
f"<string>{macosBundleName}</string>\n"
|
||||
"<key>CFBundleDisplayName</key>\n"
|
||||
f"<string>{macosBundleName}</string>\n"
|
||||
"<key>CFBundleInfoDictionaryVersion</key>\n"
|
||||
"<string>6.0</string>\n"
|
||||
"<key>CFBundleShortVersionString</key>\n"
|
||||
f"<string>{macosBundleSVers}</string>\n"
|
||||
"<key>CFBundleSignature</key>\n"
|
||||
"<string>????</string>\n"
|
||||
"<key>CFBundleVersion</key>\n"
|
||||
f"<string>{macosBundleVers}</string>\n"
|
||||
"<key>CFBundlePackageType</key>\n"
|
||||
"<string>APPL</string>\n"
|
||||
"<key>NSHumanReadableCopyright</key>\n"
|
||||
f"<string>{macosBundleCopyright}</string>\n"
|
||||
"<key>IFMajorVersion</key>\n"
|
||||
f"<integer>{macosBundleVersMajor}</integer>\n"
|
||||
"<key>IFMinorVersion</key>\n"
|
||||
f"<integer>{macosBundleVersMinor}</integer>\n"
|
||||
"<key>CFBundleDocumentTypes</key>\n"
|
||||
" <array>\n"
|
||||
" <dict>\n"
|
||||
" <key>CFBundleTypeExtensions</key>\n"
|
||||
" <array>\n"
|
||||
" <string>nwx</string>\n"
|
||||
" </array>\n"
|
||||
" <key>CFBundleTypeName</key>\n"
|
||||
" <string>novelWriter Project</string>\n"
|
||||
" <key>CFBundleTypeOSTypes</key>\n"
|
||||
" <array>\n"
|
||||
" <string>TEXT</string>\n"
|
||||
" <string>utxt</string>\n"
|
||||
" <string>TUTX</string>\n"
|
||||
" <string>****</string>\n"
|
||||
" </array>\n"
|
||||
" <key>CFBundleTypeRole</key>\n"
|
||||
" <string>Viewer</string>\n"
|
||||
" <key>LSHandlerRank</key>\n"
|
||||
" <string>Alternate</string>\n"
|
||||
" </dict>\n"
|
||||
" </array>\n"
|
||||
"</dict>\n"
|
||||
"</plist>\n"
|
||||
plistXML = readFile(f"{outDir}/Info.plist.template").format(
|
||||
macosBundleSVers=pkgVers,
|
||||
macosBundleVers=numVers,
|
||||
macosBundleVersMajor=pkgVersMaj,
|
||||
macosBundleVersMinor=pkgVersMin,
|
||||
macosBundleCopyright=f"Copyright 2018–{copyrightYear}, Veronica Berglyd Olsen",
|
||||
)
|
||||
|
||||
print(f"Writing Info.plist to {outDir}/Info.plist")
|
||||
|
||||
writeFile(f"{outDir}/Info.plist", plistXML)
|
||||
|
||||
return
|
||||
|
||||
|
||||
##
|
||||
# Sample Project ZIP File Builder (sample)
|
||||
@@ -2059,7 +1974,7 @@ if __name__ == "__main__":
|
||||
if "clean-assets" in sys.argv:
|
||||
sys.argv.remove("clean-assets")
|
||||
cleanBuiltAssets()
|
||||
|
||||
|
||||
if "gen-plist" in sys.argv:
|
||||
sys.argv.remove("gen-plist")
|
||||
genMacOSPlist()
|
||||
|
||||
@@ -7,4 +7,4 @@
|
||||
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
</plist>
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
<string>True</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>novelWriter</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>novelWriter: A markdown-like text editor for planning and writing novels.</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>novelwriter.icns</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>io.novelwriter.novelWriter</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>novelWriter</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>novelWriter</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>{macosBundleSVers}</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>{macosBundleVers}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>{macosBundleCopyright}</string>
|
||||
<key>IFMajorVersion</key>
|
||||
<integer>{macosBundleVersMajor}</integer>
|
||||
<key>IFMinorVersion</key>
|
||||
<integer>{macosBundleVersMinor}</integer>
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
<string>nwx</string>
|
||||
</array>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>novelWriter Project</string>
|
||||
<key>CFBundleTypeOSTypes</key>
|
||||
<array>
|
||||
<string>TEXT</string>
|
||||
<string>utxt</string>
|
||||
<string>TUTX</string>
|
||||
<string>****</string>
|
||||
</array>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Viewer</string>
|
||||
<key>LSHandlerRank</key>
|
||||
<string>Alternate</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
Reference in New Issue
Block a user