python: help defining/installing simple script to setup machine-specific information
Posted
by Jason S
on Stack Overflow
See other posts from Stack Overflow
or by Jason S
Published on 2010-05-17T17:06:41Z
Indexed on
2010/05/17
17:10 UTC
Read the original article
Hit count: 305
python
(This is related to scons
but I think most of the following should be fairly general to python)
I would like to define a python file/library that I put in a Well-Known Place somewhere on my computer that I can use to define machine-specific paths, and was looking for help on how to do this well, since I'm a beginner to Python & really only use it for my scons work.
scons uses a SConstruct file which can execute python code. What I would like to do is something like this:
My SConstruct file would contain this at the beginning:
defaultEnv = JJJJJ.getMachineSpecificPaths()
or (do both of these syntaxes work?)
import JJJJJ defaultEnv = getMachineSpecificPaths()
I define a
JJJJJ.py
file somewhere installed in the python dir which contains the followingdef getMachineSpecificPaths(): ... does something here, I don't know what ...
that reads a file
machine-specific-paths.txt
(maybe it has the code Ross Rogers mentioned in my other question) located in the same directory as JJJJJ.py containing the following:machine-specific-paths.txt
TI_C28_ROOT C:/appl/ti/ccs/?4.1.1/ccsv4/tools/co?mpiler/c2000 JSDB c:/bin/jsdb/jsdb.exe PYTHON_PATH c:/appl/python/2.6.4
The thing is, I don't really know much about the conventions in Python about where you put system-wide libraries and files. This is probably really simple to get right but I don't know how.
© Stack Overflow or respective owner