[Distutils] [setuptools] running a post_install script
Jon Peirce
Jonathan.Peirce at nottingham.ac.uk
Thu Aug 24 19:44:09 CEST 2006
I've just been discovering the beauties of setuptools - for someone like
me, developing a package with many dependencies, it could be just the
tonic! And very easy to get going too - thnks!
One question though - my package carries a post-install script to create
a few shortcuts on windows systems. Creating an egg and then
easy_installing it copies a setuptools version of the script to the
scripts folder but it doesn't run at the end of install (or maybe it
tries to and fails in some hidden way). The script does use the special
functions from distutils [like get_special_folder_path(csidl_string)]
and maybe these aren't available to setuptools?
Am I missing something? Should it run? Or is it a simple limitation of
eggs that they can't do this?
The post-install script is attached below.
thanks
Jon
http://www.psychopy.org/
#--------------------------------------
##-----------------------------
##Windows post install (shortcuts etc...)
##-----------------------------
import sys, os
def install():
print "Adding shortcuts to >>Start>Programs>PsychoPy"
progsFolder= get_special_folder_path("CSIDL_COMMON_PROGRAMS")
sitePackages = os.path.join(sys.prefix , 'lib','site-packages')
#Psychopy Programs folder
psychopyShortcuts = os.path.join(progsFolder, 'PsychoPy')
if not os.path.isdir(psychopyShortcuts):
os.mkdir(psychopyShortcuts)
directory_created(psychopyShortcuts)
#monitor center
monitorCenterLink=os.path.join(psychopyShortcuts, "MonitorCenter.lnk")
if os.path.isfile(monitorCenterLink):
os.remove(monitorCenterLink)#we want to make a new one
create_shortcut(os.path.join(sitePackages,'monitors','MonitorCenter.py'),
'PsychoPy Monitor Center', monitorCenterLink)
file_created(monitorCenterLink)
#homepage
homePageLink = os.path.join(psychopyShortcuts, "PsychoPyHome.lnk")
if os.path.isfile(homePageLink):
os.remove(homePageLink)#we want to make a new one
create_shortcut(r"http://www.psychopy.org",
'PsychoPy HomePage', homePageLink)
file_created(homePageLink)
print "All done. Enjoy!"
if len(sys.argv) > 1:
if sys.argv[1] == '-install':
install()
else:
print "Script was called with option %s" % sys.argv[1]
This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.
More information about the Distutils-SIG
mailing list