Ask Your Question
1

nothing provides /bin/python3

asked 2015-10-25 15:04:44 -0500

Martin Ueding gravatar image

updated 2015-11-03 18:59:50 -0500

mether gravatar image

I want to create an RPM package from a Python 3 and setuptools project. I have used %py3_install and a manual invocation of python3 install ... in the %install section of the .spec file. The shebang always ends up with #!/bin/python3 in the scripts.

When I try to install that package with dnf, I get nothing provides /bin/python3.

How could I package this such that the shebangs get rewritten properly to /usr/bin/python3? If possible, I'd like to keep the upstream package unchanged.

This is on Fedora 22.

This is the full .spec file.

# Copyright © 2015 Martin Ueding <dev@martin-ueding.de>

# spec file for package thinkpad-scripts
#
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

Name:           thinkpad-scripts
Version:        4.4.0
Release:        1
License:        GPL-2.0+
Summary:        Rotate scripts for Lenovo ThinkPad
Url:            http://martin-ueding.de/en/projects/%{name}
Source0:        http://bulk.martin-ueding.de/source/%{name}/%{name}_%{version}.tar.gz
#Group:
#Patch:
BuildRequires:  gettext python3-setuptools python3-devel

%if 0%{?suse_version}
BuildRequires:  oxygen-icon-theme
BuildRequires:  python3-Sphinx
BuildRequires:  systemd
BuildRequires:  udev
BuildRequires:  update-desktop-files
%else
BuildRequires:  python3-sphinx
%endif

BuildArch:      noarch
Requires:       acpid alsa-utils python3-setuptools udev xinput 

%if 0%{?suse_version}
Requires:       systemd
Requires:       xrandr
%else
Requires:       xorg-x11-server-utils
%endif

#PreReq:
#Provides:       think-rotate think-dock
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description

This collection of scripts is intended for the Lenovo ThinkPad X220 Tablet. You
can still use them with the regular X220 machine, but only ``thinkpad-rotate``
will probably be useless for you then. I think that most scripts will also be
handy for other ThinkPad models, I have not tested them though.

In short, this script fixes or improves the following:

1. Rotation of the internal screen and any Wacom touch and pen input devices
   using the bezel buttons or physical screen rotation

2. Get the microphone mute button to work.

3. Automatically use any external monitor, speakers and LAN connection when
   docking onto an UltraBase or similar.

4. Ability to disable touch pad or touch screen

%prep
%setup -q

%if 0%{?suse_version}
%define sphinx_build sphinx-build
%else
%define sphinx_build sphinx-build-3
%endif

%build
make %{?_smp_mflags} SPHINXBUILD=%{sphinx_build}

%install
%make_install
python3 setup.py install --prefix=%{_prefix} --root=%{buildroot}

%if 0%{?suse_version}
%suse_update_desktop_file -r thinkpad-dock-off System HardwareSettings
%suse_update_desktop_file -r thinkpad-dock-on System HardwareSettings
%suse_update_desktop_file -r thinkpad-rotate System Monitor
%suse_update_desktop_file -r thinkpad-rotate-flip System Monitor
%suse_update_desktop_file -r thinkpad-rotate-left System Monitor
%suse_update_desktop_file -r thinkpad-touch System HardwareSettings
%suse_update_desktop_file -r thinkpad-touchpad System HardwareSettings
%suse_update_desktop_file -r thinkpad-touchpad System HardwareSettings
%endif

%post
systemctl restart acpid.service || true ...
(more)
edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
2

answered 2015-10-26 09:37:28 -0500

Martin Ueding gravatar image

The problem is the python3 setup.py .... The normal PATH is set such that /bin is before /usr/bin and therefore python3 will be resolved to /bin/python3. That path works since it is a symlink to /usr/bin where python3 actually is.

Python Setuptools then adds shebangs with /bin/python3 to the files. Then dnf complains because there is no package that provides /bin/python3, which is correct.

The solution is to call /usr/bin/python3 setup.py ... in order to let it resolve to the desired path.

edit flag offensive delete link more

Comments

Good to know! I recently came across this documentation which explains your findings.

skytux gravatar imageskytux ( 2015-10-26 15:21:56 -0500 )edit
0

answered 2015-10-25 17:44:29 -0500

davidva gravatar image

updated 2015-10-25 18:25:12 -0500

Is your first rpm with python? Simple a patch... or search "#!/bin/python3" in all files, and changes.... to #!/usr/bin/python3 ; why not share the spec?

Patch:

diff -u old_file new_file > changes.patch

other way example using sed...(in %install) also you can combine with "find"

sed -i "s|#!/bin/python3|#!/usr/bin/python3|" files...

If the package needs python3, remember add:

%BuildRequires: python3-devel python3-setuptools

Read also...

edit flag offensive delete link more

Comments

The inference you need to make from this answer is that there is not a part of the rpm process that magically changes shebangs - or any source file content. Bad shebangs in means bad shebangs out. Also note that things that end up in site-packages/ aren't supposed to be directly executable, and so do not need shebangs.

randomuser gravatar imagerandomuser ( 2015-10-25 17:56:08 -0500 )edit

But /usr/bin/python is python2.7 and he needs python3 (3.4 in F22).

skytux gravatar imageskytux ( 2015-10-25 17:57:08 -0500 )edit

@skytux is an example, he can change also espefic version of python. Maybe @Martin Ueding has added to Requires: /bin/python3, or forget the %build process. If he need help why not share the spec?

davidva gravatar imagedavidva ( 2015-10-25 18:13:26 -0500 )edit

I added the full SPEC file, sorry for not doing that in the first place. The problem is that setuptools creates some new scripts and uses the interpreter that setup.py is called with, they say. So there is nothing in the source I can directly change, it is something that setuptools does strangely.

Martin Ueding gravatar imageMartin Ueding ( 2015-10-26 02:51:56 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2015-10-25 15:04:44 -0500

Seen: 828 times

Last updated: Oct 26 '15