#1019 Use python2/3 instead of python in Makefile/spec
Merged 3 years ago by mikem. Opened 3 years ago by tkopecek.
tkopecek/koji issue1018  into  master

file modified
+4
@@ -2,6 +2,10 @@ 

  SPECFILE = $(firstword $(wildcard *.spec))

  SUBDIRS = hub builder koji cli util www plugins vm

  

+ ifndef PYTHON

+ export PYTHON=python2

+ endif

+ 

  ifdef DIST

  DIST_DEFINES := --define "dist $(DIST)"

  endif

file modified
-1
@@ -1,6 +1,5 @@ 

  SUBDIRS=koji_cli

  

- PYTHON=python

  PACKAGE = $(shell basename `pwd`)

  PYVER := $(shell $(PYTHON) -c 'import sys; print("%.3s" %(sys.version))')

  PYSYSDIR := $(shell $(PYTHON) -c 'import sys; print(sys.prefix)')

file modified
-1
@@ -1,6 +1,5 @@ 

  PYFILES = $(wildcard *.py)

  

- PYTHON=python

  PACKAGE = $(shell basename `pwd`)

  PYVER := $(shell $(PYTHON) -c 'import sys; print("%.3s" % (sys.version))')

  PYSYSDIR := $(shell $(PYTHON) -c 'import sys; print(sys.prefix)')

file modified
-1
@@ -1,4 +1,3 @@ 

- PYTHON=python

  PACKAGE = $(shell basename `pwd`)

  PYFILES = $(wildcard *.py)

  PYVER := $(shell $(PYTHON) -c 'import sys; print("%.3s" %(sys.version))')

file modified
+4 -4
@@ -268,14 +268,14 @@ 

  

  %install

  rm -rf $RPM_BUILD_ROOT

- make DESTDIR=$RPM_BUILD_ROOT %{?install_opt} install

+ make DESTDIR=$RPM_BUILD_ROOT PYTHON=%{__python2} %{?install_opt} install

  %if 0%{with python3}

  cd koji

- make DESTDIR=$RPM_BUILD_ROOT PYTHON=python3 %{?install_opt} install

+ make DESTDIR=$RPM_BUILD_ROOT PYTHON=%{__python3} %{?install_opt} install

  cd ../cli

- make DESTDIR=$RPM_BUILD_ROOT PYTHON=python3 %{?install_opt} install

+ make DESTDIR=$RPM_BUILD_ROOT PYTHON=%{__python3} %{?install_opt} install

  cd ../plugins

- make DESTDIR=$RPM_BUILD_ROOT PYTHON=python3 %{?install_opt} install

+ make DESTDIR=$RPM_BUILD_ROOT PYTHON=%{__python3} %{?install_opt} install

  # alter python interpreter in koji CLI

  sed -i 's/\#\!\/usr\/bin\/python2/\#\!\/usr\/bin\/python3/' $RPM_BUILD_ROOT/usr/bin/koji

  %endif

file modified
-1
@@ -1,4 +1,3 @@ 

- PYTHON=python

  PACKAGE = $(shell basename `pwd`)

  ifeq ($(PYTHON), python3)

      # for python3 we fully support only basic library + CLI

file modified
+2 -2
@@ -1,4 +1,4 @@ 

- PYTHON=python

+ PYMAJORVER := $(shell $(PYTHON) -c 'import sys; print(sys.version_info[0])')

  PYVER := $(shell $(PYTHON) -c 'import sys; print("%.3s" %(sys.version))')

  PYSYSDIR := $(shell $(PYTHON) -c 'import sys; print(sys.prefix)')

  PYLIBDIR = $(PYSYSDIR)/lib/python$(PYVER)
@@ -29,7 +29,7 @@ 

  		echo "ERROR: A destdir is required"; \

  		exit 1; \

  	fi

- 	if [ "$(PYTHON)" == "python" ] ; then \

+ 	if [ "$(PYMAJORVER)" == "2" ] ; then \

  		mkdir -p $(DESTDIR)/$(HUBPLUGINDIR); \

  		mkdir -p $(DESTDIR)/$(BUILDERPLUGINDIR); \

  		install -p -m 644 $(HUBFILES) $(DESTDIR)/$(HUBPLUGINDIR); \

@@ -1,4 +1,3 @@ 

- PYTHON=python

  PACKAGE = $(shell basename `pwd`)

  PYFILES = $(wildcard *.py)

  PYVER := $(shell $(PYTHON) -c 'import sys; print("%.3s" % (sys.version))')

related PR#990: https://pagure.io/koji/pull-request/990
We'll need some tweaks for building koji on RHEL8

1 new commit added

  • use macro to support RHEL8 build
3 years ago

2 new commits added

  • use macro to support RHEL8 build
  • Use python2/3 instead of python in Makefile/spec
3 years ago

Combined with PR #990 to one.

Some make commands are pretty noisy with this change. I think we need to make sure we provide a default value for PYTHON everywhere.

[mike@localhost koji]$ make clean
rm -f *.o *.so *.pyc *~ koji*.bz2 koji*.src.rpm
rm -rf koji-1.16.0
for d in hub builder koji cli util www plugins vm; do make -s -C $d clean; done
make[1]: -c: Command not found
make[1]: -c: Command not found
make[1]: -c: Command not found
make[1]: -c: Command not found
make[1]: -c: Command not found
make[1]: -c: Command not found
make[3]: -c: Command not found
make[3]: -c: Command not found
make[1]: -c: Command not found
make[1]: -c: Command not found
make[1]: -c: Command not found
coverage erase ||:

I think maybe we just need to export the PYTHON variable in the main Makefile. E.g.

https://github.com/mikem23/koji-playground/commits/pagure/pr/1019

1 new commit added

  • set default python
3 years ago

Your solution doesn't allow to override PYTHON via standard environment variables e.g. ('PYTHON=python3 make clean', while 'make PYTHON-python3 clean' works). Python2 will be still used. I've added commit with conditional define which should solve it.

I'm still seeing junk output when running commands like make clean and make tarball. I should not have to explicitly set PYTHON=python2 to run these commands.

maybe your approach, but also export the var?

rebased onto e6e214f

3 years ago

yeah, it seems to fixed it

What about this one? Using unversioned 'python' prevents koji from building in actual Fedora.
(https://copr-be.cloud.fedoraproject.org/results/tkopecek/koji/fedora-29-x86_64/00829698-koji/)

Commit e10daec fixes this pull-request

Pull-Request has been merged by mikem

3 years ago