Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#32306 closed defect (fixed)

glib2, glib2-devel: build fails when "python" is not 2.5 thru 2.7

Reported by: gotyaoi@… Owned by: ryandesign (Ryan Carsten Schmidt)
Priority: Normal Milestone:
Component: ports Version: 2.0.3
Keywords: Cc: gale@…, v.rajagopal@…, jpmasseria@…
Port: glib2, glib2-devel

Description (last modified by mf2k (Frank Schima))

Specifically, it fails build when something that isn't python26 is set as the default using

port select --set python {not python26}

I had it set to python32, and was getting this godawful stacktrace. Unfortunately, I can't post my log as when it built right, the log vanished. The problem is that it's calling

/opt/local/bin/python

to run its tests, which in this case is a symlink to whatever you selected to be the default. python32 in my case, which is absolutely not what it was expecting. When it got set to python26 with

port select --set python python26

everything worked fine.

Change History (12)

comment:1 Changed 13 years ago by mf2k (Frank Schima)

Description: modified (diff)
Keywords: python removed
Owner: changed from macports-tickets@… to ryandesign@…

comment:2 Changed 13 years ago by ryandesign (Ryan Carsten Schmidt)

Port: glib2-devel added
Status: newassigned
Summary: glib2 fails buildglib2, glib2-devel: build fails when "python" is not 2.5 thru 2.7

I also got a curious error along the lines of "python2.5: file not found" on Tiger, until I installed python25. I'm going to assume Tiger comes with an older version of python than that, and that any versions 2.5 through 2.7 would be ok. But yes. glib2 needs to ensure it's using a compatible python.

comment:3 Changed 13 years ago by gale@…

I am stuck on this one too. Here are some details:

I am on Mac OS X 10.6.8 on an Intel MacBook. I am trying to upgrade:

glib2 2.28.8_0 < 2.30.2_1

I get the following error:

Making all in tests
make[4]: Entering directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_glib2/glib2/work/glib-2.30.2/gio/tests'

...


UNINSTALLED_GLIB_SRCDIR=../.. \
		UNINSTALLED_GLIB_BUILDDIR=../.. \
		/opt/local/bin/python ../../gio/gdbus-2.0/codegen/gdbus-codegen \
		--interface-prefix org.project. \
		--generate-c-code gdbus-test-codegen-generated \
		--c-generate-object-manager \
		--c-namespace Foo_iGen \
		--generate-docbook gdbus-test-codegen-generated-doc \
		--annotate "org.project.Bar" Key1 Value1 \
		--annotate "org.project.Bar" org.gtk.GDBus.Internal Value2 \
		--annotate "org.project.Bar.HelloWorld()" Key3 Value3 \
		--annotate "org.project.Bar::TestSignal" Key4 Value4 \
		--annotate "org.project.Bar:ay" Key5 Value5 \
		--annotate "org.project.Bar.TestPrimitiveTypes()[val_int32]" Key6 Value6 \
		--annotate "org.project.Bar.TestPrimitiveTypes()[ret_uint32]" Key7 Value7 \
		--annotate "org.project.Bar::TestSignal[array_of_strings]" Key8 Value8 \
		./test-codegen.xml \
		
Traceback (most recent call last):
  File "../../gio/gdbus-2.0/codegen/gdbus-codegen", line 41, in <module>
    sys.exit(codegen_main.codegen_main())
  File "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_glib2/glib2/work/glib-2.30.2/gio/gdbus-2.0/codegen/codegen_main.py", line 171, in codegen_main
    parsed_ifaces = parser.parse_dbus_xml(xml_data)
  File "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_glib2/glib2/work/glib-2.30.2/gio/gdbus-2.0/codegen/parser.py", line 289, in parse_dbus_xml
    parser = DBusXMLParser(xml_data)
  File "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_glib2/glib2/work/glib-2.30.2/gio/gdbus-2.0/codegen/parser.py", line 57, in __init__
    self._parser.Parse(xml_data)
  File "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_glib2/glib2/work/glib-2.30.2/gio/gdbus-2.0/codegen/parser.py", line 155, in handle_start_element
    if attrs.has_key('name') and self.doc_comment_last_symbol == attrs['name']:
AttributeError: 'dict' object has no attribute 'has_key'

Note that the syntax

attrs.has_key('name')

is an old synonym for

'name' in attrs

that was removed in Python 3.

So this particular error is easy to fix. But I'm not sure how easy it would be to go through the python code in glib2 ourselves and ensure that it is all compatible with Python 3. That's a job for upstream.

The real issue is that since this port does still require Python 2 only, we need to make sure that is what it uses. (And we need a dependency to make sure that we actually have an appropriate version of Python around somewhere.)

We have run across this issue for a number of other ports. This one is pretty important though, because glib2 is a direct or indirect dependency for many, many ports.

Thanks!

comment:4 Changed 13 years ago by gale@…

Cc: gale@… added

Cc Me!

comment:5 in reply to:  3 ; Changed 13 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to gale@…:

I am stuck on this one too.

You shouldn't be stuck on anything. The workaround is to use "sudo port select python" to select a version of python between 2.5 and 2.7. After glib2 is installed, you can re-select whatever other version of python you usually prefer.

So this particular error is easy to fix. But I'm not sure how easy it would be to go through the python code in glib2 ourselves and ensure that it is all compatible with Python 3. That's a job for upstream.

Right. I have no interest in learning python nor in fixing glib2's code for them.

The real issue is that since this port does still require Python 2 only, we need to make sure that is what it uses.

Right, that is what I want to do.

(And we need a dependency to make sure that we actually have an appropriate version of Python around somewhere.)

In the spirit of the discussion A Plea to Reduce Dependences I would like to avoid adding a python dependency unless absolutely necessary (i.e. on Tiger), since, as you rightly say, "glib2 is a direct or indirect dependency for many, many ports" and I don't want to force everyone to have a python port installed that they might not otherwise need.

comment:6 Changed 13 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: v.rajagopal@… added

Has duplicate #32336.

comment:7 in reply to:  5 ; Changed 13 years ago by gale@…

Replying to ryandesign@…:

You shouldn't be stuck on anything. The workaround is...

I wasn't *that* stuck. :) Thanks for recording the workaround here explicitly, though. I'm sure it will help a lot of people.

...I would like to avoid adding a python dependency unless absolutely necessary (i.e. on Tiger)

Interesting idea. So you mean use the Mac OS X native python 2 for Leopard and up, I assume. But then what to do for Tiger? Build a special temporary python just for this build (and just for testing, it looks like)? Is there some way to depend on a python port just for Tiger?

Another idea is to have a port called something like "python2minimal" that just creates a symlink to /usr/bin/python for Leopard and up, and builds (or depends on) python 2.7 for Tiger and below.

comment:8 in reply to:  7 ; Changed 13 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to gale@…:

So you mean use the Mac OS X native python 2 for Leopard and up, I assume.

Yes. Probably:

configure.python /usr/bin/python

And then maybe some reinplacing somewhere to tell it to use that.

But then what to do for Tiger?

Add a dependency on python27 and tell it to use that python instead.

Is there some way to depend on a python port just for Tiger?

Sure:

platform darwin 8 {
    depends_lib-append port:python27
    configure.python ${prefix}/bin/python2.7
}

Another idea is to have a port called something like "python2minimal" that just creates a symlink to /usr/bin/python for Leopard and up,

No, we don't need anything that complicated. We just need to inform glib2 what python it should use.

comment:9 Changed 13 years ago by ryandesign (Ryan Carsten Schmidt)

Resolution: fixed
Status: assignedclosed

Confirmed this works on Snow Leopard when I have MacPorts python 3.1 selected, and on Tiger where the system python is version 2.3. Committed in r87671.

comment:10 in reply to:  8 ; Changed 13 years ago by gale@…

Replying to ryandesign@…:

Is there some way to depend on a python port just for Tiger?

Sure

Cool!

platform darwin 8 {
    depends_lib-append port:python27
    configure.python ${prefix}/bin/python2.7
}

Are you sure this is a lib-dep and not just a build-dep?

comment:11 in reply to:  10 Changed 13 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to gale@…:

Are you sure this is a lib-dep and not just a build-dep?

Yes; the programs gdbus-codegen and gtester-report which glib2 installs use python at runtime. See #17530.

comment:12 Changed 13 years ago by jpmasseria@…

Cc: jpmasseria@… added

Cc Me!

Note: See TracTickets for help on using tickets.