poikilos
2 years ago
27 changed files with 1532 additions and 1169 deletions
@ -1,141 +1,150 @@ |
|||
#!/usr/bin/env python |
|||
import os |
|||
import sys |
|||
import shutil |
|||
from forwardfilesync import * |
|||
# import filever |
|||
try: |
|||
input = raw_input |
|||
except NameError: |
|||
from pyenliven import ( |
|||
echo0, |
|||
) |
|||
if sys.version_info.major >= 3: |
|||
pass |
|||
else: |
|||
input = raw_input |
|||
|
|||
warnings = list() |
|||
|
|||
print("") |
|||
print("This script is NOT YET IMPLEMENTED") |
|||
def rm_sub(bad_sub): |
|||
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.") |
|||
|
|||
script_dir_path = os.path.dirname(os.path.abspath(__file__)) |
|||
enliven_project_path = os.path.dirname(script_dir_path) |
|||
script_dir_path = os.path.dirname(os.path.abspath(__file__)) |
|||
enliven_project_path = os.path.dirname(script_dir_path) |
|||
|
|||
profile_path = None |
|||
if "HOME" in os.environ: |
|||
profile_path = None |
|||
if "HOME" in os.environ: |
|||
profile_path = os.environ["HOME"] |
|||
elif "USERPROFILE" in os.environ: |
|||
elif "USERPROFILE" in os.environ: |
|||
profile_path = os.environ["USERPROFILE"] |
|||
else: |
|||
else: |
|||
try_path = "C:\\Users\\jgustafson" |
|||
if not os.path.isdir(try_path): |
|||
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 + "'") |
|||
profile_path = try_path |
|||
# TODO: Make a settings file for values in the next region. |
|||
# region user settings |
|||
deploy_path = "C:\\Games\\ENLIVEN-deploy" |
|||
try_path = "C:\\Games\\Minetest" |
|||
if (not os.path.isdir(deploy_path)) and os.path.isdir(try_path): |
|||
# TODO: Make a settings file for values in the next region. |
|||
# region user settings |
|||
deploy_path = "C:\\Games\\ENLIVEN-deploy" |
|||
try_path = "C:\\Games\\Minetest" |
|||
if (not os.path.isdir(deploy_path)) and os.path.isdir(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"]) |
|||
installer_name = "install-ENLIVEN.exe" |
|||
# endregion user settings |
|||
installer_name = "install-ENLIVEN.exe" |
|||
# 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): |
|||
print("#WARNING: does not exist:") |
|||
print("installer_deploy_path: " + installer_deploy_path) |
|||
if not os.path.isdir(installer_deploy_path): |
|||
echo0("#WARNING: does not exist:") |
|||
print("installer_deploy_path: " + installer_deploy_path) |
|||
|
|||
# this is a waste--it just shows 0.0.0.0 though iss file has version |
|||
# if os.path.isfile(installer_path): |
|||
# numbers=filever.get_version_number(installer_path) |
|||
# major,minor,subminor,revision = numbers |
|||
# print(".".join([str (i) for i in numbers])) |
|||
# this is a waste--it just shows 0.0.0.0 though iss file has version |
|||
# if os.path.isfile(installer_path): |
|||
# numbers=filever.get_version_number(installer_path) |
|||
# major,minor,subminor,revision = 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) |
|||
games_path = os.path.join(deploy_path, "games") |
|||
minetest_game_path = os.path.join(games_path, "minetest_game") |
|||
minetest_game_mods_path = os.path.join(minetest_game_path, "mods") |
|||
if not os.path.isdir(minetest_game_path): |
|||
print("This deploy script requires an unmodified build of minetest and\n" + |
|||
games_path = os.path.join(deploy_path, "games") |
|||
minetest_game_path = os.path.join(games_path, "minetest_game") |
|||
minetest_game_mods_path = os.path.join(minetest_game_path, "mods") |
|||
if not os.path.isdir(minetest_game_path): |
|||
echo0("This deploy script requires an unmodified build of minetest and\n" + |
|||
" minetest_game. Please place an unmodified build of minetest in\n" + |
|||
" " + deploy_path + " so that minetest_game is at: \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 |
|||
# automatically |
|||
if not os.path.isdir(game_path): |
|||
print("") |
|||
print("ERROR: ENLIVEN must first be installed from web sources" + |
|||
# NOTE: remove this case, and instead: copy minetest_game, download ENLIVEN |
|||
# automatically |
|||
if not os.path.isdir(game_path): |
|||
echo0("") |
|||
echo0("ERROR: ENLIVEN must first be installed from web sources" + |
|||
" using the provided 'install' script in the etc/change*" + |
|||
" folder (run on linux then copy to a Windows machine" + |
|||
" in " + game_path) |
|||
# exit(2) |
|||
else: |
|||
# return 2 |
|||
else: |
|||
print("game_path: " + game_path) |
|||
mods_path = os.path.join(game_path, "mods") |
|||
if not os.path.isdir(mods_path): |
|||
mods_path = os.path.join(game_path, "mods") |
|||
if not os.path.isdir(mods_path): |
|||
os.makedirs(mods_path) |
|||
mtg_list_path = os.path.join(game_path, "minetest_game-mod-list.txt") |
|||
mtg_list_out = open(mtg_list_path, 'w') |
|||
folder_path = minetest_game_mods_path |
|||
if os.path.isdir(folder_path): |
|||
mtg_list_path = os.path.join(game_path, "minetest_game-mod-list.txt") |
|||
mtg_list_out = open(mtg_list_path, 'w') |
|||
folder_path = minetest_game_mods_path |
|||
if os.path.isdir(folder_path): |
|||
for sub_name in os.listdir(folder_path): |
|||
sub_path = os.path.join(folder_path, sub_name) |
|||
if sub_name[:1] != "." and os.path.isdir(sub_path): |
|||
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, |
|||
"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") |
|||
else: |
|||
else: |
|||
shutil.copyfile(server_devel_minetest_conf_path, |
|||
server_minetest_conf_path) |
|||
|
|||
|
|||
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)" |
|||
rm_sub(["CC-BY-SA 3.0 Unported (fallback license for ENLIVEN assets)" |
|||
".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 |
|||
# minetest_game's and the following are intentionally looking in |
|||
# C:\games\ENLIVEN\games\ENLIVEN: |
|||
# rm_sub(["games", "ENLIVEN", "LICENSE.txt"]) |
|||
# rm_sub(["games", "ENLIVEN", "README.txt"]) |
|||
# NOTE: At this point, the following LICENSE and README files are |
|||
# minetest_game's and the following are intentionally looking in |
|||
# C:\games\ENLIVEN\games\ENLIVEN: |
|||
# rm_sub(["games", "ENLIVEN", "LICENSE.txt"]) |
|||
# rm_sub(["games", "ENLIVEN", "README.txt"]) |
|||
|
|||
print("") |
|||
if len(warnings) > 0: |
|||
print(str(len(warnings)) + " warning(s):") |
|||
echo0("") |
|||
if len(warnings) > 0: |
|||
echo0(str(len(warnings)) + " warning(s):") |
|||
for warning in warnings: |
|||
print(warning) |
|||
else: |
|||
print("0 warnings.") |
|||
print("\n") |
|||
input("press enter to exit...") |
|||
echo0(warning) |
|||
else: |
|||
echo0("0 warnings.") |
|||
echo0() |
|||
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