473,722 Members | 2,397 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

another distutils question

is there anyway I can, in a setup.py file, set and internal equivalent
to the '--install-scripts' commandline option?

script installation directory but I don't want on the command line where
things can go horribly wrong if the user forgets. I would like to
create a new default setting for this commandline option as well as a
couple of other such as the data default directory.

--- eric

Sep 29 '06 #1
7 1539
On Fri, 29 Sep 2006 13:53:46 -0400, Eric S. Johansson wrote:
is there anyway I can, in a setup.py file, set and internal equivalent
to the '--install-scripts' commandline option?

script installation directory but I don't want on the command line where
things can go horribly wrong if the user forgets. I would like to
create a new default setting for this commandline option as well as a
couple of other such as the data default directory.

--- eric
On a similar note , I have another question about distutils and data files.
I have a little program that uses a txt file to store data, and it works
fine running it in it's own folder, if I install through distutils, using
sudo to get it to write to the site-packages folder (which root owns), it
installs the data file so that it is owned by root, and not by me, so
that the data file can't be written to (although the script can read it).
Do I need to run a post install script, or add something to setup.py file
to chown the file or am I doing something wrong? There doesn't seem to be
anything on this in the docs.
Thanks in advance,
Keith

Sep 29 '06 #2
Keith Perkins wrote:
On a similar note , I have another question about distutils and data files.
I have a little program that uses a txt file to store data, and it works
fine running it in it's own folder, if I install through distutils, using
sudo to get it to write to the site-packages folder (which root owns), it
installs the data file so that it is owned by root, and not by me, so
that the data file can't be written to (although the script can read it).
Do I need to run a post install script, or add something to setup.py file
to chown the file or am I doing something wrong? There doesn't seem to be
anything on this in the docs.
There's nothing in distutils specifically that will let you do this. The root
user will have to chown/chgrp/chmod/chwhatever the package that you installed
manually.

You shouldn't use package data for things that are going to be modified.
Instead, use a directory like ~/.myscript/ or something else.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Sep 29 '06 #3
On Fri, 29 Sep 2006 18:57:12 -0500, Robert Kern wrote:
Keith Perkins wrote:
>On a similar note , I have another question about distutils and data files.
I have a little program that uses a txt file to store data, and it works
fine running it in it's own folder, if I install through distutils, using
sudo to get it to write to the site-packages folder (which root owns), it
installs the data file so that it is owned by root, and not by me, so
that the data file can't be written to (although the script can read it).
Do I need to run a post install script, or add something to setup.py file
to chown the file or am I doing something wrong? There doesn't seem to be
anything on this in the docs.

There's nothing in distutils specifically that will let you do this. The root
user will have to chown/chgrp/chmod/chwhatever the package that you installed
manually.

You shouldn't use package data for things that are going to be modified.
Instead, use a directory like ~/.myscript/ or something else.
I did install it in ~/.script/data.txt, and distutils set the
user/group as root. Is it impossible to install this with distutils?
Since I'm running setup as root, should I just add a class or method to
chown the datafolder/file to the installer. Should I use autotools
instead? I haven't looked into eggs yet would that be a better choice? The
data file is something that is necessary for the program (it reads it and
prints out a random line--the whole idea of the script)if that's all I
wanted it to do I wouldn't have any problems--I could even include it as a
list in the script file, but I would like the user to be able to add other
data.
Thanks,
Keith
Sep 30 '06 #4
Keith Perkins wrote:
I did install it in ~/.script/data.txt, and distutils set the
user/group as root. Is it impossible to install this with distutils?
Since I'm running setup as root, should I just add a class or method to
chown the datafolder/file to the installer. Should I use autotools
instead? I haven't looked into eggs yet would that be a better choice? The
data file is something that is necessary for the program (it reads it and
prints out a random line--the whole idea of the script)if that's all I
wanted it to do I wouldn't have any problems--I could even include it as a
list in the script file, but I would like the user to be able to add other
data.
Don't use "setup.py install" to install that directory. Imagine a case where the
root user installs the package for everyone on the system to use. How do the
multiple users get ~/.script/?

Instead, include the default data inside the package (read-only to non-root
users). Then allow the script itself to create the directory the first time it
is run (read-write, and it should then automatically be accessible to the user
that ran the script). You might also add a command-line option to *only* install
that directory.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Sep 30 '06 #5
Keith Perkins wrote:
>
On a similar note , I have another question about distutils and data files.
I have a little program that uses a txt file to store data, and it works
fine running it in it's own folder, if I install through distutils, using
sudo to get it to write to the site-packages folder (which root owns), it
installs the data file so that it is owned by root, and not by me, so
that the data file can't be written to (although the script can read it).
Do I need to run a post install script, or add something to setup.py file
to chown the file or am I doing something wrong? There doesn't seem to be
anything on this in the docs.
1: as pointed out, site-packages is for code only :-)

2: you will need a post processing script.

here is an example of distutils abuse that may help a little bit. I
needed to collect files from a file hierarchy and one other place in the
source directory then stuff them in the right place in the production
directory. Since the pattern was unpredictable, I built a method to
accumulate data file references.

the solution is a bit more hard coded than I like but it gets the job
done for now. as I need to improve it, I'll fix it.

def expand_hierarch y(starting_poin t, data_files):
dir_files = os.walk(startin g_point)

for (path, name, files) in dir_files:
x = os.path.basenam e(path)
if x != 'CVS':
clean_files = [ os.path.join(pa th,item) \
for item in files \
if (clean_test(ite m)) ]
data_files.appe nd((cr_paths%pa th,clean_files) )

return data_files

setup(...
data_files=expa nd_hierarchy("w eb-ui",
[(cr_paths%'etc' ,

['ancillary/baseline_config uration']),
],
)
to solve the file perms problem you run something after setup. how you
associate perms/ownership with a file is up to you. It might work to
use data_files to enumerate files you apply the common perms/owernship.
then special case what you need to.

hope this gives you some useful ideas.

--- eric

Sep 30 '06 #6
Robert Kern wrote:
Instead, include the default data inside the package (read-only to non-root
users). Then allow the script itself to create the directory the first time it
is run (read-write, and it should then automatically be accessible to the user
that ran the script). You might also add a command-line option to *only* install
that directory.
I would be okay with a package/data/... arrangement if and only if the
data within that directory was read only and only changed when the
package changed it. System specific changes would be in a system copy
of the configuration file and user specific changes would be a user copy.

If you create a configuration system which uses a union of all three
configuration files, you eliminate unnecessary replication of
configuration values, minimize changes necessary when the baseline
configuration file changes, and you also have the opportunity to
control scope of configuration variables. I.e. some that are only
changed in the system config file.

I have an application dependent version of this I've been using for the
past three years and, it's really nice. It lets me mostly ignore the
configuration files and focus on what I'm trying to solve.

--- eric

Sep 30 '06 #7
Thanks everyone, for your answers. They've been very helpful.
Keith
Sep 30 '06 #8

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

Similar topics

3
4978
by: Rick Muller | last post by:
I've been trying to figure out whether there are any plans to add an "uninstall" feature to the Python distutils. Googling has found several people posting the same question, but, to the best of my knowledge, no answers. Can anyone tell me whether this has been proposed before? Thanks in advance.
1
2655
by: Mathieu Malaterre | last post by:
Hello, I thought this would be easy but I guess I didn't get the distutil feeling. I am trying to write a setup for install my package but I don't understand how to do that. organisation: setup.py /bin/
15
4123
by: Colin J. Williams | last post by:
The distutils download page has: -------------------------------------------------------- Current stable release The current stable release is Distutils 1.0.2; you can download it as: * Distutils-1.0.2.tar.gz (source distribution) (233k) * Distutils-1.0.2.zip (source distribution) (274k) * Distutils-1.0.2.win32.exe (Windows installer) (187k)
1
1718
by: Terry Hancock | last post by:
Some time ago, I got the idea that I wanted to build image resources from vector graphic originals, instead of marshalling hundreds of tiny little icon images by hand. I wrote "BuildImage" to do this for me, and so far, it works very well, so I'm trying to make it easier to use and available to more developers. There is a brief (and somewhat dated) tutorial explaining what BuildImage itself does at:
3
1912
by: Qiangning Hong | last post by:
I am writing a setup.py for my package. I have a pre-compiled myextmod.pyd file in my package and I want the distutils to automatically copy it to C:\Python23\Lib\site-packages\mypackage\myextmod.pyd. I try to add the following parameter to setup(): data_file = )], but it installs the pyd file to C:\Python23\mypackage\myextmod.pyd,
0
1450
by: Glenn Pierce | last post by:
Hi I have a question about writing a portable setup.py script for distutils. I have a directory structure like this. FreeImage/ |----------Source/ | |------ FreeImage.h | |----------Dist/ | |------FreeImage.lib
2
1061
by: Laszlo Zsolt Nagy | last post by:
How how can I install my .mo files from a distutil script into its default location? sys.prefix + os.sep + 'share' + os.sep + 'locale'
9
4159
by: jtravs | last post by:
Hi all, I suspect that I'm doing something stupid, I would like some other opinions though. I'm getting started with ctypes and am trying to use distutils to help build my module. At the moment I simply want distutils to build a shared c library (not a python extension!). Under linux, the following works, under windows xp id doesn't (which I guess is obvious, but the linux success lead me on). I have two files at the moment...
0
1465
by: newbie73 | last post by:
OS: Vista Python 2.5.2.2 (ActiveState Software Installation) Running latest Cygwin release The error generated is pasted below - please help. - Luis ***************************************
0
8863
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8739
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
9088
tracyyun
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8052
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...
0
5995
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4502
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
3207
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
2
2602
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2147
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.