Skip to content

Commit

Permalink
Python: simplify build process via setuptools
Browse files Browse the repository at this point in the history
Since the 'INSTALL_PREFIX' used within the Python Bindings is now
generated by configure in the file '_versions.py', there is no need
to rewrite the file 'static.py' anymore.
This commit removes now the unnecessary code.

Refs #731
  • Loading branch information
rcrdnalor committed May 15, 2023
1 parent 7913ac1 commit 2e628f8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 47 deletions.
3 changes: 1 addition & 2 deletions mythtv/bindings/python/Makefile
Expand Up @@ -6,7 +6,6 @@ else
ROOT_FLAGS = --root="/"
endif

REAL_PREFIX = $(PREFIX)
ifneq ($(PREFIX:/=), /usr)
ifneq ($(PREFIX:/=), /usr/local)
PREFIX_FLAGS=--prefix="$(PREFIX)"
Expand All @@ -21,7 +20,7 @@ clean:
distclean: clean

python_build: setup.py
$(PYTHON) setup.py build --mythtv-prefix="$(REAL_PREFIX)"
$(PYTHON) setup.py build

install: setup.py
$(PYTHON) setup.py install --skip-build $(ROOT_FLAGS) $(PREFIX_FLAGS)
Expand Down
45 changes: 0 additions & 45 deletions mythtv/bindings/python/setup.py
Expand Up @@ -3,50 +3,5 @@
import sys, os
import setuptools

run_post_build_action = False
index = 0
mythtv_prefix = None

# handle extra build option for 'mythtv-prefix'
if sys.argv[1] == 'build':
for index,arg in enumerate(sys.argv):
if arg.startswith("--mythtv-prefix="):
run_post_build_action = True
try:
mythtv_prefix = arg.split("=")[1].strip()
except IndexError:
pass
break

# 'mythtv-prefix' argument is not meant for setup()
if run_post_build_action:
del sys.argv[index]

# run setup() from setuptools with expected arguments
setuptools.setup()

# adapt the path to the grabber scripts according installation
if run_post_build_action:
# check for alternate prefix
if mythtv_prefix is None or mythtv_prefix == '':
sys.exit(0)

# find file
for path,dirs,files in os.walk('build'):
if 'static.py' in files:
break
else:
sys.exit(0)

# read in and replace existing line
buff = []
path = os.path.join(path,'static.py')
with open(path) as fi:
for line in fi:
if 'INSTALL_PREFIX' in line:
line = "INSTALL_PREFIX = '%s'\n" % mythtv_prefix
buff.append(line)

# push back to file
with open(path,'w') as fo:
fo.write(''.join(buff))

0 comments on commit 2e628f8

Please sign in to comment.