Go Back   ZeroC Forums > Bug Reports

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 06-07-2007
joshmoore joshmoore is offline
Registered User
 
Name: Josh Moore
Organization: Glencoe Software, Inc.
Project: OMERO, http://trac.openmicroscopy.org.uk/omero
 
Join Date: Feb 2007
Location: Germany
Posts: 59
Should slice2py --prefix update imports?

I'm having difficulties using the --prefix option to slice2py. The generated __init__.py files import the prefixed files (TEST_... below); but the modules themselves don't.

Code:
$ slice2py --output-dir=out -I. a.ice c.ice
$ PYTHONPATH=out:$ICE_HOME/python python2.4
Python 2.4.4 (#2, Apr 12 2007, 21:22:23) 
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import c
>>> c.d()
object #0 (::c::d)
{
}
>>> f = c.d()
>>> f.ice_ids()
('::Ice::Object', '::a::b', '::c::d')
>>> 
$ rm -rf out/*
$ slice2py --output-dir=out --prefix=TEST_ -I. a.ice c.ice
$ PYTHONPATH=out:$ICE_HOME/python python2.4
Python 2.4.4 (#2, Apr 12 2007, 21:22:23) 
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import c
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/home/josh/bug/out/c/__init__.py", line 4, in ?
    import TEST_c_ice
  File "/home/josh/bug/out/TEST_c_ice.py", line 14, in ?
    import a_ice
ImportError: No module named a_ice
>>>
$ ls -ltra out/
total 28K
drwxr-xr-x 3 josh josh 4.0K 2007-06-07 21:43 ..
-rw-r--r-- 1 josh josh 1.6K 2007-06-07 21:44 TEST_c_ice.py
-rw-r--r-- 1 josh josh 1.5K 2007-06-07 21:44 TEST_a_ice.py
drwxr-xr-x 2 josh josh 4.0K 2007-06-07 21:44 a
-rw-r--r-- 1 josh josh 2.0K 2007-06-07 21:45 TEST_c_ice.pyc
drwxr-xr-x 2 josh josh 4.0K 2007-06-07 21:45 c
drwxr-xr-x 4 josh josh 4.0K 2007-06-07 21:45 .
$ head -n 20 out/TEST_c_ice.py
# **********************************************************************
#
# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved.
#
# This copy of Ice is licensed to you under the terms described in the
# ICE_LICENSE file included in this distribution.
#
# **********************************************************************

# Ice version 3.2.0
# Generated from file `c.ice'

import Ice, IcePy, __builtin__
import a_ice
Reply With Quote
  #2 (permalink)  
Old 06-07-2007
mes's Avatar
mes mes is offline
ZeroC Staff
 
Name: Mark Spruiell
Organization: ZeroC, Inc.
Project: Ice Developer
 
Join Date: Feb 2003
Location: California
Posts: 971
Hi Josh,

As you have seen, specifying the --prefix option does not influence the import statements that correspond to #include statements in your Slice file. In the example you provided, I presume that c.ice contains the statement

#include <a.ice>

slice2py translates that directive into the following import statement:

import a_ice

As explained in Section 22.15.2 of the Ice manual, you have to carefully plan your use of the --prefix option and #include directives. The solution for your example is to modify the #include directive in c.ice as follows:

#include <TEST/a.ice>

This will cause the translator to emit the following statement:

import TEST_a_ice

Naturally, this also means you have to create a subdirectory named TEST and place a.ice inside it.

One way to learn more about this subject is to examine the way we do it for Ice for Python; in particular, have a look at python/Makefile.

Hope that helps,
- Mark
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can Ice3.1.1-VC60 support slice2py? yuntinghill Help Center 1 12-08-2006 04:10 AM
Please, update FSF address at ICE_LICENSE fmoya Bug Reports 1 11-06-2006 06:00 PM
Where is slice2py? flytod Help Center 3 10-16-2006 07:48 AM
Python: #include/import problem with slice2py hiasl Bug Reports 1 02-21-2006 10:59 AM
Ice 2.1.2 update to 3.0 in FC3 ?? surfer Help Center 1 11-18-2005 09:14 AM


All times are GMT -4. The time now is 08:26 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.