You are not logged in.

#1 2011-02-18 16:39:46

MW
Member
Registered: 2007-07-27
Posts: 127

python2 compatability

I'm in the middle of creating a package and would like some info on how to do things the right way.

The package was written in Python2 and thus if you try and run it, it will die.

I have worked around this by renaming python (run python file) to python2 (run python file) in the executable.

This can be easily done with sed in the final PKGBUILD file, but is this the correct way to do this?

Offline

#2 2011-02-18 18:32:11

Anikom15
Banned
From: United States
Registered: 2009-04-30
Posts: 836
Website

Re: python2 compatability

No you're gonna break everything that expects python to be python3. Perhaps post your PKGBUILD but most pure Python packages are installed with

python setup.py install

you'd use python2 in place of python.

Last edited by Anikom15 (2011-02-18 18:32:29)


Personally, I'd rather be back in Hobbiton.

Offline

#3 2011-02-18 18:41:22

MW
Member
Registered: 2007-07-27
Posts: 127

Re: python2 compatability

Okay, give me till tomorrow and I'll post the PKGBUILD as it is, still need to do a few things here and there.

In the mean time, this is what I was talking about:

# Make it python2 compatible on a python3 system
sed -i 's/python/python2/g' /usr/bin/bibleanalyzer
sed -i 's/python/python2/g' /usr/share/applications/bibleanalyzer.desktop

This changes things from this:

#!/bin/bash
clear
echo "************ Starting Bible Analyzer *************"
python /usr/share/bibleanalyzer/analyzer4.py
echo
read -p "Press Enter to close terminal"

to this

#!/bin/bash
clear
echo "************ Starting Bible Analyzer *************"
python2 /usr/share/bibleanalyzer/analyzer4.py
echo
read -p "Press Enter to close terminal"

Last edited by MW (2011-02-18 18:45:01)

Offline

#4 2011-02-19 05:58:06

MW
Member
Registered: 2007-07-27
Posts: 127

Re: python2 compatability

Here is the PKGBUILD

This is the first time I have done something like this, so if there are a few improvements to be made, please share it.

# Contributor: Timothy Morton <xxxxx@bibleanalyzer.com>
# Maintainer: MyWorld <xxxxx@gmail.com>
pkgname=bibleanalyzer
pkgver=4.1_0
pkgrel=1
pkgdesc="A cross platform Bible study software program."
url="http://www.bibleanalyzer.com"
license="Custom"
arch=('i686' 'x86_64')
depends=('wxpython' 'python-espeak' 'python-configobj')
makedepends=('deb2targz')
source=(http://www.bibleanalyzer.com/${pkgname}_${pkgver//_/-}_i386.deb)
md5sums=('4d3ffb131220cd2db1cf514b9384515b')

build() {
    # Convert the file
    deb2targz ${srcdir}/${pkgname}_${pkgver//_/-}_i386.deb || exit 1
    # Extract the file
    tar xvzf ${srcdir}/${pkgname}_${pkgver//_/-}_i386.tar.gz -C / || exit 1
    # Make it python2 compatible on a python3 system
    sed -i 's/python/python2/g' /usr/bin/bibleanalyzer
    sed -i 's/python/python2/g' /usr/share/applications/bibleanalyzer.desktop
    # Create the directories required
    (
            echo -n "Creating directories as required: "
            entries=`wc -l /etc/passwd | awk '{print $1}'`
            declare -a luser[$entries]

                for i in `seq 1 $entries`; do
                username[$i]=`cat /etc/passwd | sed -n "${i}p" | awk -F: '{print $1}'`
                groupid[$i]=`cat /etc/passwd | sed -n "${i}p" | awk -F: '{print $4}'`
                    if [ "${groupid[$i]}" == "100" ]; then
                            if [ -d /home/${username[$i]} ]; then
                        echo "${username[$i]} "
                            if [ ! -d /home/${username[$i]}/Documents/BibleAnalyzer ]; then
                                mkdir -p /home/${username[$i]}/Documents/BibleAnalyzer
                            fi
                    chown -R ${username[$i]}:users /home/${username[$i]}/Documents/BibleAnalyzer
                        fi
                fi
                done
            echo
    )
      }

Last edited by MW (2011-02-19 13:14:20)

Offline

#5 2011-02-19 17:13:03

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: python2 compatability

Modifying a users home directory is very bad practice.

Offline

#6 2011-02-19 18:08:30

MW
Member
Registered: 2007-07-27
Posts: 127

Re: python2 compatability

skottish wrote:

Modifying a users home directory is very bad practice.

Thank you for the reply!

The obvious thing then to do is to echo the necessary steps after the install finished?

I cannot find anything on this in the documentation, is a coloured echo allowed in a PKGBUILD?

# Contributor: Timothy Morton <morton@bibleanalyzer.com>
# Maintainer: MyWorld <mywereld@gmail.com>

pkgname=bibleanalyzer
pkgver=4.1_0
pkgrel=1
pkgdesc="A cross platform Bible study software program."
url="http://www.bibleanalyzer.com"
license="Custom"
arch=('i686' 'x86_64')
depends=('wxpython' 'python-espeak' 'python-configobj')
makedepends=('deb2targz')
source=(http://www.bibleanalyzer.com/${pkgname}_${pkgver//_/-}_i386.deb)
md5sums=('4d3ffb131220cd2db1cf514b9384515b')

build() {
        cd ${srcdir}
        # Convert the file
        deb2targz ${pkgname}_${pkgver//_/-}_i386.deb || exit 1
        # Extract the file
        tar xvzf ${pkgname}_${pkgver//_/-}_i386.tar.gz -C / || exit 1
        # Make it python2 compatible on a python3 system
        sed -i 's/python/python2/g' /usr/bin/bibleanalyzer
        sed -i 's/python/python2/g' /usr/share/applications/bibleanalyzer.desktop
        # Create the directories required
        echo -en '\E[01;31m'"\033[1m    
        For the program to run you need to create the following directory:
        mkdir -p /home/[user]/Documents/BibleAnalyzer
        \033[0m" 
        echo
        }

Last edited by MW (2011-02-19 20:17:40)

Offline

#7 2011-02-19 21:35:37

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: python2 compatability

Generally speaking, the program will create the necessary directories at runtime. Doesn't the program do this?

Offline

#8 2011-02-19 21:56:41

MW
Member
Registered: 2007-07-27
Posts: 127

Re: python2 compatability

No, unfortunately not. But I could speak to the author and hear if he could add this feature.

Offline

#9 2011-02-20 09:17:27

Awebb
Member
Registered: 2010-05-06
Posts: 6,688

Re: python2 compatability

You could copy those files to /etc/skel instead of /home/whatever and add an .install file afterwards telling the user to copy over his stuff.

I find software that does not create it's own settings on runtime disturbing.

Offline

#10 2011-02-20 11:15:40

MW
Member
Registered: 2007-07-27
Posts: 127

Re: python2 compatability

Awebb wrote:

You could copy those files to /etc/skel instead of /home/whatever and add an .install file afterwards telling the user to copy over his stuff.

I find software that does not create it's own settings on runtime disturbing.

Sorry for being such a n00b...

We are ironing out the bugs as we go along, the errors in creating the directories seem to stem from the fact that the package was developed on Ubuntu.
The program stores all it's userfiles in ~/Documents/BibleAnalyzer, and Ubuntu creates the Documents folder upon installation and the application creates the latter on first run. Other distros however do not follow the same standards so the author needs to implement a check for both the Documents AND BibleAnalyzer folders.

I have asked the author to look into this and it should be fixed momentarily, thanks for the input!

Offline

#11 2011-02-20 14:47:07

skunktrader
Member
From: Brisbane, Australia
Registered: 2010-02-14
Posts: 1,668

Re: python2 compatability

Perhaps the authors could follow the standards
http://standards.freedesktop.org/basedi … 01s03.html

Online

#12 2011-02-20 17:13:33

Anikom15
Banned
From: United States
Registered: 2009-04-30
Posts: 836
Website

Re: python2 compatability

There's a Documents folder standard?


Personally, I'd rather be back in Hobbiton.

Offline

Board footer

Powered by FluxBB