poikilos
2 years ago
27 changed files with 1532 additions and 1169 deletions
@ -1,141 +1,150 @@ |
|||||
#!/usr/bin/env python |
#!/usr/bin/env python |
||||
import os |
import os |
||||
|
import sys |
||||
import shutil |
import shutil |
||||
from forwardfilesync import * |
from forwardfilesync import * |
||||
# import filever |
# import filever |
||||
try: |
from pyenliven import ( |
||||
input = raw_input |
echo0, |
||||
except NameError: |
) |
||||
|
if sys.version_info.major >= 3: |
||||
pass |
pass |
||||
|
else: |
||||
|
input = raw_input |
||||
|
|
||||
warnings = list() |
|
||||
|
|
||||
print("") |
def rm_sub(bad_sub): |
||||
print("This script is NOT YET IMPLEMENTED") |
bad_path = path_join_all(deploy_path, bad_sub) |
||||
|
if os.path.isfile(bad_path): |
||||
|
os.remove(bad_path) |
||||
|
|
||||
|
|
||||
|
def main(): |
||||
|
warnings = list() |
||||
|
|
||||
|
echo0("") |
||||
|
echo0("This script is NOT YET IMPLEMENTED") |
||||
|
|
||||
# TODO: Scrape https://minetest.kitsunemimi.pw/builds/ (NOTE: stable is |
|
||||
# always "https://minetest.kitsunemimi.pw/builds/win64/" |
|
||||
# "minetest-0.4.15-win64.7z") |
|
||||
|
|
||||
|
# TODO: Scrape https://minetest.kitsunemimi.pw/builds/ (NOTE: stable is |
||||
|
# always "https://minetest.kitsunemimi.pw/builds/win64/" |
||||
|
# "minetest-0.4.15-win64.7z") |
||||
|
|
||||
print("This script patches minetest and minetest_game with ENLIVEN\n" + |
|
||||
|
echo0("This script patches minetest and minetest_game with ENLIVEN\n" + |
||||
"(such as launcher and subgame) and creates a Windows installer.") |
"(such as launcher and subgame) and creates a Windows installer.") |
||||
|
|
||||
script_dir_path = os.path.dirname(os.path.abspath(__file__)) |
script_dir_path = os.path.dirname(os.path.abspath(__file__)) |
||||
enliven_project_path = os.path.dirname(script_dir_path) |
enliven_project_path = os.path.dirname(script_dir_path) |
||||
|
|
||||
profile_path = None |
profile_path = None |
||||
if "HOME" in os.environ: |
if "HOME" in os.environ: |
||||
profile_path = os.environ["HOME"] |
profile_path = os.environ["HOME"] |
||||
elif "USERPROFILE" in os.environ: |
elif "USERPROFILE" in os.environ: |
||||
profile_path = os.environ["USERPROFILE"] |
profile_path = os.environ["USERPROFILE"] |
||||
else: |
else: |
||||
try_path = "C:\\Users\\jgustafson" |
try_path = "C:\\Users\\jgustafson" |
||||
if not os.path.isdir(try_path): |
if not os.path.isdir(try_path): |
||||
try_path = "C:\\Users\\Owner" |
try_path = "C:\\Users\\Owner" |
||||
|
|
||||
print("WARNING: no HOME or USERPROFILE found, reverting to '" + |
echo0("WARNING: no HOME or USERPROFILE found, reverting to '" + |
||||
try_path + "'") |
try_path + "'") |
||||
profile_path = try_path |
profile_path = try_path |
||||
# TODO: Make a settings file for values in the next region. |
# TODO: Make a settings file for values in the next region. |
||||
# region user settings |
# region user settings |
||||
deploy_path = "C:\\Games\\ENLIVEN-deploy" |
deploy_path = "C:\\Games\\ENLIVEN-deploy" |
||||
try_path = "C:\\Games\\Minetest" |
try_path = "C:\\Games\\Minetest" |
||||
if (not os.path.isdir(deploy_path)) and os.path.isdir(try_path): |
if (not os.path.isdir(deploy_path)) and os.path.isdir(try_path): |
||||
deploy_path = try_path |
deploy_path = try_path |
||||
installer_deploy_path = path_join_all([profile_path, "ownCloud", "www", |
installer_deploy_path = path_join_all([profile_path, "ownCloud", "www", |
||||
"expertmultimedia", "downloads"]) |
"expertmultimedia", "downloads"]) |
||||
installer_name = "install-ENLIVEN.exe" |
installer_name = "install-ENLIVEN.exe" |
||||
# endregion user settings |
# endregion user settings |
||||
|
|
||||
installer_path = os.path.join(installer_deploy_path, installer_name) |
installer_path = os.path.join(installer_deploy_path, installer_name) |
||||
|
|
||||
if not os.path.isdir(installer_deploy_path): |
if not os.path.isdir(installer_deploy_path): |
||||
print("#WARNING: does not exist:") |
echo0("#WARNING: does not exist:") |
||||
print("installer_deploy_path: " + installer_deploy_path) |
print("installer_deploy_path: " + installer_deploy_path) |
||||
|
|
||||
# this is a waste--it just shows 0.0.0.0 though iss file has version |
# this is a waste--it just shows 0.0.0.0 though iss file has version |
||||
# if os.path.isfile(installer_path): |
# if os.path.isfile(installer_path): |
||||
# numbers=filever.get_version_number(installer_path) |
# numbers=filever.get_version_number(installer_path) |
||||
# major,minor,subminor,revision = numbers |
# major,minor,subminor,revision = numbers |
||||
# print(".".join([str (i) for i in numbers])) |
# print(".".join([str (i) for i in numbers])) |
||||
|
|
||||
if not os.path.isdir(deploy_path): |
if not os.path.isdir(deploy_path): |
||||
os.makedirs(deploy_path) |
os.makedirs(deploy_path) |
||||
games_path = os.path.join(deploy_path, "games") |
games_path = os.path.join(deploy_path, "games") |
||||
minetest_game_path = os.path.join(games_path, "minetest_game") |
minetest_game_path = os.path.join(games_path, "minetest_game") |
||||
minetest_game_mods_path = os.path.join(minetest_game_path, "mods") |
minetest_game_mods_path = os.path.join(minetest_game_path, "mods") |
||||
if not os.path.isdir(minetest_game_path): |
if not os.path.isdir(minetest_game_path): |
||||
print("This deploy script requires an unmodified build of minetest and\n" + |
echo0("This deploy script requires an unmodified build of minetest and\n" + |
||||
" minetest_game. Please place an unmodified build of minetest in\n" + |
" minetest_game. Please place an unmodified build of minetest in\n" + |
||||
" " + deploy_path + " so that minetest_game is at: \n\n" + |
" " + deploy_path + " so that minetest_game is at: \n\n" + |
||||
" " + minetest_game_path + "\n\n") |
" " + minetest_game_path + "\n\n") |
||||
exit(1) |
return 1 |
||||
|
|
||||
game_path = os.path.join(games_path, "ENLIVEN") |
game_path = os.path.join(games_path, "ENLIVEN") |
||||
|
|
||||
# NOTE: remove this case, and instead: copy minetest_game, download ENLIVEN |
# NOTE: remove this case, and instead: copy minetest_game, download ENLIVEN |
||||
# automatically |
# automatically |
||||
if not os.path.isdir(game_path): |
if not os.path.isdir(game_path): |
||||
print("") |
echo0("") |
||||
print("ERROR: ENLIVEN must first be installed from web sources" + |
echo0("ERROR: ENLIVEN must first be installed from web sources" + |
||||
" using the provided 'install' script in the etc/change*" + |
" using the provided 'install' script in the etc/change*" + |
||||
" folder (run on linux then copy to a Windows machine" + |
" folder (run on linux then copy to a Windows machine" + |
||||
" in " + game_path) |
" in " + game_path) |
||||
# exit(2) |
# return 2 |
||||
else: |
else: |
||||
print("game_path: " + game_path) |
print("game_path: " + game_path) |
||||
mods_path = os.path.join(game_path, "mods") |
mods_path = os.path.join(game_path, "mods") |
||||
if not os.path.isdir(mods_path): |
if not os.path.isdir(mods_path): |
||||
os.makedirs(mods_path) |
os.makedirs(mods_path) |
||||
mtg_list_path = os.path.join(game_path, "minetest_game-mod-list.txt") |
mtg_list_path = os.path.join(game_path, "minetest_game-mod-list.txt") |
||||
mtg_list_out = open(mtg_list_path, 'w') |
mtg_list_out = open(mtg_list_path, 'w') |
||||
folder_path = minetest_game_mods_path |
folder_path = minetest_game_mods_path |
||||
if os.path.isdir(folder_path): |
if os.path.isdir(folder_path): |
||||
for sub_name in os.listdir(folder_path): |
for sub_name in os.listdir(folder_path): |
||||
sub_path = os.path.join(folder_path, sub_name) |
sub_path = os.path.join(folder_path, sub_name) |
||||
if sub_name[:1] != "." and os.path.isdir(sub_path): |
if sub_name[:1] != "." and os.path.isdir(sub_path): |
||||
mtg_list_out.write(sub_name + "\n") |
mtg_list_out.write(sub_name + "\n") |
||||
mtg_list_out.close() |
mtg_list_out.close() |
||||
|
|
||||
# TODO: uncomment this: update_tree(minetest_game_path, game_path) |
# TODO: uncomment this: update_tree(minetest_game_path, game_path) |
||||
|
|
||||
server_devel_minetest_conf_path = os.path.join( |
server_devel_minetest_conf_path = os.path.join( |
||||
game_path, |
game_path, |
||||
"minetest.conf.ENLIVEN-server" |
"minetest.conf.ENLIVEN-server" |
||||
) |
) |
||||
server_minetest_conf_path = os.path.join(game_path, "minetest.conf") |
server_minetest_conf_path = os.path.join(game_path, "minetest.conf") |
||||
|
|
||||
if not os.path.isfile(server_devel_minetest_conf_path): |
if not os.path.isfile(server_devel_minetest_conf_path): |
||||
warnings.append(server_devel_minetest_conf_path + " was not found") |
warnings.append(server_devel_minetest_conf_path + " was not found") |
||||
else: |
else: |
||||
shutil.copyfile(server_devel_minetest_conf_path, |
shutil.copyfile(server_devel_minetest_conf_path, |
||||
server_minetest_conf_path) |
server_minetest_conf_path) |
||||
|
|
||||
|
rm_sub(["CC-BY-SA 3.0 Unported (fallback license for ENLIVEN assets)" |
||||
def rm_sub(bad_sub): |
|
||||
bad_path = path_join_all(deploy_path, bad_sub) |
|
||||
if os.path.isfile(bad_path): |
|
||||
os.remove(bad_path) |
|
||||
|
|
||||
|
|
||||
rm_sub(["CC-BY-SA 3.0 Unported (fallback license for ENLIVEN assets)" |
|
||||
".txt"]) |
".txt"]) |
||||
rm_sub(["MIT LICENSE (fallback license for ENLIVEN code).txt"]) |
rm_sub(["MIT LICENSE (fallback license for ENLIVEN code).txt"]) |
||||
|
|
||||
# NOTE: At this point, the following LICENSE and README files are |
# NOTE: At this point, the following LICENSE and README files are |
||||
# minetest_game's and the following are intentionally looking in |
# minetest_game's and the following are intentionally looking in |
||||
# C:\games\ENLIVEN\games\ENLIVEN: |
# C:\games\ENLIVEN\games\ENLIVEN: |
||||
# rm_sub(["games", "ENLIVEN", "LICENSE.txt"]) |
# rm_sub(["games", "ENLIVEN", "LICENSE.txt"]) |
||||
# rm_sub(["games", "ENLIVEN", "README.txt"]) |
# rm_sub(["games", "ENLIVEN", "README.txt"]) |
||||
|
|
||||
print("") |
echo0("") |
||||
if len(warnings) > 0: |
if len(warnings) > 0: |
||||
print(str(len(warnings)) + " warning(s):") |
echo0(str(len(warnings)) + " warning(s):") |
||||
for warning in warnings: |
for warning in warnings: |
||||
print(warning) |
echo0(warning) |
||||
else: |
else: |
||||
print("0 warnings.") |
echo0("0 warnings.") |
||||
print("\n") |
echo0() |
||||
input("press enter to exit...") |
return 0 |
||||
|
|
||||
|
|
||||
|
if __name__ == "__main__": |
||||
|
sys.exit(main()) |
||||
|
@ -0,0 +1,103 @@ |
|||||
|
#!/usr/bin/env python |
||||
|
''' |
||||
|
This module assists with building games from other games, mods, and |
||||
|
patches. |
||||
|
''' |
||||
|
from __future__ import print_function |
||||
|
|
||||
|
import sys |
||||
|
import platform |
||||
|
import os |
||||
|
|
||||
|
profile = None |
||||
|
if platform.system() == "Windows": |
||||
|
profile = os.environ.get('USERPROFILE') |
||||
|
else: |
||||
|
profile = os.environ.get('HOME') |
||||
|
|
||||
|
verbosity = 0 |
||||
|
max_verbosity = 2 |
||||
|
|
||||
|
|
||||
|
def echo0(*args, **kwargs): |
||||
|
print(*args, file=sys.stderr, **kwargs) |
||||
|
|
||||
|
|
||||
|
def echo1(*args, **kwargs): |
||||
|
if verbosity < 1: |
||||
|
return False |
||||
|
print(*args, file=sys.stderr, **kwargs) |
||||
|
return True |
||||
|
|
||||
|
|
||||
|
def echo2(*args, **kwargs): |
||||
|
if verbosity < 2: |
||||
|
return False |
||||
|
print(*args, file=sys.stderr, **kwargs) |
||||
|
return True |
||||
|
|
||||
|
|
||||
|
def get_verbosity(): |
||||
|
return verbosity |
||||
|
|
||||
|
|
||||
|
def set_verbosity(level): |
||||
|
if level is True: |
||||
|
verbosity = 1 |
||||
|
elif level is False: |
||||
|
verbosity = 0 |
||||
|
elif level in range(max_verbosity+1): |
||||
|
verbosity = level |
||||
|
raise ValueError( |
||||
|
"verbosity must be {} at maximum.".format(max_verbosity) |
||||
|
) |
||||
|
|
||||
|
|
||||
|
try: |
||||
|
import mtanalyze |
||||
|
except ModuleNotFoundError as ex: |
||||
|
# tryMTA = os.path.join(profile, "git", "mtanalyze") |
||||
|
moduleDir = os.path.dirname(os.path.realpath(__file__)) |
||||
|
REPO_DIR = os.path.dirname(moduleDir) |
||||
|
modulesDir = os.path.dirname(REPO_DIR) |
||||
|
echo0("* looking for mtanalyze in modulesDir \"{}\"" |
||||
|
"".format(modulesDir)) |
||||
|
tryMTA = os.path.abspath(os.path.join(modulesDir, "mtanalyze")) |
||||
|
if os.path.isdir(tryMTA): |
||||
|
sys.path.append(tryMTA) |
||||
|
import mtanalyze |
||||
|
# ^ import mtanalyze/mtanalyze purposely since the main |
||||
|
# mtanalyze/ directory is a setuptools package not a module. |
||||
|
else: |
||||
|
echo0("") |
||||
|
echo0("You must install mtanalyze alongside") |
||||
|
echo0("EnlivenMinetest such that ../mtanalize/mtanalize exists") |
||||
|
echo0("such as via:") |
||||
|
echo0(" git clone https://github.com/poikilos/mtanalyze {}" |
||||
|
"".format(tryMTA)) |
||||
|
echo0("") |
||||
|
# raise tryMTA |
||||
|
exit(1) |
||||
|
|
||||
|
# from mtanalyze import profile_path |
||||
|
MY_MODULE_DIR = os.path.dirname(os.path.realpath(__file__)) |
||||
|
# ^ realpath follows symlinks |
||||
|
REPO_DIR = os.path.dirname(MY_MODULE_DIR) |
||||
|
MODS_STOPGAP_DIR = os.path.join(REPO_DIR, "patches", "mods-stopgap") |
||||
|
if not os.path.isdir(MODS_STOPGAP_DIR): |
||||
|
echo0("Error: \"{}\" is missing.".format(MODS_STOPGAP_DIR)) |
||||
|
exit(1) |
||||
|
BASE_DIR = os.path.join(REPO_DIR, "Bucket_Game-base") |
||||
|
if not os.path.isdir(BASE_DIR): |
||||
|
echo0("Error: \"{}\" is missing.".format(BASE_DIR)) |
||||
|
exit(1) |
||||
|
BRANCHES_DIR = os.path.join(REPO_DIR, "Bucket_Game-branches") |
||||
|
if not os.path.isdir(BRANCHES_DIR): |
||||
|
echo0("Error: \"{}\" is missing.".format(BRANCHES_DIR)) |
||||
|
exit(1) |
||||
|
|
||||
|
# NOTE: get a git repo's origin via: git remote show origin |
||||
|
|
||||
|
|
||||
|
def getSGPath(stopgap_mod_name): |
||||
|
return os.path.join(MODS_STOPGAP_DIR, stopgap_mod_name) |
@ -0,0 +1,77 @@ |
|||||
|
#!/usr/bin/env python |
||||
|
import setuptools |
||||
|
import sys |
||||
|
import os |
||||
|
# - For the example on which this was based, see |
||||
|
# https://github.com/poikilos/linux-preinstall/blob/main/setup.py |
||||
|
# which is based on |
||||
|
# https://github.com/poikilos/world_clock/blob/main/setup.py |
||||
|
# which is based on |
||||
|
# https://github.com/poikilos/nopackage/blob/main/setup.py |
||||
|
# which is based on |
||||
|
# https://github.com/poikilos/pypicolcd/blob/master/setup.py |
||||
|
# - For nose, see https://github.com/poikilos/mgep/blob/master/setup.py |
||||
|
|
||||
|
# python_mr = sys.version_info.major |
||||
|
# versionedModule = {} |
||||
|
# versionedModule['urllib'] = 'urllib' |
||||
|
# if python_mr == 2: |
||||
|
# versionedModule['urllib'] = 'urllib2' |
||||
|
|
||||
|
install_requires = [] |
||||
|
|
||||
|
if os.path.isfile("requirements.txt"): |
||||
|
with open("requirements.txt", "r") as ins: |
||||
|
for rawL in ins: |
||||
|
line = rawL.strip() |
||||
|
if len(line) < 1: |
||||
|
continue |
||||
|
install_requires.append(line) |
||||
|
|
||||
|
description = '''Manage Minetest using Python.''' |
||||
|
long_description = description |
||||
|
if os.path.isfile("readme.md"): |
||||
|
with open("readme.md", "r") as fh: |
||||
|
long_description = fh.read() |
||||
|
|
||||
|
setuptools.setup( |
||||
|
name='pyenliven', |
||||
|
version='0.3.0', |
||||
|
description=description, |
||||
|
long_description=long_description, |
||||
|
long_description_content_type="text/markdown", |
||||
|
classifiers=[ |
||||
|
'Development Status :: 3 - Alpha', |
||||
|
'Programming Language :: Python :: 3', |
||||
|
('License :: OSI Approved ::' |
||||
|
' GNU General Public License v2 or later (GPLv2+)'), |
||||
|
'Operating System :: POSIX :: Linux', |
||||
|
'Topic :: Software Development :: Version Control', |
||||
|
], |
||||
|
keywords=('minetest repo management commit data analyzer' |
||||
|
' meld merge compare files diff'), |
||||
|
url="https://github.com/poikilos/EnlivenMinetest", |
||||
|
author="Jake Gustafson", |
||||
|
author_email='7557867+poikilos@users.noreply.github.com', |
||||
|
license='GPLv2.1', |
||||
|
# packages=setuptools.find_packages(), |
||||
|
packages=['pyenliven'], |
||||
|
# include_package_data=True, # look for MANIFEST.in |
||||
|
# scripts=['example'] , |
||||
|
# See <https://stackoverflow.com/questions/27784271/ |
||||
|
# how-can-i-use-setuptools-to-generate-a-console-scripts-entry- |
||||
|
# point-which-calls> |
||||
|
entry_points={ |
||||
|
'console_scripts': [ |
||||
|
'compatiblizemod=pyenliven.compatiblizemod:main', |
||||
|
], |
||||
|
}, |
||||
|
install_requires=install_requires, |
||||
|
# versionedModule['urllib'], |
||||
|
# ^ "ERROR: Could not find a version that satisfies the requirement |
||||
|
# urllib (from nopackage) (from versions: none) |
||||
|
# ERROR: No matching distribution found for urllib" |
||||
|
test_suite='nose.collector', |
||||
|
tests_require=['nose', 'nose-cover3'], |
||||
|
zip_safe=False, # It can't run zipped due to needing data files. |
||||
|
) |
Loading…
Reference in new issue