If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Importing / packages

I'm trying to build libglib on Windows. I realise there are pre-built versions available but I'm trying to figure out how to build everything - including the various Python and Perl scripts. I've mastered everything except for the Python script called gdbus-codegen.py, which looks like this (after I've inserted a couple of paths that are relevant to my particular system):-

Code:

#! E:/Program Files/Python31/python.exe
# GDBus - GLib D-Bus Library
#
# Copyright (C) 2008-2011 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General
# Public License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307, USA.
#
# Author: David Zeuthen <davidz@redhat.com>
import os
import sys
srcdir = os.getenv('UNINSTALLED_GLIB_SRCDIR', None)
if srcdir is not None:
path = os.path.join(srcdir, 'gio', 'gdbus-2.0')
elif os.name == 'nt':
# Makes gdbus-codegen 'relocatable' at runtime on Windows.
path = os.path.join(os.path.dirname(__file__), '..', 'lib', 'gdbus-2.0')
else:
path = os.path.join('F:/+GTK-SOURCES/gnu-win32/src/glib/gio/', 'glib-2.0')
sys.path.insert(0, os.path.abspath(path))
from codegen import codegen_main
sys.exit(codegen_main.codegen_main())

Whenever I try to run this script I get an error at line 39. That's the line that reads:-

Code:

from codegen import codegen_main

and the error that I see is:-

ValueError: Attempted relative import in non-package

Various things have been suggested to me. One is to check that the directory containing gdbus-codegen.py contains a file called __init__.py (which it does). This apparently marks the directory as a 'package' which allows things to get imported from it. I was also advised to try running python -m, passing the relevant folder (which declares it as a package) but I couldn't figure out the proper syntax. Mostly I kept getting the error Import by filename is not supported. Finally, I was advised to change:-

from codegen import codegen_main

and just use this instead:-

import codegen_main

but that didn't help either.

I've tried Python 2.7 and Python 3.1 and have now completely run out of ideas. Is it possible that importing just isn't supported on Windows