Python XMP Toolkit bundling

View: New views
8 Messages — Rating Filter:   Alert me  

Python XMP Toolkit bundling

by Jim Skibbie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Python XMP Toolkit bundling I’m a Python newbie... I am working on a project where I need to read and write XMP metadata to PDF files. I found the Python XMP Toolkit at http://code.google.com/p/python-xmp-toolkit/ and was able to download, compile and install all the pieces (boost, Exempi and Python XMP Toolkit) and write a script that can actually do what I want.

Now, my question is, how can I distribute this kind of solution to other user’s workstations? I don’t want to have to repeat this whole process to create the necessary environment on each user machine to be able to run this python script.

Is there a way that I can bundle all the necessary dependencies (boost, Exempi, Python XMP Toolkit) together so that to the user it is just a single application? And if so, what about the compiled versions on Intel vs. G5 machines?

Below is the whole script. It basically takes a file path and two values as arguments and writes the two values into the XMP stream of the file.

It seems pretty simple, but the distribution part seems daunting to me.

Thanks.
Jim


import sys
from libxmp import *

path_to_file = sys.argv[1]
vertical_shrink = sys.argv[2]
horizontal_shrink = sys.argv[3]

# Read file
xmpfile = XMPFiles( file_path=path_to_file, open_forupdate=files.XMP_OPEN_FORUPDATE)

# Get XMP from file.
xmp = xmpfile.get_xmp()

# Change the XMP property
xmp.set_property( "http://ns.somenamespace.com/1.0/", 'vshrink', vertical_shrink )
xmp.set_property( "http://ns.somenamespace.com/1.0/", 'hshrink', horizontal_shrink )


# Check if XMP document can be written to file and write it.
if xmpfile.can_put_xmp(xmp):
    xmpfile.put_xmp(xmp)

xmpfile.close_file()

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@...
http://mail.python.org/mailman/listinfo/pythonmac-sig

Re: Python XMP Toolkit bundling

by Aahz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Oct 27, 2009, Jim Skibbie wrote:

>
> I?m a Python newbie... I am working on a project where I need to read and
> write XMP metadata to PDF files. I found the Python XMP Toolkit at
> http://code.google.com/p/python-xmp-toolkit/ and was able to download,
> compile and install all the pieces (boost, Exempi and Python XMP Toolkit)
> and write a script that can actually do what I want.
>
> Now, my question is, how can I distribute this kind of solution to other
> user?s workstations? I don?t want to have to repeat this whole process to
> create the necessary environment on each user machine to be able to run this
> python script.

http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html
--
Aahz (aahz@...)           <*>         http://www.pythoncraft.com/

"You could make Eskimos emigrate to the Sahara by vigorously arguing --
at hundreds of screens' length -- for the wonder, beauty, and utility of
snow."  --PNH to rb in r.a.sf.f
_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@...
http://mail.python.org/mailman/listinfo/pythonmac-sig

Re: Python XMP Toolkit bundling

by Jim Skibbie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Re: [Pythonmac-SIG] Python XMP Toolkit bundling How can I make my script into an application if I need to pass arguments to it? From the command line I can pass three variables to it (file path and two distortion numbers). How would that work as an application?

Thanks.
Jim


From: Aahz <aahz@...>
Organization: The Cat & Dragon
Date: Tue, 27 Oct 2009 14:13:55 -0700
To: Jim Skibbie <jskibbie@...>
Cc: <pythonmac-sig@...>
Subject: Re: [Pythonmac-SIG] Python XMP Toolkit bundling

On Tue, Oct 27, 2009, Jim Skibbie wrote:
>
> I?m a Python newbie... I am working on a project where I need to read and
> write XMP metadata to PDF files. I found the Python XMP Toolkit at
> http://code.google.com/p/python-xmp-toolkit/ and was able to download,
> compile and install all the pieces (boost, Exempi and Python XMP Toolkit)
> and write a script that can actually do what I want.
>
> Now, my question is, how can I distribute this kind of solution to other
> user?s workstations? I don?t want to have to repeat this whole process to
> create the necessary environment on each user machine to be able to run this
> python script.

http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html
--
Aahz (aahz@...)           <*>         http://www.pythoncraft.com/

"You could make Eskimos emigrate to the Sahara by vigorously arguing --
at hundreds of screens' length -- for the wonder, beauty, and utility of
snow."  --PNH to rb in r.a.sf.f

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@...
http://mail.python.org/mailman/listinfo/pythonmac-sig

Re: Python XMP Toolkit bundling

by Jim Skibbie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Re: [Pythonmac-SIG] Python XMP Toolkit bundling For testing purposes, I removed the option to pass arguments to my Python script and I tried using the tutorial for py2app to create a standalone app.

The Python script looks like the below, but when I build the standalone app and try to run it, I get the error:

ImportError: No module named libxmp

How do I go about getting the libxmp which is part of the ‘python-xmp-toolkit’ that I compiled to be part of my standalone app?

Thanks.
Jim


import sys

from libxmp import *

path_to_file = "/Users/jim/Desktop/021521A.pdf"
vertical_shrink = ".5"
horizontal_shrink = ".5"

# Read file
xmpfile = XMPFiles( file_path=path_to_file, open_forupdate=files.XMP_OPEN_FORUPDATE)

# Get XMP from file.
xmp = xmpfile.get_xmp()


# Change the XMP property
xmp.set_property( "http://ns.esko-graphics.com/grinfo/1.0/", 'vshrink', vertical_shrink )
xmp.set_property( "http://ns.esko-graphics.com/grinfo/1.0/", 'hshrink', horizontal_shrink )


# Check if XMP document can be written to file and write it.
if xmpfile.can_put_xmp(xmp):
    xmpfile.put_xmp(xmp)

xmpfile.close_file()

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@...
http://mail.python.org/mailman/listinfo/pythonmac-sig

Re: Python XMP Toolkit bundling

by Jim Skibbie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Re: [Pythonmac-SIG] Python XMP Toolkit bundling I was using the –A option to develop in alias mode and that was my issue. When I removed that flag, the libxmp did get bundled into the application.

Thanks.
Jim


From: Jim Skibbie <jskibbie@...>
Date: Wed, 28 Oct 2009 11:16:03 -0500
To: "pythonmac-sig@..." <pythonmac-sig@...>
Conversation: [Pythonmac-SIG] Python XMP Toolkit bundling
Subject: Re: [Pythonmac-SIG] Python XMP Toolkit bundling

For testing purposes, I removed the option to pass arguments to my Python script and I tried using the tutorial for py2app to create a standalone app.

The Python script looks like the below, but when I build the standalone app and try to run it, I get the error:

ImportError: No module named libxmp

How do I go about getting the libxmp which is part of the ‘python-xmp-toolkit’ that I compiled to be part of my standalone app?

Thanks.
Jim


import sys

from libxmp import *

path_to_file = "/Users/jim/Desktop/021521A.pdf"
vertical_shrink = ".5"
horizontal_shrink = ".5"

# Read file
xmpfile = XMPFiles( file_path=path_to_file, open_forupdate=files.XMP_OPEN_FORUPDATE)

# Get XMP from file.
xmp = xmpfile.get_xmp()


# Change the XMP property
xmp.set_property( "http://ns.esko-graphics.com/grinfo/1.0/", 'vshrink', vertical_shrink )
xmp.set_property( "http://ns.esko-graphics.com/grinfo/1.0/", 'hshrink', horizontal_shrink )


# Check if XMP document can be written to file and write it.
if xmpfile.can_put_xmp(xmp):
    xmpfile.put_xmp(xmp)

xmpfile.close_file()

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@...
http://mail.python.org/mailman/listinfo/pythonmac-sig

Re: Python XMP Toolkit bundling

by Christopher Barker :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Jim Skibbie wrote:
> For testing purposes, I removed the option to pass arguments to my
> Python script and I tried using the tutorial for py2app to create a
> standalone app.

1) use the latest py2app"

easy_install py2app==dev


2) make sure you are running py2app with the same python that you've
installed all that stuff into. (and tell us what python that is)

3) post your setup.py here, so we can see what you've done

4) tell us OS and Python version.

-Chris



--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker@...
_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@...
http://mail.python.org/mailman/listinfo/pythonmac-sig

Re: Python XMP Toolkit bundling

by Jim Skibbie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Re: [Pythonmac-SIG] Python XMP Toolkit bundling From: Christopher Barker <Chris.Barker@...>
Date: Wed, 28 Oct 2009 09:50:14 -0700
To: Jim Skibbie <jskibbie@...>
Cc: "pythonmac-sig@..." <pythonmac-sig@...>
Subject: Re: [Pythonmac-SIG] Python XMP Toolkit bundling

Jim Skibbie wrote:
> For testing purposes, I removed the option to pass arguments to my
> Python script and I tried using the tutorial for py2app to create a
> standalone app.

1) use the latest py2app"

easy_install py2app==dev

I’m using py2app v. 0.4.3

2) make sure you are running py2app with the same python that you've
installed all that stuff into. (and tell us what python that is)

Not sure what you mean about using the same python that I’ve installed all the stuff into. I compiled boost, exempi and python-xmp-toolkit into a directory inside my /opt/local folder. Should I have installed these in some other place?

3) post your setup.py here, so we can see what you've done

Here’s the setup.py, it is just the generated one from py2applet.

"""
This is a setup.py script generated by py2applet

Usage:
    python setup.py py2app
"""

from setuptools import setup

APP = ['WriteEskoXMP.py']
DATA_FILES = []
OPTIONS = {'argv_emulation': True}

setup(
    app=APP,
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=['py2app'],
)

I got the py2app to make an app that runs now by turning off the –A (alias mode) when building the app, but it still only runs on my machine. The libxmp looks like it’s getting bundled now, but when I try to run it on a different machine, I get a error:
ExempiLoadError so now it looks like the Exempi which the python-xmp-toolkit requires ( http://www.spacetelescope.org/projects/python-xmp-toolkit/docs/installation.html) isn’t getting bundled, or maybe it can’t be bundled? That would be a bummer.

4) tell us OS and Python version.

I’m using OS X 10.5.8 and Python 2.5.1 which I’m assuming is what came with my Mac? I don’t remember installing anything else.

Can you tell that I’m in a little over my head??

Thanks.
Jim



-Chris



--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker@...

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@...
http://mail.python.org/mailman/listinfo/pythonmac-sig

Re: Python XMP Toolkit bundling

by Christopher Barker :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Jim Skibbie wrote:
> I’m using py2app v. 0.4.3

That should do it.


>     2) make sure you are running py2app with the same python that you've
>     installed all that stuff into. (and tell us what python that is)
>
>
> Not sure what you mean about using the same python that I’ve installed
> all the stuff into. I compiled boost, exempi and python-xmp-toolkit into
> a directory inside my /opt/local folder. Should I have installed these
> in some other place?

What I meant was to make sure that you run py2app with the same python
that you are running your app with when it isn't bundles -- you can have
any number of different pythons installed: 2.5, 2.5, macports, fink,
etc., etc, etc.


> Here’s the setup.py, it is just the generated one from py2applet.

fine place to start

> I got the py2app to make an app that runs now by turning off the –A
> (alias mode) when building the app,

odd -- usually -A is easier to get working! Unless you move the bundle...

> but it still only runs on my
> machine.

> I’m using OS X 10.5.8 and Python 2.5.1 which I’m assuming is what came
> with my Mac? I don’t remember installing anything else.

If you use that one, py2app won't bundle everything, so it won't work on
any non-10.5 machine (and I'm not sure about extra stuff you've installed).

It's best to use the python 2.5 you get from python.org

You will then need to re-install the add-on packages you need.

> Can you tell that I’m in a little over my head??

This is all more complicated than it should be.

-Chris


--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker@...
_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@...
http://mail.python.org/mailman/listinfo/pythonmac-sig