I got really tired of unpacking a distutils package, installing then
cleaning up. So I wrote distinstall.py - it reads a zip file, unpacks
it, installs the bits and cleans up. I've only used it on windows and
Linux and for pure Python packages.
Windows: distinstall.py Photronics.zip
Linux: python distinstall.py Photronics.zip
Hopefully somebody else will find it useful.
#============== ========== distinstall.py =============== ======
#!/usr/bin/env python
'''Install a zipped up distutils package'''
import zipfile
import sys, os, os.path
def usage():
print "distinstal l.py pack.zip: Install a zipped distutil python
package"
print "One arg: name of the zip package"
print "THIS PROGRAM ONLY WORKS WITH ZIPPED PURE PYTHON PACKAGES!"
sys.exit(1)
def nuke(top):
# Delete everything reachable from the directory named in 'top'.
# CAUTION: This is dangerous! For example, if top == '/', it
# could delete all your disk files.
for root, dirs, files in os.walk(top, topdown=False):
for name in files:
os.remove(os.pa th.join(root, name))
for name in dirs:
os.rmdir(os.pat h.join(root, name))
os.rmdir(top)
def explodeZipFile( zippedPackageFi leName):
if not zipfile.is_zipf ile(zippedPacka geFileName):
print '"%s" is not a zip file!' % zippedPackageFi leName
usage()
zip = zipfile.ZipFile (zippedPackageF ileName,'r')
if not filter(lambda n:"setup.py" in n, zip.namelist()) :
print "setup.py isn't in the zip file! Not a distutil package?"
usage()
tmp = os.getenv('TMP' ) or os.getenv('TMPD IR')
if (not tmp) and os.path.isdir('/tmp'): tmp = '/tmp'
if not tmp:
print 'Can\'t find the tmp directory!'
sys.exit(1)
path,fileName = os.path.split(z ippedPackageFil eName)
tmpDir = os.path.join(tm p,os.path.split ext(fileName)[0])
print "unzip %s to %s" % (zippedPackageF ileName,tmpDir)
for z in zip.namelist():
# print z
data = zip.read(z)
try:
os.makedirs(os. path.join(tmp,o s.path.split(z)[0]),0777)
except: pass
f = file(os.path.jo in(tmp,z),'w') #?? what's up with wb?
f.writelines(da ta.split('\r')) # this really sucks
f.close()
zip.close()
setup = os.path.join(tm pDir,"setup.py" )
return tmpDir,setup
if len(sys.argv) < 2: usage()
cwd = os.getcwd()
zippedPackageFi leName = sys.argv[1]
tmpDir,setup = explodeZipFile( zippedPackageFi leName)
print "============== ======Install== =============== "
os.chdir(tmpDir )
install = "%s setup.py install --force" % sys.executable
print install
os.system(insta ll)
os.chdir(cwd)
print "\nClean up %s" % tmpDir
nuke(tmpDir) # this will clean up the build directory
#============== ========== distinstall.py =============== ====== 0 1436 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Isaac Jones |
last post by:
Hello Python Community. I bring greetings from the Haskell community
(http://www.haskell.org) ;)
There has been a lot of discussion of late about creating a
grand-unified build & distribution system for "3rd party" Haskell
libraries (those not distributed with the compilers). Python's
Distutils has come up a few times. The Haskell...
|
by: John Hunter |
last post by:
What is the best way to get the target install dir from distutils when
python setup.py install
is run.
Eg, on a standard python install to /usr/local I want
/usr/local/lib/python2.3/site-packages
|
by: Derek Croxton |
last post by:
I just installed a new Linux distribution (MEPIS) and went to install
PDO and got the error
Traceback (most recent call last):
File "setup.py", line 2, in ?
from distutils.core import setup
ImportError: No module named distutils.core
Undaunted, I downloaded the Distutils package, which is supposed to be
able to install itself with the...
|
by: Holger Joukl |
last post by:
Hi,
what version of python are you using?
I got the same error when invoking a customized, 2-year-old version of
distutils with
python 2.3.3 (instead of 1.5.2, as before). Reason is code in dist.py,
using dir() to
look up the attributes of a class instance. But dir() nowadays also returns
the class methods,
__doc__ etc.
Changing this in...
|
by: Christopher Barker |
last post by:
HI all,
I'd like to be able to use distutils to install a package within the
wxPython package:
wx.lib.MyPackage
I want to be able to do this so folks can upgrade a package of mine that
is in the wxPython library, without changing it's location.
| |
by: jtan325 |
last post by:
hi,
i am running Linux Ubuntu Hoary and am trying to build the Python
numarray package, v. 1.3.2 by hand since ubuntu's repos won't be
updated until breezy.
i have python 2.4, and gcc 3.3.5
after unpacking the tar, i run "python setup.py install", as it says in
the installation instructions. i get the following:
|
by: seberino |
last post by:
It appears that apps distributed as Python Eggs are either a single
compressed
blob in site-packages directory or a directory under site-packages
directory.
Is this ALWAYS true? So by just erasing stuff under site-packages
I can do a COMPLETE uninstallation of an Egg?
Chris
|
by: spectrumdt |
last post by:
Hello.
I am trying to install Pypvm (http://pypvm.sourceforge.net/), the
Python interface to PVM ("Parallel Virtual Machine"). Unfortunately,
installation fails. I am hoping someone can help me fix it.
I am running Fedora Core 8 Linux.
The official Pypvm documentation is very helpful (or something),
providing the following:
|
by: Gabriel Genellina |
last post by:
En Thu, 29 May 2008 06:29:00 -0300, <Dominique.Holzwarth@ch.delarue.com>
escribió:
You don't need setuptools at all. Just write a setup.py file using the
standard distutils module, and execute:
python setup.py bdist_wininst
It will create an executable installer. A simple setup.py script looks
|
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...
|
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. ...
| |
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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...
|
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...
|
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |