473,396 Members | 1,827 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,396 software developers and data experts.

distutils: tweaking my ini to use relevant data_files path

I would like to let my setup script know if the user has provided a
custom path for the data_files of my distribution, e.g. by using the
--install-data option, so the setup can automagically change a config
information in my package to the local path applied, instead of using
some default path I hard-coded into the config information. I could not
find an appropriate pattern for this, but I'm rather confident that this
is not too exotic and some of you already use such a pattern. Would be
great to learn. Thank you in advance.

Following some details. My development version is Python 2.4.4 on
Windows XP. My project contains a sdk.ini configuration file which is in
the root package of my tool (by default in site-packages of course).
This INI has a OSPDIR option for a path to some example *.osp files
(data_files) coming with the distribution. These *.osp files are some
work files that should be typically stored in an user's home directory
or somewhere else, but not in the Python directory.

So, the setup() in my setup.py has (among many other arguments, which I
don't consier to be important for my task here):

data_files=[('projects', ['projects/foo.osp', 'projects/bar.osp']),

By default this "projects" directory is going into the Python directory,
right? At least I could see that in my Python 2.4.4 installation on
Windows XP:

C:\Python24\projects\

My default config could be:
OSPDIR = os.path.join(sys.prefix, 'projects')

so, my tool should usually know where this directory is on a local machine.

But, as mentioned earlier, it makes much sense to have "projects" (and
its contained data files) installed instead to another location, e.g.
user home or D:\ etc. - of course this should work on any platform with
Python and distutils.

I already learned, that user's can alter where setup distributes
specific parts, such as the data_files with the --install-data option,
see alternate installation
http://www.python.org/doc/2.4.4/inst...l-windows.html
or custom installation http://www.python.org/doc/2.4.4/inst/search-path.html

I think, this is reasonable for any user. But what do I need to do, to
provide OSPDIR with this particular --install-data path applied by the
user? Can I use OptionParser module (as I already do for my tools) in
the setup.py which checks, if this option is given, and eventually which
value it has, and somehow putting it dynamically into the OSPDIR variable?

a) Is --install-data the only way for users to customize path to data_files?
b) Am I right to parse --install-data in setup.py and change OSPDIR
variable on the fly?
c) If yes, how do I add this to my setup.py? It currently has only a
setup() call with plenty of arguments (no weired stuff, though). Do I
need to put this verifcation before or after setup() or is there any
callback or hook to use?

Many thanks for your support,
Anastasios
Mar 7 '07 #1
0 1193

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

Similar topics

5
by: Christian Seberino | last post by:
I have a setup.py with something like this: import glob .... setup( ..., ..., data_files =
8
by: Johan Svedberg | last post by:
Hi! I just started playing around with Distutils and there is one thing I could use some help with. I'm wondering if there is some convenient way to access the directories where the data_files...
0
by: Jorge Godoy | last post by:
Hi! For the following setup.py, I get this error: byte-compiling /var/tmp/bhsys-buildroot/usr/lib/python2.3/site-packages/bhsys/Impressao.py to Impressao.pyc byte-compiling...
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: ...
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...
7
by: Frans Englich | last post by:
This is silly. How do I access data files I've installed with distutils? In a portable, generic way, I want to find out what is the following path on most systems: ...
0
by: Saketh | last post by:
I'm having trouble getting the data_files argument of my setup.py to work with "python setup.py sdist" under Windows XP. Here is the data_files argument that I pass to setup(). data_files = , )...
7
by: Eric S. Johansson | last post by:
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...
0
by: Torsten Bronger | last post by:
Hallöchen! I try to distribute a Python application with i18n files (.mo). My setup.py says: .... data_files = )], packages = , package_dir = {'felo': 'src'},
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
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...

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.