evennia/setup.py

51 lines
1.4 KiB
Python
Raw Normal View History

2022-11-18 22:07:43 +01:00
"""
Do custom actions during build/install step.
"""
import os
import sys
2022-11-10 22:21:12 +01:00
2022-11-18 22:07:43 +01:00
from setuptools import setup
OS_WINDOWS = os.name == "nt"
2015-09-07 10:32:05 -07:00
2022-11-18 22:07:43 +01:00
def get_evennia_executable():
"""
2022-11-18 22:07:43 +01:00
Called from build process.
Determine which executable scripts should be added. For Windows,
this means creating a .bat file.
2022-11-18 22:07:43 +01:00
"""
if OS_WINDOWS:
batpath = os.path.join("bin", "windows", "evennia.bat")
scriptpath = os.path.join(sys.prefix, "Scripts", "evennia_launcher.py")
with open(batpath, "w") as batfile:
2019-12-16 20:31:42 +01:00
batfile.write('@"%s" "%s" %%*' % (sys.executable, scriptpath))
return [batpath, os.path.join("bin", "windows", "evennia_launcher.py")]
else:
return [os.path.join("bin", "unix", "evennia")]
2022-11-18 22:07:43 +01:00
def get_all_files():
"""
2022-11-18 22:07:43 +01:00
By default, the distribution tools ignore all non-python files, such as VERSION.txt.
Make sure we get everything.
"""
file_set = []
2019-12-16 20:31:42 +01:00
for root, dirs, files in os.walk("evennia"):
for f in files:
2019-12-16 20:31:42 +01:00
if ".git" in f.split(os.path.normpath(os.path.join(root, f))):
2015-02-02 21:57:06 +01:00
# Prevent the repo from being added.
continue
2019-12-16 20:31:42 +01:00
file_name = os.path.relpath(os.path.join(root, f), "evennia")
file_set.append(file_name)
return file_set
2022-11-18 22:07:43 +01:00
# legacy entrypoint
setup(scripts=get_evennia_executable(), package_data={"": get_all_files()})