Discussion:
sync-engine default config.xml location
Iain Buchanan
2008-03-17 04:01:28 UTC
Permalink
Hi,

just looking through the sync-engine code to tweak the gentoo package,
and I came across this in config.py:

# check if we have a config

self.config_dir = os.path.join(os.path.expanduser("~"), ".synce")
self.config_path = os.path.join(self.config_dir, "config.xml")

if not os.path.exists(self.config_path):
if not os.path.isdir(self.config_dir):
os.mkdir(self.config_dir)
oldconf = os.path.join(self.sepath,"config/config.xml")
shutil.copy(oldconf, self.config_path)

so if config.xml doesn't exist in ~/.synce it is copied from
"self.sepath". The only problem is self.sepath is set to
"/usr/lib/python2.5/site-packages" a few lines earlier, so the default
config.xml would have to be installed into
"/usr/lib/python2.5/site-packages/config/config.xml"

Is that right? I couldn't find any other reference to config.xml.
Shouldn't it go into
"/usr/lib/python2.5/site-packages/SyncEngine/config/config.xml"
or /usr/share or something instead?

thanks,
--
Iain Buchanan <iaindb at netspace dot net dot au>

It was the Law of the Sea, they said. Civilization ends at the waterline.
Beyond that, we all enter the food chain, and not always right at the top.
-- Hunter S. Thompson
John Carr
2008-03-17 10:43:29 UTC
Permalink
Post by Iain Buchanan
Is that right? I couldn't find any other reference to config.xml.
Shouldn't it go into
"/usr/lib/python2.5/site-packages/SyncEngine/config/config.xml"
or /usr/share or something instead?
thanks,
--
Iain Buchanan <iaindb at netspace dot net dot au>
I noticed yesterday a user in IRC (#opensync IIRC) claiming his
opensync plugins were in site-packages/plugins, I would have expected
site-packages/SyncEngine/plugins or something, but not what he had...
I think he was on Gentoo.. I think something is dropping the
SyncEngine part ?

John
Iain Buchanan
2008-03-18 23:07:02 UTC
Permalink
Any comments from Dr. J A Gow?
Hi again
Post by Iain Buchanan
os.mkdir(self.config_dir)
oldconf = os.path.join(self.sepath,"config/config.xml")
shutil.copy(oldconf, self.config_path)
Remove this block all together. Reading UpdateConfig(), you see that
sync-engine will still run just fine without the config file. If you
look at the GlobalConfig object and self.cfg, it already has sane
defaults.
thanks,
--
Iain Buchanan <iaindb at netspace dot net dot au>

To have died once is enough.
-- Publius Vergilius Maro (Virgil)
Dr J A Gow
2008-03-29 17:04:36 UTC
Permalink
Post by Iain Buchanan
Any comments from Dr. J A Gow?
Hi again
Post by Iain Buchanan
os.mkdir(self.config_dir)
oldconf = os.path.join(self.sepath,"config/config.xml")
shutil.copy(oldconf, self.config_path)
Remove this block all together. Reading UpdateConfig(), you see that
sync-engine will still run just fine without the config file. If you
look at the GlobalConfig object and self.cfg, it already has sane
defaults.
When I first introduced the config.xml into sync-engine I arranged that
sync-engine could indeed run fine without a config.xml to ensure
backwards-compatibility. It will indeed use sane defaults.

I added the code above later on. Firstly, it ensures that a virgin
installation will always place a default config.xml in the right place.
The default config.xml contains comments describing each element, and
its presence would help users who could simply open and read the file to
discover what can be tweaked and why. If the file is not there, then
those users who can not/do not have time to hunt through other docs may
not be aware of its existence. Secondly, packages can install a base
(default) config.xml into a location from which sync-engine can copy
each time a user starts sync-engine for the first time, or from which it
can be (re)copied should a user trash their config.xml.

There is no fundamental problem with this architecture, except that
packagers do not seem to know where to put the default config.xml! I
placed it in a directory off the root of sync-engine - if this is not
appropriate for packagers it can be moved with only minor code changes.

John.
Dr J A Gow
2008-03-19 11:19:16 UTC
Permalink
Post by Iain Buchanan
Hi,
just looking through the sync-engine code to tweak the gentoo package,
# check if we have a config
self.config_dir = os.path.join(os.path.expanduser("~"), ".synce")
self.config_path = os.path.join(self.config_dir, "config.xml")
os.mkdir(self.config_dir)
oldconf = os.path.join(self.sepath,"config/config.xml")
shutil.copy(oldconf, self.config_path)
so if config.xml doesn't exist in ~/.synce it is copied from
"self.sepath". The only problem is self.sepath is set to
"/usr/lib/python2.5/site-packages" a few lines earlier, so the default
config.xml would have to be installed into
"/usr/lib/python2.5/site-packages/config/config.xml"
I can't speak for the packages, but the SVN version acquires the path
from the following statement. The path is not harcoded:

# Now, get our current path (this may be useful)
# Avoids messing about with having to pull a PREFIX from
# an installer

self.sepath = str(xml2util).split()[3][1:-2]
self.sepath = os.path.dirname(self.sepath)
self.sepath = os.path.dirname(self.sepath)


This acquires the SyncEngine root from the location of xml2util.py. This
should be the root of the SyncEngine archive. The path to config.xml is
then constructed.

Therefore 'sepath' should be set to the root of the sync-engine install.

I wonder if it is the way in which the package is being installed: if
the entire sync-engine tree is dumped
in /usr/lib/python2.5/site-packages then I would indeed expect sepath to
be set to /usr/lib/python2.5/site-packages.


John.
Iain Buchanan
2008-03-20 06:57:46 UTC
Permalink
Hi,
Post by Dr J A Gow
Post by Iain Buchanan
Hi,
just looking through the sync-engine code to tweak the gentoo package,
[snip]
Post by Dr J A Gow
Post by Iain Buchanan
so if config.xml doesn't exist in ~/.synce it is copied from
"self.sepath". The only problem is self.sepath is set to
"/usr/lib/python2.5/site-packages" a few lines earlier, so the default
config.xml would have to be installed into
"/usr/lib/python2.5/site-packages/config/config.xml"
I can't speak for the packages, but the SVN version acquires the path
# Now, get our current path (this may be useful)
# Avoids messing about with having to pull a PREFIX from
# an installer
self.sepath = str(xml2util).split()[3][1:-2]
self.sepath = os.path.dirname(self.sepath)
self.sepath = os.path.dirname(self.sepath)
this is the same as my installed sync-engine. If I put this line of
code after each of those lines:
print "self.sepath = %s" % self.sepath
Then the output is:
self.sepath = /usr/lib/python2.5/site-packages/SyncEngine/xml2util.py
self.sepath = /usr/lib/python2.5/site-packages/SyncEngine
self.sepath = /usr/lib/python2.5/site-packages
Post by Dr J A Gow
This acquires the SyncEngine root from the location of xml2util.py. This
should be the root of the SyncEngine archive. The path to config.xml is
then constructed.
Just an addendum to my previous message - this is actually correct in
what it is doing. The sync-engine root is one level below
'SyncEngine' (check the tree out from SVN to see what I mean).
one level below? Could you perhaps show me the output from your
sync-engine with the one-liner I added above?

thanks,
--
Iain Buchanan <iaindb at netspace dot net dot au>

A man who persists in stalking game in a place where there is none may wait
forever without finding any success. Persistence in search is not enough.

-- Zensunni Wisdom of the Wanderings
Dr J A Gow
2008-03-20 21:14:21 UTC
Permalink
Post by Iain Buchanan
this is the same as my installed sync-engine. If I put this line of
print "self.sepath = %s" % self.sepath
self.sepath = /usr/lib/python2.5/site-packages/SyncEngine/xml2util.py
self.sepath = /usr/lib/python2.5/site-packages/SyncEngine
self.sepath = /usr/lib/python2.5/site-packages
This looks correct. In the case here, this indicates that the packages
are dumping the contents of the sync-engine root
into /usr/lib/python2.5/site-packages
Post by Iain Buchanan
Post by Dr J A Gow
This acquires the SyncEngine root from the location of xml2util.py. This
should be the root of the SyncEngine archive. The path to config.xml is
then constructed.
Just an addendum to my previous message - this is actually correct in
what it is doing. The sync-engine root is one level below
'SyncEngine' (check the tree out from SVN to see what I mean).
one level below? Could you perhaps show me the output from your
sync-engine with the one-liner I added above?
It probably won't help you because I don't run packages - I run
sync-engine from the development tree - but I would have got, before my
development disk ate itself last night (always guaranteed to happen
before a long holiday when I can't get another one):


/scratchpad/software-builds/synce/sync-engine/SyncEngine/xml2util.py
/scratchpad/software-builds/synce/sync-engine/SyncEngine
/scratchpad/software-builds/synce/sync-engine

Note that the default config should be in:

/scratchpad/software-builds/synce/sync-engine/config.


So the problem seems to be how the packaging is being carried out.

John.
Iain Buchanan
2008-03-21 04:12:01 UTC
Permalink
Hi all,

could someone who packages sync-engine for something other than Gentoo
please apply this one-line patch
to /usr/lib/python2.5/site-packages/SyncEngine/config.py (or where
Post by Dr J A Gow
self.sepath = str(xml2util).split()[3][1:-2]
self.sepath = os.path.dirname(self.sepath)
self.sepath = os.path.dirname(self.sepath)
print "self.sepath = %s" % self.sepath
self.sepath = /usr/lib/python2.5/site-packages/SyncEngine/xml2util.py
self.sepath = /usr/lib/python2.5/site-packages/SyncEngine
self.sepath = /usr/lib/python2.5/site-packages
My intention is to see if this is a Gentoo packaging thing I'm doing
wrong, or general python install behaviour.

Any tips to how python packages are installed would also be welcome :)

thanks,
--
Iain Buchanan <iaindb at netspace dot net dot au>

Only someone with nothing to be sorry for smiles back at the rear of an
elephant.
Mark Ellis
2008-03-25 17:00:59 UTC
Permalink
Post by Iain Buchanan
Hi all,
could someone who packages sync-engine for something other than Gentoo
please apply this one-line patch
to /usr/lib/python2.5/site-packages/SyncEngine/config.py (or where
Post by Dr J A Gow
self.sepath = str(xml2util).split()[3][1:-2]
self.sepath = os.path.dirname(self.sepath)
self.sepath = os.path.dirname(self.sepath)
print "self.sepath = %s" % self.sepath
self.sepath = /usr/lib/python2.5/site-packages/SyncEngine/xml2util.py
self.sepath = /usr/lib/python2.5/site-packages/SyncEngine
self.sepath = /usr/lib/python2.5/site-packages
My intention is to see if this is a Gentoo packaging thing I'm doing
wrong, or general python install behaviour.
Any tips to how python packages are installed would also be welcome :)
thanks,
Hi Iain

I had a bit of fun when I made a deb of sync-engine too. I'll gloss over
some of it, since debian policy uses particular things like pycentral or
python-support.

I get the equivalent of what you get, in site-packages.

For the base config, I installed config.xml in site-packages/SyncEngine,
dropped the third of the above lines so self.sepath refers to this dir,
and further on changed config/config.xml to just config.xml. I did this
because it seemed inappropriate to have a file called config.xml in
site-packages.

I think it would still be better in /usr/share/sync-engine or something.

I also put authcli and authgui in site-packages/SyncEngine, and changed
the path in auth.py

Hope this helps

Mark
Guido Diepen
2008-03-25 17:23:00 UTC
Permalink
Hi,
Post by Mark Ellis
For the base config, I installed config.xml in site-packages/SyncEngine,
dropped the third of the above lines so self.sepath refers to this dir,
and further on changed config/config.xml to just config.xml. I did this
because it seemed inappropriate to have a file called config.xml in
site-packages.
I think it would still be better in /usr/share/sync-engine or something.
But everything that is under the site-packages directory is perfectly
accessable from within the python script. You can figure out the location of
your module and then get the right path for your config.xml file.

If you create it in /usr/share/sync-engine, you have the probem of accessing
it in your code (without hardcoding, because what if the program was
installed with different prefix the /usr ).

I have had the same problem when I was figuring out where to put the data
files of synce-kpm. The problem is that I don't know of any way that you can
change locations (i.e. update prefixes) of your python files from within the
setup.py.

Guido Diepen
Post by Mark Ellis
I also put authcli and authgui in site-packages/SyncEngine, and changed
the path in auth.py
Hope this helps
Mark
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
SynCE-Devel mailing list
https://lists.sourceforge.net/lists/listinfo/synce-devel
--
Aviation is proof that given the will, we have the
capacity to achieve the impossible.
--Eddie Rickenbacker
Mark Ellis
2008-03-25 17:24:33 UTC
Permalink
Post by Guido Diepen
Hi,
Post by Mark Ellis
For the base config, I installed config.xml in site-packages/SyncEngine,
dropped the third of the above lines so self.sepath refers to this dir,
and further on changed config/config.xml to just config.xml. I did this
because it seemed inappropriate to have a file called config.xml in
site-packages.
I think it would still be better in /usr/share/sync-engine or something.
But everything that is under the site-packages directory is perfectly
accessable from within the python script. You can figure out the location of
your module and then get the right path for your config.xml file.
If you create it in /usr/share/sync-engine, you have the probem of accessing
it in your code (without hardcoding, because what if the program was
installed with different prefix the /usr ).
I have had the same problem when I was figuring out where to put the data
files of synce-kpm. The problem is that I don't know of any way that you can
change locations (i.e. update prefixes) of your python files from within the
setup.py.
Guido Diepen
Not being very good at python I won't comment about how to do it :)

But I agree, if it did go somewhere outside the python tree it should be
left to packagers to patch it for the distro. In my deb I can happily
hardcode a path because that is where it is in that distro.

Mark
Dr J A Gow
2008-03-30 18:12:09 UTC
Permalink
Post by Guido Diepen
Hi,
Post by Mark Ellis
For the base config, I installed config.xml in site-packages/SyncEngine,
dropped the third of the above lines so self.sepath refers to this dir,
and further on changed config/config.xml to just config.xml. I did this
because it seemed inappropriate to have a file called config.xml in
site-packages.
I think it would still be better in /usr/share/sync-engine or something.
But everything that is under the site-packages directory is perfectly
accessable from within the python script. You can figure out the location of
your module and then get the right path for your config.xml file.
If you create it in /usr/share/sync-engine, you have the probem of accessing
it in your code (without hardcoding, because what if the program was
installed with different prefix the /usr ).
I really don't like stuffing the config file (data etc) in the same dir
as the executables - I prefer to encapsulate the executables. Personally
I would prefer to see it in somewhere like /usr/share/sync-engine. Is
there something out there for python trees like pkgconfig - or can one
easily access pkgconfig from python? That way we can easily find the
prefix - and no more problems with hardcoding? I'll have a look.

John.

Dr J A Gow
2008-03-19 12:23:29 UTC
Permalink
Post by Iain Buchanan
Hi,
just looking through the sync-engine code to tweak the gentoo package,
# check if we have a config
self.config_dir = os.path.join(os.path.expanduser("~"), ".synce")
self.config_path = os.path.join(self.config_dir, "config.xml")
os.mkdir(self.config_dir)
oldconf = os.path.join(self.sepath,"config/config.xml")
shutil.copy(oldconf, self.config_path)
so if config.xml doesn't exist in ~/.synce it is copied from
"self.sepath". The only problem is self.sepath is set to
"/usr/lib/python2.5/site-packages" a few lines earlier, so the default
config.xml would have to be installed into
"/usr/lib/python2.5/site-packages/config/config.xml"
Is that right? I couldn't find any other reference to config.xml.
Just an addendum to my previous message - this is actually correct in
what it is doing. The sync-engine root is one level below
'SyncEngine' (check the tree out from SVN to see what I mean). I can
only assume that the package manager is installing the entire
sync-engine tree to /usr/lib/python2.5/site-packages. If this is the
case, the sync-engine root is the same
as /usr/lib/python2.5/site-packages and the above behaviour is to be
expected.

If packagers need the directory structure of sync-engine changing to
make life easier, please let me know. I avoid getting involved in
packaging so I am not sure where the problems are.

John.
Loading...