473,734 Members | 2,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Distributing applications that use 3rd party modules

Hello,

I'm getting into Python now after years of Perl, and as part of my
research I must understand how to do some common tasks I need.

I have a bunch of Windows PCs at work to which I want to distribute an
application I've developed on my PC. All these PCs have Python 2.5
installed.

If my application contains only code I've developed, I simply zip its
directory with .py files and send it to everyone, who can then use it
by running the entry-point .py file. However, what if I've installed
some 3rd party modules on my PC, and my application uses them (for
example pyparsing, PiYAML and some others) ? I don't want to manually
install all these packages (there may be dozens of them) on all those
PCs (there may be dozens of those too). What is the best method I can
use ? Naturally, I want all the non-standard packages my app uses to
be detected automatically and collected into some kind of convenient
distributable that is easy to pass around and run.

I'm aware of py2exe - tried it and it works fine. But it creates huge
executables, and I don't want to distribute those all the time. I much
prefer a zipped directory of .py scripts that takes some 10s of KBs.

Thanks in advance,
Eli
Jun 27 '08 #1
9 1507
On May 17, 4:42*am, eliben <eli...@gmail.c omwrote:
Hello,

I'm getting into Python now after years of Perl, and as part of my
research I must understand how to do some common tasks I need.

I have a bunch of Windows PCs at work to which I want to distribute an
application I've developed on my PC. All these PCs have Python 2.5
installed.

If my application contains only code I've developed, I simply zip its
directory with .py files and send it to everyone, who can then use it
by running the entry-point .py file. However, what if I've installed
some 3rd party modules on my PC, and my application uses them (for
example pyparsing, PiYAML and some others) ? I don't want to manually
install all these packages (there may be dozens of them) on all those
PCs (there may be dozens of those too). What is the best method I can
use ? Naturally, I want all the non-standard packages my app uses to
be detected automatically and collected into some kind of convenient
distributable that is easy to pass around and run.

I'm aware of py2exe - tried it and it works fine. But it creates huge
executables, and I don't want to distribute those all the time. I much
prefer a zipped directory of .py scripts that takes some 10s of KBs.

Thanks in advance,
Eli
You might want to check out Buildout. It allows you to run all that
stuff in it's own virtual world, so to speak. I'm planning on playing
with it this week.

Also, there's this site which has collected the various means of
distributing Python apps:

http://www.freehackers.org/Packaging_a_python_program

Hope that helps!

Mike
Jun 27 '08 #2
eliben wrote:
Hello,

I'm getting into Python now after years of Perl, and as part of my
research I must understand how to do some common tasks I need.

I have a bunch of Windows PCs at work to which I want to distribute an
application I've developed on my PC. All these PCs have Python 2.5
installed.

If my application contains only code I've developed, I simply zip its
directory with .py files and send it to everyone, who can then use it
by running the entry-point .py file. However, what if I've installed
some 3rd party modules on my PC, and my application uses them (for
example pyparsing, PiYAML and some others) ? I don't want to manually
install all these packages (there may be dozens of them) on all those
PCs (there may be dozens of those too). What is the best method I can
use ? Naturally, I want all the non-standard packages my app uses to
be detected automatically and collected into some kind of convenient
distributable that is easy to pass around and run.

I'm aware of py2exe - tried it and it works fine. But it creates huge
executables, and I don't want to distribute those all the time. I much
prefer a zipped directory of .py scripts that takes some 10s of KBs.
What do you call "huge"?

In my environment the end-users don't have Python installed on their own
PCs, but the team does have a networked shared drive; we put py2exe'd
applications there. Less complaints about app load time than for things
like Word/Excel/Outlook, and no complaints from me about distribution,
and no worries about users running old versions.

Cheers,
John
Jun 27 '08 #3
On May 17, 3:23 pm, Mike Driscoll <kyoso...@gmail .comwrote:
On May 17, 4:42 am, eliben <eli...@gmail.c omwrote:
Hello,
I'm getting into Python now after years of Perl, and as part of my
research I must understand how to do some common tasks I need.
I have a bunch of Windows PCs at work to which I want to distribute an
application I've developed on my PC. All these PCs have Python 2.5
installed.
If my application contains only code I've developed, I simply zip its
directory with .py files and send it to everyone, who can then use it
by running the entry-point .py file. However, what if I've installed
some 3rd party modules on my PC, and my application uses them (for
example pyparsing, PiYAML and some others) ? I don't want to manually
install all these packages (there may be dozens of them) on all those
PCs (there may be dozens of those too). What is the best method I can
use ? Naturally, I want all the non-standard packages my app uses to
be detected automatically and collected into some kind of convenient
distributable that is easy to pass around and run.
I'm aware of py2exe - tried it and it works fine. But it creates huge
executables, and I don't want to distribute those all the time. I much
prefer a zipped directory of .py scripts that takes some 10s of KBs.
Thanks in advance,
Eli

You might want to check out Buildout. It allows you to run all that
stuff in it's own virtual world, so to speak. I'm planning on playing
with it this week.
I looked at its examples and I'm not sure it's what I need. It seems
useful for other cases though.
Also, there's this site which has collected the various means of
distributing Python apps:

http://www.freehackers.org/Packaging_a_python_program
This page only talks about the packagers that create .exe files that
don't need Python installed.
Is there a simple way to find out which packages are used by my
script ?

Eli
Jun 27 '08 #4

"eliben" <el****@gmail.c omwrote in message
news:b4******** *************** ***********@m45 g2000hsb.google groups.com...
| Is there a simple way to find out which packages are used by my
| script ?

Ggrep for import statements?
(But that only only gives direct dependencies.)
Does py2exe have an option to output the list it collects?|
I think people have mentioned such here.

Jun 27 '08 #5
On May 17, 8:54 pm, "Terry Reedy" <tjre...@udel.e duwrote:
"eliben" <eli...@gmail.c omwrote in message

news:b4******** *************** ***********@m45 g2000hsb.google groups.com...
| Is there a simple way to find out which packages are used by my
| script ?

Ggrep for import statements?
This isn't very comprehensive :-)
(But that only only gives direct dependencies.)
Does py2exe have an option to output the list it collects?|
I think people have mentioned such here.
Digging around the standard library documentation, I came upon the
'modulefinder' module, which seems to be able to do what I want, at
least in terms of finding all the modules used. I wonder how difficult
it should be to wrap something around modulefinder that copies all the
relevant modules into a local directory and modifies sys.path
accordingly.

Eli
Jun 27 '08 #6
On May 17, 10:13*am, eliben <eli...@gmail.c omwrote:
On May 17, 3:23 pm, Mike Driscoll <kyoso...@gmail .comwrote:
On May 17, 4:42 am, eliben <eli...@gmail.c omwrote:
Hello,
I'm getting into Python now after years of Perl, and as part of my
research I must understand how to do some common tasks I need.
I have a bunch of Windows PCs at work to which I want to distribute an
application I've developed on my PC. All these PCs have Python 2.5
installed.
If my application contains only code I've developed, I simply zip its
directory with .py files and send it to everyone, who can then use it
by running the entry-point .py file. However, what if I've installed
some 3rd party modules on my PC, and my application uses them (for
example pyparsing, PiYAML and some others) ? I don't want to manually
install all these packages (there may be dozens of them) on all those
PCs (there may be dozens of those too). What is the best method I can
use ? Naturally, I want all the non-standard packages my app uses to
be detected automatically and collected into some kind of convenient
distributable that is easy to pass around and run.
I'm aware of py2exe - tried it and it works fine. But it creates huge
executables, and I don't want to distribute those all the time. I much
prefer a zipped directory of .py scripts that takes some 10s of KBs.
Thanks in advance,
Eli
You might want to check out Buildout. It allows you to run all that
stuff in it's own virtual world, so to speak. I'm planning on playing
with it this week.

I looked at its examples and I'm not sure it's what I need. It seems
useful for other cases though.
Also, there's this site which has collected the various means of
distributing Python apps:
http://www.freehackers.org/Packaging_a_python_program

This page only talks about the packagers that create .exe files that
don't need Python installed.

Is there a simple way to find out which packages are used by my
script ?

Eli
I'm fairly certain you can use that Freeze application to do the dirty
work for you. Or you can just distribute the pyc files...I've heard
that works somehow too.

Mike
Jun 27 '08 #7
On May 17, 4:42*am, eliben <eli...@gmail.c omwrote:
Hello,

I'm getting into Python now after years of Perl, and as part of my
research I must understand how to do some common tasks I need.

I have a bunch of Windows PCs at work to which I want to distribute an
application I've developed on my PC. All these PCs have Python 2.5
installed.

If my application contains only code I've developed, I simply zip its
directory with .py files and send it to everyone, who can then use it
by running the entry-point .py file. However, what if I've installed
some 3rd party modules on my PC, and my application uses them (for
example pyparsing, PiYAML and some others) ? I don't want to manually
install all these packages (there may be dozens of them) on all those
PCs (there may be dozens of those too). What is the best method I can
use ? Naturally, I want all the non-standard packages my app uses to
be detected automatically and collected into some kind of convenient
distributable that is easy to pass around and run.

I'm aware of py2exe - tried it and it works fine. But it creates huge
executables, and I don't want to distribute those all the time. I much
prefer a zipped directory of .py scripts that takes some 10s of KBs.

Thanks in advance,
Eli
One way I forgot to mention is to put Python on the network (i.e. the
intranet). We do that here at work and I can develop my applications
on my machine and then put them on there for anyone to use. That way
they never have to install Python, let alone the bother of installing
dependencies.

Mike
Jun 27 '08 #8
On May 20, 7:56*am, Mike Driscoll <kyoso...@gmail .comwrote:
On May 17, 4:42*am, eliben <eli...@gmail.c omwrote:


Hello,
I'm getting into Python now after years of Perl, and as part of my
research I must understand how to do some common tasks I need.
I have a bunch of Windows PCs at work to which I want to distribute an
application I've developed on my PC. All these PCs have Python 2.5
installed.
If my application contains only code I've developed, I simply zip its
directory with .py files and send it to everyone, who can then use it
by running the entry-point .py file. However, what if I've installed
some 3rd party modules on my PC, and my application uses them (for
example pyparsing, PiYAML and some others) ? I don't want to manually
install all these packages (there may be dozens of them) on all those
PCs (there may be dozens of those too). What is the best method I can
use ? Naturally, I want all the non-standard packages my app uses to
be detected automatically and collected into some kind of convenient
distributable that is easy to pass around and run.
I'm aware of py2exe - tried it and it works fine. But it creates huge
executables, and I don't want to distribute those all the time. I much
prefer a zipped directory of .py scripts that takes some 10s of KBs.
Thanks in advance,
Eli

One way I forgot to mention is to put Python on the network (i.e. the
intranet). We do that here at work and I can develop my applications
on my machine and then put them on there for anyone to use. That way
they never have to install Python, let alone the bother of installing
dependencies.

Mike- Hide quoted text -

- Show quoted text -
Impossible and Useless here:

I assert there's no way to generate the list.

a= raw_input( )
if a== 'something unknown':
b= 'imp'
b+= 'ort '
b+= 'os'
exec( b )
Jun 27 '08 #9
On May 17, 11:42 am, eliben <eli...@gmail.c omwrote:
Hello,

I'm getting into Python now after years of Perl, and as part of my
research I must understand how to do some common tasks I need.

I have a bunch of Windows PCs at work to which I want to distribute an
application I've developed on my PC. All these PCs have Python 2.5
installed.

If my application contains only code I've developed, I simply zip its
directory with .py files and send it to everyone, who can then use it
by running the entry-point .py file. However, what if I've installed
some 3rd party modules on my PC, and my application uses them (for
example pyparsing, PiYAML and some others) ? I don't want to manually
install all these packages (there may be dozens of them) on all those
PCs (there may be dozens of those too). What is the best method I can
use ? Naturally, I want all the non-standard packages my app uses to
be detected automatically and collected into some kind of convenient
distributable that is easy to pass around and run.

I'm aware of py2exe - tried it and it works fine. But it creates huge
executables, and I don't want to distribute those all the time. I much
prefer a zipped directory of .py scripts that takes some 10s of KBs.

Thanks in advance,
Eli
Hello,

If anyone is interested, I've implemented such a utility - called
libcollect.py, downloadable at: http://eli.thegreenplace.net/files/p...collect.py.txt

Here's its description from the embedded docstring:

Motivation:

Imagine that you've written a script that uses several libraries, some
of
which you've written and some you've downloaded and installed (for
example
PyYAML). You want to distribute the script to your friends and co-
workers,
who already have Python installed with all the standard library. But
your
script won't run on their machines, because they have neither your
personal
libraries, nor PyYAML installed. So what can you do ?
* You can ask them to install PyYAML and other libraries your script
uses,
and send them your own libraries. This is a lengthy and
inconvenient
process.
* You can use a tool like py2exe to package your delivery. This has a
downside, however. py2exe produces large files (several MBs) and you
may
not want that.
* You can painstakingly collect the libraries into a directory where
your
script can find them, and package the directory together with the
script.

LibCollect makes the third option trivial, by doing all the dirty work
for you.

Example:

Suppose your script is named script.py, and is located in directory
$DIR
(although I'm using Unix-y notation here, it is for convenience only.
LibCollect works similarly well on Windows platforms). Follow these
steps
to prepare a self-contained distribution with LibCollect:

Create a distribution setup script in the same directory. Lets assume
you call it distrib_script. py. You can easily place it in any
directory
you like, I'm using the same one to make the example simpler.

Add the following to distrib_script. py (assuming that libcollect.py is
in your sys.path):

*************** *************** *************** *************** **

import libcollect

# Create a LibCollect object
lc = libcollect.LibC ollect()

# Prepare arguments for do_collect
#

# Path to the script (can be absolute or relative)
scriptname = 'script.py'

# Ask the resulting distribution to be placed in
# directory distrib
targetdir = 'distrib'

# Specify which libraries to exclude from the
# distribution (because you know they're installed
# on the target machine)
excludes = ["wx",
"pywin",
"win32api",
"win32com"]

# Zip the libraries used by the script to reduce
# clutter and save space
zip_lib = True

# This does the actual work
lc.do_collect( scriptname,
targetdir,
excludes,
zip_lib=zip_lib )

*************** *************** *************** *************** **

Now run distrib_script. py.
When it finishes running, you will see that the distrib directory
has been created in $DIR. In $DIR/distrib you will see two files,
script.py and distlib.zip

* script.py is a loader that replaces your original script.py - this
is the program your users should run. All it does (look at the
code, it's short!) is prepare the sys.path to include the
packaged libraries, and runs your own script.py that was also
packaged into the .zip file
* distlib.zip is the distribution library, containing all the code
your script needs to run on any machine with Python installed,
and nothing else (except the modules you specified in the exclusion
list). You may choose to pass on the zip file creation and leave
your distribution library as a directory by providing False
to the zip_lib argument of LibCollect.do_c ollect (take a look at
its documentation, there are some other options there)

How to use LibCollect:

* It is most convenient to use LibCollect in the way demonstrated
in the example above. You may want to update your application from
time to time, and having a distribution script handy will turn
the preparation of a new distribution into a 5-second process.
* If you don't want to create a distribution script, you can use
a more direct method of invoking libcollect.py as a program on
your script. Call it without arguments and it will print
a usage string that will explain what you need to do.

How it works:

* LibCollect uses the standard modulefinder module to find out which
libraries are used by your script. It categorizes them into two
types: standard libraries that came with Python, and non-standard
libraries you've installed or written.
* Only libraries of the second type are included in the distribution
(bar the libraries you've explicitly asked to exclude).
* It then builds a directory with all the included libraries, in a
way that your script will be able to find them. The script itself
is also packaged into the same place.
* On request, this directory can be zipped into a single file, to
employ Python's built-in zip import facility.
* In the distribution directory, a new file with the name of your
script is created. It is a simple loader that uses the runpy module
to transparently load your script from the distribution library.
This way your script is not being modified (sys.path is rigged
from the loader).

Compatibility:
Python 2.5
Tested on Windows and Linux, but should work on other platforms
where the standard Python distribution works.
Jun 27 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
1878
by: Phillip Mills | last post by:
I've learned enough of the Python language to be mildly dangerous and have used it in a few personal projects. All my development of commercial (or production) products over the past dozen years have been done with C++ or Java. For a program I'm planning -- to begin during the summer -- having an interpreter as part of the application would be very desirable to allow sophisticated users to provide their own extensions. Java would be...
5
1724
by: Jiri Barton | last post by:
Hi, I'd like to be able to distribute some python modules of my system (plugins) without the source. So far, I have done this by including only the *.pyc files. However, I have recently found they are platform dependent and python version dependent. This approach has been very convenient because I don't have to mess up with __import__ and the like - which seem to be kind of a pain when inter-module dependencies are introduced.
2
2668
by: RickMuller | last post by:
I really appreciate the ease that the distutils make distributing Python modules. However, I have a question about using them to distribute non-Python (i.e. text) data files that support Python modules. Currently when I have data of this type, I parse it into python objects and make a python module from it. In other words, given a data file like % cat grocery_list.txt eggs spam
10
7424
by: John Phelan | last post by:
I read an article by, by Mike Groh, in Access-VB-SQL Advisor Magazine, Week 37 that concerns me quite a bit on distributing Access Applications commercially. First I need to describe a "commercial version" of my application that I hope to distribute after completing all the beta testing: A. It was developed using MS AccessXP Pro (developers edition), B. It has a front end MyApplication.mdb and a MyAppBbackend_be.mde; the front end is...
5
1739
by: MLH | last post by:
I have little or no knowledge as to how a runtime Access database application might be distributed from a website. I am sure that I'm about to find out. I do have one question for you wizards though... My experience has shown that when I have installed applications from the web, my browser generally asks what I want to do with the file... Do I wanna save it? or Do I wanna run it? The browser generally warns about the dangers of executing...
7
1784
by: wazdakka | last post by:
I'm confused about what is necessary to distribute an Access 2003 application to people that don't have MS Access (or don't have the right version) installed on their PCs. I have done some research on the MS website, as well as on this newsgroup, and have never found a clear explanation of what is required. I have written an application that I would like to sell, but if I can only sell to those with access to Access (sorry, couldn't...
6
1936
by: Ben Finney | last post by:
Howdy all, I'm improving an existing application that's partly written using Python and the standard library. Many of the improvements I want to make can be done by using third-party free software. The immediate customer for this application is happy to install Python on their machine, but I'd like to remove the hassle of asking them to continually install new versions of great third-party Python software that isn't packaged for their...
11
4015
by: Tina I | last post by:
Hi list, Is there a preferred way to distribute programs that depends on third party modules like PyQt, Beautifulsoup etc? I have used setuptools and just having the setup script check for the existence of the required modules. If they're not found I have it exit with a message that it need this or that installed. But this is not very convenient for the end user and I have got a few complaints about it. Am I missing something in...
1
1413
by: PurpleServerMonkey | last post by:
Working on a rather large open source python application that I want to release for Linux and BSD and was wondering what methods others are using to distribute large and complex applications. Setuptools and friends seem to be focused on distributing modules, I'm at the other end of the scale where I want to distribute an entire application so that an Administrator can run a single install and have a fully operational product. A key...
0
8776
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9449
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9310
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9236
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.