#2148 Simplify obtaining of PKGDIR
Merged 3 years ago by tkopecek. Opened 3 years ago by mprivozn.
mprivozn/koji python_fixes  into  master

file modified
+1 -4
@@ -1,10 +1,7 @@ 

  SUBDIRS=koji_cli

  

  PACKAGE = $(shell basename `pwd`)

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

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

- PYLIBDIR = $(PYSYSDIR)/lib/python$(PYVER)

- PKGDIR = $(PYLIBDIR)/site-packages

+ PKGDIR = $(shell $(PYTHON) -c "import site; print(site.getsitepackages()[0])")/$(PACKAGE)

  

  FILES = koji

  

file modified
+1 -4
@@ -1,10 +1,7 @@ 

  PYFILES = $(wildcard *.py)

  

  PACKAGE = $(shell basename `pwd`)

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

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

- PYLIBDIR = $(PYSYSDIR)/lib/python$(PYVER)

- PKGDIR = $(PYLIBDIR)/site-packages/$(PACKAGE)

+ PKGDIR = $(shell $(PYTHON) -c "import site; print(site.getsitepackages()[0])")/$(PACKAGE)

  

  _default:

  	@echo "nothing to make.  try make install"

file modified
+1 -4
@@ -1,9 +1,6 @@ 

  PACKAGE = $(shell basename `pwd`)

  PYFILES = $(wildcard *.py)

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

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

- PYLIBDIR = $(PYSYSDIR)/lib/python$(PYVER)

- PKGDIR = $(PYLIBDIR)/site-packages/$(PACKAGE)

+ PKGDIR = $(shell $(PYTHON) -c "import site; print(site.getsitepackages()[0])")/$(PACKAGE)

  

  SERVERDIR = /usr/share/koji-hub

  PYFILES = $(wildcard *.py)

file modified
+7 -7
@@ -58,7 +58,7 @@ 

  # not yet to RHEL proper.

  # https://bugzilla.redhat.com/show_bug.cgi?id=1307190

  %{!?__python2: %global __python2 /usr/bin/python2}

- %{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}

+ %{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}

  %{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}

  %{!?py2_build: %global py2_build %{expand: CFLAGS="%{optflags}" %{__python2} setup.py %{?py_setup_args} build --executable="%{__python2} -s"}}

  %{!?py2_install: %global py2_install %{expand: CFLAGS="%{optflags}" %{__python2} setup.py %{?py_setup_args} install -O1 --skip-build --root %{buildroot}}}
@@ -472,19 +472,19 @@ 

  

  %if 0%{py2_support}

  %files -n python2-%{name}

- %{python2_sitelib}/%{name}

- %{python2_sitelib}/koji_cli

+ %{python2_sitearch}/%{name}

+ %{python2_sitearch}/koji_cli

  %endif

  

  %if 0%{py3_support}

  %files -n python%{python3_pkgversion}-koji

- %{python3_sitelib}/%{name}

- %{python3_sitelib}/koji_cli

+ %{python3_sitearch}/%{name}

+ %{python3_sitearch}/koji_cli

  %endif

  

  %if 0%{py2_support}

  %files -n python2-%{name}-cli-plugins

- %{python2_sitelib}/koji_cli_plugins

+ %{python2_sitearch}/koji_cli_plugins

  # we don't have config files for default plugins yet

  #%%dir %%{_sysconfdir}/koji/plugins

  #%%config(noreplace) %%{_sysconfdir}/koji/plugins/*.conf
@@ -492,7 +492,7 @@ 

  

  %if 0%{py3_support}

  %files -n python%{python3_pkgversion}-%{name}-cli-plugins

- %{python3_sitelib}/koji_cli_plugins

+ %{python3_sitearch}/koji_cli_plugins

  # we don't have config files for default plugins yet

  #%%dir %%{_sysconfdir}/koji/plugins

  #%%config(noreplace) %%{_sysconfdir}/koji/plugins/*.conf

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

  PYFILES = $(wildcard *.py)

  PYSCRIPTS =

  SUBDIRS =

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

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

- PYLIBDIR = $(PYSYSDIR)/lib/python$(PYVER)

- PKGDIR = $(PYLIBDIR)/site-packages/$(PACKAGE)

+ PKGDIR = $(shell $(PYTHON) -c "import site; print(site.getsitepackages()[0])")/$(PACKAGE)

  

  _default:

  	@echo "nothing to make.  try make install"

file modified
+1 -5
@@ -1,8 +1,4 @@ 

- 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)

- PKGDIR = $(PYLIBDIR)/site-packages

+ PKGDIR = $(shell $(PYTHON) -c "import site; print(site.getsitepackages()[0])")/$(PACKAGE)

  

  CLIPLUGINDIR = $(PKGDIR)/koji_cli_plugins

  HUBPLUGINDIR = /usr/lib/koji-hub-plugins

file modified
+1 -4
@@ -1,9 +1,6 @@ 

  PACKAGE = $(shell basename `pwd`)

  PYFILES = $(wildcard *.py)

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

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

- PYLIBDIR = $(PYSYSDIR)/lib/python$(PYVER)

- PKGDIR = $(PYLIBDIR)/site-packages/$(PACKAGE)

+ PKGDIR = $(shell $(PYTHON) -c "import site; print(site.getsitepackages()[0])")/$(PACKAGE)

  

  SERVERDIR = /kojiweb

  FILES = $(wildcard *.py *.chtml)

So far, in all Makefiles we have a complicated way to construct
PKGDIR path which is used to install python modules into.
Firstly, python version is obtained, and then system prefix and
these are then used to construct the PKGDIR path. Well, we can do
better. We can use 'site.getsitepackages()[0]' to obtain exactly
the path we are after.

This also fixes the problem on distributions which have split
/usr/lib and /usr/lib64 directories, because with the way we are
constructing the PKGDIR path we assume that the directories are
the same (or one is a symlink to another). Well, that is not
always the case.

Signed-off-by: Michal Privoznik mprivozn@redhat.com

Is there a way to make this py 2.6 compatible? site.getsitepackages is there only from py2.7.

Do we care about python 2.6? Isn't it replaced with 2.7 like everywhere and 2.7 is going away anyway?

Yes, unfortunately we're not leaving py 2.6 yet. In next release (1.22) we're dropping py2 support for everything but builders. I would like to create maintenance branch for RHEL6 in +-1.23 (but we will still need to release patches there).

/We can postpone this one for that release/

I'm surprised to learn that on RHEL6 somebody would use such new package, but fair enough. Let's postpone this one then.

pretty please pagure-ci rebuild

3 years ago

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

3 years ago

rebased onto 674fff0

3 years ago

Commit b75d3cc fixes this pull-request

Pull-Request has been merged by tkopecek

3 years ago

Metadata Update from @jcupova:
- Pull-request tagged with: testing-done

3 years ago