Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
Switch to nuitka for building
Browse files Browse the repository at this point in the history
  • Loading branch information
melvyn2 committed Aug 31, 2019
1 parent 71e2bf1 commit 7e4cb8d
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 21 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
PySteamAuth/maFiles/
PySteamAuth/PyUIs/*
bin/
build/
build/PySteamAuth.build/
build/PySteamAuth.dist/
dist/
pkg/
*.pro.user
cacert.pem
page.html
2 changes: 1 addition & 1 deletion .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/scopes/Copyright.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,16 @@ Then, build it:
`$ ./make.py build`

The executable will be packaged into a folder (or an app bundle on
macOS) with other files required for PSA to run. If you require
portability, using

`$ ./make.py build --compact`

will package everything into a single executable, which is also smaller,
but has a longer startup time.
macOS) with other files required for PSA to run in `dist`.

Contributing
------------
* Testing! Simply test this program out and report bugs/missing features.

* Development: add features, fix bugs, and work on TODOs.

* Translations: coming soon

Credits
-------
* [rossengeorgiev](https://github.com/rossengeorgiev) for steam (the
Expand Down
26 changes: 26 additions & 0 deletions build/Info.template.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist>
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>PySteamAuth</string>
<key>CFBundleIconFile</key>
<string>Icon.icns</string>
<key>CFBundleIdentifier</key>
<string>com.${USERNAME}.PySteamAuth</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>PySteamAuth</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${VERSION}</string>
<key>CFBundleDisplayName</key>
<string>PySteamAuth</string>
</dict>
</plist>
21 changes: 21 additions & 0 deletions build/PropertyList-1.0.dtd
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!--- Property List Template - from http://www.apple.com/DTDs/PropertyList-1.0.dtd -->
<!ENTITY % plistObject "(array | data | date | dict | real | integer | string | true | false )" >

<!ELEMENT plist %plistObject;>
<!ATTLIST plist version CDATA "1.0" >

<!-- Collections -->
<!ELEMENT array (%plistObject;)*>
<!ELEMENT dict (key, %plistObject;)*>
<!ELEMENT key (#PCDATA)>

<!--- Primitive types -->
<!ELEMENT string (#PCDATA)>
<!ELEMENT data (#PCDATA)> <!-- Contents interpreted as Base-64 encoded -->
<!ELEMENT date (#PCDATA)> <!-- Contents should conform to a subset of ISO 8601 (in particular, YYYY '-' MM '-' DD 'T' HH ':' MM ':' SS 'Z'. Smaller units may be omitted with a loss of precision) -->

<!-- Numerical primitives -->
<!ELEMENT true EMPTY> <!-- Boolean constant true -->
<!ELEMENT false EMPTY> <!-- Boolean constant false -->
<!ELEMENT real (#PCDATA)> <!-- Contents should represent a floating point number matching ("+" | "-")? d+ ("."d*)? ("E" ("+" | "-") d+)? where d is a digit 0-9. -->
<!ELEMENT integer (#PCDATA)> <!-- Contents should represent a (possibly signed) integer number in base 10 -->
72 changes: 62 additions & 10 deletions make.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,19 @@
import subprocess
import sys
import struct
import time


if not(sys.version_info.major == 3 and sys.version_info.minor >= 6):
raise SystemExit('ERROR: Requires python >= 3.6')


def clean():
delete(os.path.join('build', sys.platform))
delete(os.path.join('bin', sys.platform))
delete(os.path.join('build', 'PySteamAuth.build'))
delete(os.path.join('build', 'PySteamAuth.dist'))
delete(os.path.join('build', 'PySteamAuth.app'))
delete('dist')
delete('pkg')

for f in glob.iglob(os.path.join(os.path.dirname(os.path.abspath(__file__)), '**', '*.pyc'), recursive=True):
delete(f)
Expand Down Expand Up @@ -75,20 +79,68 @@ def build_qt_files():
action = sys.argv[1].lower() if len(sys.argv) >= 2 else None

if action == 'build': # TODO add travis & appveyor CI
clean()
if '--dont-clean' not in sys.argv:
clean()
if '--dont-build-qt' not in sys.argv:
build_qt_files()
os.chdir('build')
try:
from PyInstaller.__main__ import run as freeze
if '--compact' in sys.argv:
freeze(['PySteamAuth-File.spec'])
else:
freeze(['PySteamAuth-Folder.spec'])
print('You can find your built executable(s) in the \'dist\' directory.')
pre_time = time.time()
sp = subprocess.run([sys.executable, '-m', 'nuitka', '--standalone', '--follow-imports',
'--plugin-enable=qt-plugins=sensible,styles',
os.path.join('..', 'PySteamAuth', 'PySteamAuth.py')])
print('Nuitka compilation took', time.time() - pre_time, 'seconds')
except ImportError:
print('PyInstaller is missing.')
print('Nuitka is missing.')
sys.exit(1)

try:
version = subprocess.run(['git', 'describe', '--tags', '--exact-match'], capture_output=True) \
.stdout.decode('utf-8').strip()
if version == '':
version = 'git' + \
subprocess.run(['git', 'rev-parse', '--short', 'HEAD'], capture_output=True) \
.stdout.decode('utf-8').strip()
if version == '':
version = '0.0.0'
except FileNotFoundError:
version = '0.0'
print('Git is not installed; using default version value')

if sys.platform == 'darwin':
os.mkdir('PySteamAuth.app')
os.mkdir(os.path.join('PySteamAuth.app', 'Contents'))
with open('Info.template.plist') as info_f:
info_plist = info_f.read()
try:
username = subprocess.run(['git', 'config', 'user.name'], capture_output=True).stdout\
.decode('utf-8')\
.replace(' ', '')\
.replace('\n', '')
if username == '':
username = 'example'
except FileNotFoundError:
username = 'example'
print('Git is not installed; using default package id')
with open(os.path.join('PySteamAuth.app', 'Contents', 'Info.plist'), 'w') as info_f:
info_f.write(info_plist
.replace('${USERNAME}', username)
.replace('${VERSION}', version))
os.rename('PySteamAuth.dist', os.path.join('PySteamAuth.app', 'Contents', 'MacOS'))
os.chdir('..')
os.mkdir('dist')
os.rename(os.path.join('build', 'PySteamAuth.app'), os.path.join('dist', 'PySteamAuth.app'))
else:
os.chdir('..')
os.rename(os.path.join('build', 'PySteamAuth.dist'), 'dist')
if '--zip' in sys.argv:
try:
os.mkdir('pkg')
except FileExistsError:
pass
archive_name = 'PySteamAuth-' + version + '-' + sys.platform + '-' + str(struct.calcsize("P") * 8) + 'bit'
shutil.make_archive(os.path.join('pkg', archive_name), format='zip', root_dir='dist')

elif action == 'install':
try:
if sys.platform == 'darwin':
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PyQt5
requests
pyinstaller
https://github.com/Nuitka/Nuitka/archive/fc25e8c25a573b98abed6123e86f9b08ab729a62.zip
https://github.com/ValvePython/steam/archive/fcb584f205a5e3f120cf39642676d59ccb4cfadb.zip

0 comments on commit 7e4cb8d

Please sign in to comment.