from setuptools.command.develop import develop
from multiprocessing import cpu_count
from direct.dist.commands import bdist_apps
-from ya2.build.build import branch, files, ver, files, bld_dpath
+from ya2.build.build import _branch, files, _ver, files
#from ya2.build.docs import bld_docs
from ya2.build.models import ModelsBuilder
from ya2.build.images import bld_images
system(cmd)
bdist_apps.run(self)
if not self.nolinux:
- hbranch = {'master': 'alpha', 'rc': 'rc', 'stable': ''}[branch]
+ hbranch = {'master': 'alpha', 'rc': 'rc', 'stable': ''}[_branch()]
AppImageBuilder(self).build(longname, hbranch,
'https://www.ya2.it/downloads/')
- fbranch = {'master': 'alpha', 'rc': 'rc', 'stable': 'stable'}[branch]
+ fbranch = {'master': 'alpha', 'rc': 'rc', 'stable': 'stable'}[_branch()]
# bld = FlatpakBuilder(
# self,
# 'it.ya2.Pmachines',
from os.path import exists, basename, join
from glob import glob
from panda3d.core import Filename
-from ya2.build.build import exec_cmd, _branch, ver
+from ya2.build.build import exec_cmd, _branch, _ver
class FunctionalTests(TestCase):
for line in lines:
if line.strip().split()[0] == _branch():
commit = line.strip().split()[1][:7]
- _ver = ver
+ __ver = _ver()
if _branch() == 'stable':
with open('/home/flavio/builders/pmachines_builder/pmachines/assets/version.txt') as fver:
- _ver = fver.read().strip() + '-'
- exp = '%s-%s' % (_ver, commit)
+ __ver = fver.read().strip() + '-'
+ exp = '%s-%s' % (__ver, commit)
cmds = [
('timeout 720s ./build/manylinux2010_x86_64/pmachines --version', str(Filename.get_user_appdata_directory()) + '/pmachines/obs_version.txt'),
('timeout 720s ./dist/Pmachines-%s-x86_64.AppImage --version' % bld_branch, str(Filename.get_user_appdata_directory()) + '/pmachines/obs_version.txt'),
'''Synchronously executes a command and returns its output.'''
# ret = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True).communicate()
# return ret[0].decode('utf-8').strip()
- proc = run(cmd, shell=True, stdout=PIPE, stderr=PIPE, universal_newlines=True)
+ proc = run(cmd, shell=True, stdout=PIPE, stderr=PIPE, universal_newlines=True, check=True)
return proc.stdout.strip() + proc.stderr.strip()
def _branch():
'''Returns the current branch.'''
git_branch = exec_cmd('git symbolic-ref HEAD').split('/')[-1].strip()
- print('git_branch result: %s' % git_branch)
+ print(f'git_branch result: {git_branch}')
branches = ['master', 'rc', 'stable']
if git_branch in branches:
- print('git_branch: %s' % git_branch)
+ print(f'git_branch: {git_branch}')
return git_branch
root = str(Path(dirname(dirname(__file__))).parent) + '/'
if 'itch' in __file__.split(sep):
root = str(Path(dirname(__file__))) + '/'
if __file__ == '/app/bin/pmachines': # flatpak
root = '/app/bin/'
- for branch in branches:
+ for __branch in branches:
try:
- print('try: %s' % root + 'assets/bld_version.txt')
- with open(root + 'assets/bld_version.txt') as fver:
- ver = fver.read()
- print('ver: %s' % ver)
- # if branch in ver:
+ print(f'try: {root}' + 'assets/bld_version.txt')
+ with open(root + 'assets/bld_version.txt', encoding='utf8') as fver:
+ __ver = fver.read()
+ print(f'ver: {__ver}')
+ # if __branch in __ver:
b2c = {'master': 'a', 'rc': 'r', 'stable': '.'}
- if ver[1] == b2c[branch]:
- return branch
+ if __ver[1] == b2c[__branch]:
+ return __branch
except FileNotFoundError:
- print('file not found: %s' % root + 'assets/bld_version.txt')
+ print(f'file not found: {root}' + 'assets/bld_version.txt')
+ return ''
def _commit():
'''Returns the current branch.'''
git_commit = exec_cmd('git rev-parse HEAD')[:7]
- print('git_commit result: %s' % git_commit)
+ print(f'git_commit result: {git_commit}')
if not git_commit.startswith("Can't r"):
return git_commit
root = str(Path(dirname(dirname(__file__))).parent) + '/'
if __file__ == '/app/bin/pmachines': # flatpak
root = '/app/bin/'
try:
- print('try: %s' % root + 'assets/bld_version.txt')
- with open(root + 'assets/bld_version.txt') as fver:
- ver = fver.read()
- print('ver: %s' % ver)
- return ver.split('-')[1]
+ print(f'try: {root}' + 'assets/bld_version.txt')
+ with open(root + 'assets/bld_version.txt', encoding='utf8') as fver:
+ __ver = fver.read()
+ print(f'ver: {__ver}')
+ return __ver.split('-')[1]
except FileNotFoundError:
- print('file not found: %s' % root + 'assets/bld_version.txt')
+ print(f'file not found: {root}' + 'assets/bld_version.txt')
+ return ''
def _version():
if _branch() == 'stable':
pref, _ver = '', ''
if exists(root + 'assets/version.txt'):
- with open(root + 'assets/version.txt') as fver:
+ with open(root + 'assets/version.txt', encoding='utf8') as fver:
pref = fver.read().strip() + '-' # + _branch() + '-'
_ver = fver.read().strip()
ret_ver = _ver or ('0.' + day)
pref = {'master': 'a', 'rc': 'rc', '': 'runtime'}[_branch()]
# except KeyError:
# pref = 'notfound'
- ret_ver = '0%s%s' % (pref, day)
+ ret_ver = f'0{pref}{day}'
pref = ret_ver
bld_ver = pref + '-' + _commit()
try:
- with open(root + 'assets/bld_version.txt', 'w') as fver:
+ with open(root + 'assets/bld_version.txt', 'w', encoding='utf8') as fver:
fver.write(bld_ver)
except OSError:
print("we can't write inside flatpaks, but we don't need it")
def __to_be_built_single(src, tgt):
if getmtime(tgt) > getmtime(src):
- print('%s is newer than %s: do not build' % (tgt, src))
+ print(f'{tgt} is newer than {src}: do not build')
return False
- with open(src, 'rb') as f:
- src_content = f.read()
- with open(tgt, 'rb') as f:
- tgt_content = f.read()
+ with open(src, 'rb') as fsrc:
+ src_content = fsrc.read()
+ with open(tgt, 'rb') as ftgt:
+ tgt_content = ftgt.read()
hash_src = md5(src_content).hexdigest()
hash_tgt = md5(tgt_content).hexdigest()
cache = {}
lines = []
if exists('hash_cache.txt'):
- with open('hash_cache.txt') as f:
- lines = f.readlines()
+ with open('hash_cache.txt', encoding='utf8') as fhash:
+ lines = fhash.readlines()
for line in lines:
line_spl = line.split()
- hash = line_spl[-1]
+ _hash = line_spl[-1]
fname = ' '.join(line_spl[:-1])
- cache[fname] = hash
+ cache[fname] = _hash
if src in cache and tgt in cache:
if hash_src == cache[src] and \
hash_tgt == cache[tgt]:
- print('%s and %s are in the cache: do not build' % (tgt, src))
+ print(f'{tgt} and {src} are in the cache: do not build')
return False
- print('%s and %s are not up-to-date: building...' % (src, tgt))
+ print(f'{src} and {tgt} are not up-to-date: building...')
return True
chdir(self.old_dir)
-bld_dpath = 'build/'
-branch = _branch()
-ver = _version()
-win_fpath = '{dst_dir}{appname}-%s-windows.exe' % branch
+# bld_dpath = 'build/'
+# branch = _branch()
+# ver = _version()
+# win_fpath = '{dst_dir}{appname}-' + f'{branch}-windows.exe'
# osx_fpath = '{dst_dir}{appname}-%s-osx.zip' % branch
# flatpak_fpath = '{dst_dir}{appname}-%s-flatpak' % branch
-appimage_fpath = '{dst_dir}{appname}-%s-appimage' % branch
+# appimage_fpath = '{dst_dir}{appname}-' + f'{branch}-appimage'
# docs_fpath = '{dst_dir}{appname}-%s-docs.tar.gz' % branch