473,387 Members | 3,684 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 1518
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_hierarchy(starting_point, data_files):
dir_files = os.walk(starting_point)

for (path, name, files) in dir_files:
x = os.path.basename(path)
if x != 'CVS':
clean_files = [ os.path.join(path,item) \
for item in files \
if (clean_test(item)) ]
data_files.append((cr_paths%path,clean_files))

return data_files

setup(...
data_files=expand_hierarchy("web-ui",
[(cr_paths%'etc',

['ancillary/baseline_configuration']),
],
)
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
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...
1
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: ...
15
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: *...
1
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...
3
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...
0
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 |...
2
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
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...
0
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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...

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.