Scribusoid

Author Topic: In Script Console: Can Python Be Configured?  (Read 2260 times)

jlpoole

  • Newbie
  • *
  • Posts: 26
  • Karma: 0
  • Scribus User
In Script Console: Can Python Be Configured?
« on: June 15, 2012, 08:44:26 am »
I'm trying to get a handle on the Python interface both for Unix and Windows.

Windows
I'm running the stable build 1.4.1.  There is a dynamic link library (DLL) in the main directory, i.e. C:\Program Files (x86)\Scribus 1.4.1, for python: python27.dll.  I read a post somewhere where someone mentioned removing the dll along with some directories and then the system's python would be utilized.  I tried appending "HOLD" to the file name and the lib, dlls, and tcl directories and found that the scripting engine just became inoperative.  So I'm guessing that the python that ships with this release, python 2.7, is the only python available within the scripting environment; you cannot invoke a higher version of python with the Windows release.  Is this a correct statement?

Linux
I'm working off the Subversion HEAD, 1.5.0.svn, and finding that the python exposed through the scripting interface is version 2.6.6.  I click Script-->Show Console and then in the upper pain enter:
Code: [Select]
print(sys.version)that produces
Code: [Select]
2.6.6 (r266:84292, Mar 25 2011, 22:27:52)
[GCC 4.4.5]

In Gentoo, we have slots that allow for installations of various versions of software.  For Python, I have the following installed:
Code: [Select]
[U] dev-lang/python
     Available versions:
        (2.5)   2.5.4-r4
        (2.6)   2.6.6-r2 ~2.6.7-r2 2.6.8
        (2.7)   2.7.2-r3 ~2.7.3 2.7.3-r1 ~2.7.3-r2
        (3.1)   3.1.4-r3 ~3.1.4-r4 3.1.5
        (3.2)   3.2.2 ~3.2.2-r1 3.2.3 ~3.2.3-r1
        {-berkdb build doc elibc_uclibc examples gdbm ipv6 +ncurses +readline sqlite +ssl +threads tk +wide-unicode wininst +xml}
     Installed versions:  2.6.6-r2(2.6)(22:29:13 03/25/11)(gdbm ncurses readline sqlite ssl threads wide-unicode xml -berkdb -build -doc -elibc_uclibc -examples -ipv6 -tk -wininst)
2.7.2-r3(2.7)(05:35:55 11/07/11)(gdbm ncurses readline sqlite ssl threads wide-unicode xml -berkdb -build -doc -elibc_uclibc -examples -ipv6 -tk -wininst)
3.1.4-r3(3.1)(05:47:17 11/07/11)(gdbm ncurses readline sqlite ssl threads wide-unicode xml -build -doc -elibc_uclibc -examples -ipv6 -tk -wininst)
3.2.3(3.2)(21:13:08 06/13/12)(gdbm ncurses readline sqlite ssl threads tk wide-unicode xml -build -doc -elibc_uclibc -examples -ipv6 -wininst)
     Homepage:            http://www.python.org/
     Description:         Python is an interpreted, interactive, object-oriented programming language.

You select which version you want operative by the "eselect" command.
Code: [Select]
themis src # eselect python list
Available Python interpreters:
  [1]   python2.6
  [2]   python2.7
  [3]   python3.1
  [4]   python3.2 *
themis src #

In this case, I have version 3.2 selected as indicated by the asterisk.  I cannot remember which slot of python I had operative when I built python from the Subversion pull, but I'm pretty sure I had 3.2 selected.  It takes about 15 minutes to build Scribus on my laptop, and I've gone through several builds seeing if I can affect the outcome of which version of Python runs in the console.

With this background, I'm wondering if one can specify which version of Python is running in Scribus's console, or is that hardwired into the product?  I acknowledge that Gentoo's slot system adds an additional layer of complexity.

When I select Script->Scribus Scripts->Font Sample, I get this error message:
Code: [Select]
This script will not work without Tkinter
Please install and try again

My python version 3.2 does have tkinter (changed to lowercase for Python 3.+) available (however, version 2.6 does not) as I get the sample window when running: 
Code: [Select]
python -m tkinter
So, this topic is designed to address the question of whether the version of Python running from the script interface is configurable either at run time or during the build process.
John L. Poole

work: Principal Software Engineer, Oracle Corporation
play: Editions Poole - publisher of classical ensemble piano music (using InDesign & scripts thereunder)

jlpoole

  • Newbie
  • *
  • Posts: 26
  • Karma: 0
  • Scribus User
Re: In Script Console: Can Python Be Configured?
« Reply #1 on: June 23, 2012, 09:46:49 am »
I found a partial answer to my question (at least for a Windows build):

only 2.7, 3.x will not work

See line 327 in http://scribus.net/websvn/filedetails.php?repname=Scribus&path=%2Ftrunk%2FScribus%2FBUILDING_win32_msvc.txt, version 17537

John L. Poole

work: Principal Software Engineer, Oracle Corporation
play: Editions Poole - publisher of classical ensemble piano music (using InDesign & scripts thereunder)