Browse Source

setup.py: Add option to build with updates disabled

doc-issue-template
MrS0m30n3 6 years ago
parent
commit
f1b84455fa
1 changed files with 37 additions and 0 deletions
  1. 37
      setup.py

37
setup.py

@ -24,6 +24,10 @@ Examples:
python setup.py build_trans
Build with updates disabled::
python setup.py build --no-updates
Requirements:
* GNU gettext utilities
@ -144,9 +148,42 @@ class Build(build):
("build_trans", None)
] + build.sub_commands
build.user_options.append(("no-updates", None, "build with updates disabled"))
def initialize_options(self):
build.initialize_options(self)
self.no_updates = None
def run(self):
build.run(self)
if self.no_updates:
self.__disable_updates()
def __disable_updates(self):
lib_dir = os.path.join(self.build_lib, __packagename__)
target_file = "optionsmanager.py"
# Options file should be available from previous build commands
optionsfile = os.path.join(lib_dir, target_file)
data = None
with open(optionsfile, "r") as input_file:
data = input_file.readlines()
if data is None:
print("building with updates disabled failed!")
sys.exit(1)
for index, line in enumerate(data):
if "'disable_update': False" in line:
print("disabling updates")
data[index] = line.replace("False", "True")
break
with open(optionsfile, "w") as output_file:
output_file.writelines(data)
# Overwrite cmds
cmdclass = {

Loading…
Cancel
Save