Opened 10 years ago

Closed 4 years ago

#44954 closed defect (worksforme)

poppler, gobject-introspection: AttributeError: 'module' object has no attribute 'mkstemp'

Reported by: john.m.harrold@… Owned by: dbevans (David B. Evans)
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: ryandesign (Ryan Carsten Schmidt)
Port: poppler

Description

I'm trying to build the port for poppler and I keep getting errors. I did a self update thinking that might be the cause of my troubles but I got the same error below.

/opt/local/bin/g-ir-scanner  --add-include-path=. --warn-all --namespace=Poppler --nsversion=0.18 --libtool="/bin/sh ../libtool"  --include=GObject-2.0 --include=Gio-2.0 --include=cairo-1.0 --pkg-export=poppler-glib  --library=libpoppler-glib.la --c-include poppler.h --cflags-begin -DG_LOG_DOMAIN=\"Poppler\" -I.. -I../poppler -D_REENTRANT -I/opt/local/include/cairo -I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include -I/opt/local/include -I/opt/local/include/pixman-1 -I/opt/local/include -I/opt/local/include/freetype2 -I/opt/local/include -I/opt/local/include/freetype2 -I/opt/local/include/libpng16 -I/opt/local/include  -I/opt/local/include/freetype2  -DG_DISABLE_DEPRECATED -DG_DISABLE_SINGLE_INCLUDES -I.. --cflags-end  poppler-enums.c poppler-enums.h poppler-action.cc poppler-date.cc poppler-document.cc poppler-page.cc poppler-attachment.cc poppler-form-field.cc poppler-annot.cc poppler-layer.cc poppler-media.cc poppler-movie.cc poppler-cached-file-loader.cc poppler-cached-file-loader.h poppler-input-stream.cc poppler-structure-element.cc poppler.cc poppler-action.h poppler-date.h poppler-document.h poppler-page.h poppler-attachment.h poppler-form-field.h poppler-annot.h poppler-layer.h poppler-media.h poppler-movie.h poppler-structure-element.h poppler.h poppler-features.h libpoppler-glib.la --output Poppler-0.18.gir
Traceback (most recent call last):
  File "/opt/local/bin/g-ir-scanner", line 44, in <module>
    from giscanner.scannermain import scanner_main
  File "/opt/local/lib/gobject-introspection/giscanner/scannermain.py", line 29, in <module>
    import tempfile
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/tempfile.py", line 35, in <module>
    from random import Random as _Random
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/random.py", line 49, in <module>
    import hashlib as _hashlib
  File "build/bdist.macosx-10.8-intel/egg/hashlib.py", line 105, in <module>
    
  File "build/bdist.macosx-10.8-intel/egg/_hashlib.py", line 7, in <module>
  File "build/bdist.macosx-10.8-intel/egg/_hashlib.py", line 4, in __bootstrap__
  File "build/bdist.macosx-10.8-intel/egg/pkg_resources.py", line 954, in resource_filename
    self, resource_name
  File "build/bdist.macosx-10.8-intel/egg/pkg_resources.py", line 1647, in get_resource_filename
    zip_path = self._resource_to_zip(resource_name)
  File "build/bdist.macosx-10.8-intel/egg/pkg_resources.py", line 1683, in _extract_resource
    
  File "build/bdist.macosx-10.8-intel/egg/pkg_resources.py", line 2857, in _mkstemp
    old_open = os.open
AttributeError: 'module' object has no attribute 'mkstemp'
make[4]: *** [Poppler-0.18.gir] Error 1
make[4]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_distfiles.macports.org_ports_graphics_poppler/poppler/work/poppler-0.26.4/glib'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_distfiles.macports.org_ports_graphics_poppler/poppler/work/poppler-0.26.4/glib'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_distfiles.macports.org_ports_graphics_poppler/poppler/work/poppler-0.26.4/glib'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_distfiles.macports.org_ports_graphics_poppler/poppler/work/poppler-0.26.4'
make: *** [all] Error 2
make: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_distfiles.macports.org_ports_graphics_poppler/poppler/work/poppler-0.26.4'
Command failed:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_distfiles.macports.org_ports_graphics_poppler/poppler/work/poppler-0.26.4" && /usr/bin/make -j8 -w all CC="/usr/bin/clang -arch x86_64" 
Exit code: 2
Error: org.macports.build for port poppler returned: command execution failed
DEBUG: Error code: CHILDSTATUS 63406 2
DEBUG: Backtrace: command execution failed
    while executing
"system -nice 0 $fullcmdstring"
    ("eval" body line 1)
    invoked from within
"eval system $notty $nice \$fullcmdstring"
    invoked from within
"command_exec build"
    (procedure "portbuild::build_main" line 8)
    invoked from within
"portbuild::build_main org.macports.build"
    ("eval" body line 1)
    invoked from within
"eval $procedure $targetname"
Warning: targets not executed for poppler: org.macports.activate org.macports.build org.macports.destroot org.macports.install
Please see the log file for port poppler for details:
    /opt/local/var/macports/logs/_opt_local_var_macports_sources_distfiles.macports.org_ports_graphics_poppler/poppler/main.log
To report a bug, follow the instructions in the guide:
    http://guide.macports.org/#project.tickets
Error: Processing of port poppler failed

Attachments (3)

main.log (23.2 KB) - added by john.m.harrold@… 10 years ago.
poppler_main.log
main.2.log (428.6 KB) - added by john.m.harrold@… 10 years ago.
poppler_main_clean.log
main.3.log (271.3 KB) - added by john.m.harrold@… 10 years ago.
go-main.log

Download all attachments as: .zip

Change History (15)

Changed 10 years ago by john.m.harrold@…

Attachment: main.log added

poppler_main.log

comment:1 Changed 10 years ago by dbevans (David B. Evans)

Owner: changed from macports-tickets@… to devans@…
Status: newassigned

comment:2 Changed 10 years ago by dbevans (David B. Evans)

Port: poppler added
Version: 2.3.1

Please fill in ticket Portfield and copy maintainer for faster response. Thanks.

comment:3 Changed 10 years ago by dbevans (David B. Evans)

I'm looking at this, but the attached log file is not from a clean build so is not very informative. Please attach an updated main.log generated by the following commands

sudo port clean poppler
sudo port build poppler

comment:4 Changed 10 years ago by dbevans (David B. Evans)

I can't replicate your results building on Mavericks (10.9). The equivalent lines from my build log are:

/opt/local/bin/g-ir-scanner  --add-include-path=. --warn-all --namespace=Poppler --nsversion=0.18 --libtool="/bin/sh ../libtool"  --include=GObject-2.0 --include=Gio-2.0 --include=cairo-1.0 --pkg-export=poppler-glib  --library=libpoppler-glib.la --c-include poppler.h --cflags-begin -DG_LOG_DOMAIN=\"Poppler\" -I.. -I../poppler -D_REENTRANT -I/opt/local/include/cairo -I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include -I/opt/local/include -I/opt/local/include/pixman-1 -I/opt/local/include -I/opt/local/include/freetype2 -I/opt/local/include -I/opt/local/include/freetype2 -I/opt/local/include/libpng16 -I/opt/local/include  -I/opt/local/include/freetype2  -DG_DISABLE_DEPRECATED -DG_DISABLE_SINGLE_INCLUDES -I.. --cflags-end  poppler-enums.c poppler-enums.h poppler-action.cc poppler-date.cc poppler-document.cc poppler-page.cc poppler-attachment.cc poppler-form-field.cc poppler-annot.cc poppler-layer.cc poppler-media.cc poppler-movie.cc poppler-cached-file-loader.cc poppler-cached-file-loader.h poppler-input-stream.cc poppler-structure-element.cc poppler.cc poppler-action.h poppler-date.h poppler-document.h poppler-page.h poppler-attachment.h poppler-form-field.h poppler-annot.h poppler-layer.h poppler-media.h poppler-movie.h poppler-structure-element.h poppler.h poppler-features.h libpoppler-glib.la --output Poppler-0.18.gir
g-ir-scanner: compile: /usr/bin/clang -arch x86_64 -Wno-deprecated-declarations -D_REENTRANT -I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include -I/opt/local/include -I/opt/local/include/gio-unix-2.0 -I/opt/local/include/cairo -I/opt/local/include/pixman-1 -I/opt/local/include -I/opt/local/include/freetype2 -I/opt/local/include -I/opt/local/include/freetype2 -I/opt/local/include/libpng16 -I/opt/local/include -I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include -I/opt/local/include -c -o /opt/local/var/macports/build/_opt_macports_trunk_dports_graphics_poppler/poppler/work/poppler-0.26.4/glib/tmp-introspectLdKF2D/Poppler-0.18.o /opt/local/var/macports/build/_opt_macports_trunk_dports_graphics_poppler/poppler/work/poppler-0.26.4/glib/tmp-introspectLdKF2D/Poppler-0.18.c
g-ir-scanner: link: /bin/sh ../libtool --mode=link --tag=CC /usr/bin/clang -arch x86_64 -o /opt/local/var/macports/build/_opt_macports_trunk_dports_graphics_poppler/poppler/work/poppler-0.26.4/glib/tmp-introspectLdKF2D/Poppler-0.18 -export-dynamic /opt/local/var/macports/build/_opt_macports_trunk_dports_graphics_poppler/poppler/work/poppler-0.26.4/glib/tmp-introspectLdKF2D/Poppler-0.18.o -L. libpoppler-glib.la -L/opt/local/lib -lgio-2.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lintl
libtool: link: /usr/bin/clang -arch x86_64 -o /opt/local/var/macports/build/_opt_macports_trunk_dports_graphics_poppler/poppler/work/poppler-0.26.4/glib/tmp-introspectLdKF2D/.libs/Poppler-0.18 /opt/local/var/macports/build/_opt_macports_trunk_dports_graphics_poppler/poppler/work/poppler-0.26.4/glib/tmp-introspectLdKF2D/Poppler-0.18.o  -L. ./.libs/libpoppler-glib.dylib -L/opt/local/lib /opt/local/var/macports/build/_opt_macports_trunk_dports_graphics_poppler/poppler/work/poppler-0.26.4/poppler/.libs/libpoppler.dylib -llcms2 -ltiff -ljpeg -lpng16 -lcurl -lopenjpeg -lfontconfig -lcairo -lfreetype -lz -lgio-2.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lintl -pthread
clang: warning: argument unused during compilation: '-pthread'
/opt/local/bin/g-ir-compiler --includedir=. --includedir=. Poppler-0.18.gir -o Poppler-0.18.typelib
make[4]: Leaving directory `/opt/local/var/macports/build/_opt_macports_trunk_dports_graphics_poppler/poppler/work/poppler-0.26.4/glib'

I note that your error occurs in g-ir-scanner before it emits the appropriate compile or link commmands. You might want to rebuild gobject-introspection which provides this Python script to make sure all is well there.

Will test on ML (10.8) to see if that makes any difference.

comment:5 in reply to:  3 Changed 10 years ago by john.m.harrold@…

I did the clean and build.

jharrold:$  sudo port clean poppler
--->  Cleaning poppler
[~]
jharrold:$  sudo port build poppler
--->  Computing dependencies for poppler
--->  Fetching distfiles for poppler
--->  Verifying checksums for poppler
--->  Extracting poppler
--->  Configuring poppler
--->  Building poppler
Error: org.macports.build for port poppler returned: command execution failed
Please see the log file for port poppler for details:
    /opt/local/var/macports/logs/_opt_local_var_macports_sources_distfiles.macports.org_ports_graphics_poppler/poppler/main.log
To report a bug, follow the instructions in the guide:
    http://guide.macports.org/#project.tickets
Error: Processing of port poppler failed

I attached the main.log file (poppler_main_clean.log)

Last edited 10 years ago by john.m.harrold@… (previous) (diff)

Changed 10 years ago by john.m.harrold@…

Attachment: main.2.log added

poppler_main_clean.log

comment:6 in reply to:  4 ; Changed 10 years ago by john.m.harrold@…

I believe the way to rebuild a package is the following:

sudo port upgrade -n --force   gobject-introspection

The output from rebuilding gobject-introspection is below. This didn't seem to help (poppler still fails to compile).

--->  Fetching archive for gobject-introspection
--->  Attempting to fetch gobject-introspection-1.40.0_0.darwin_12.x86_64.tbz2 from http://packages.macports.org/gobject-introspection
--->  Attempting to fetch gobject-introspection-1.40.0_0.darwin_12.x86_64.tbz2.rmd160 from http://packages.macports.org/gobject-introspection
--->  Computing dependencies for gobject-introspection
--->  Unable to uninstall gobject-introspection @1.40.0_0, the following ports depend on it:
--->  	atk @2.8.0_0
--->  	gdk-pixbuf2 @2.28.2_0+x11
--->  	pango @1.34.1_1+x11
--->  	gtk2 @2.24.20_0+x11
--->  	poppler @0.22.5_0
--->  	atk @2.12.0_0
--->  	gdk-pixbuf2 @2.30.8_0+x11
--->  	pango @1.36.5_0+x11
--->  	gtk2 @2.24.24_0+x11
Warning: Uninstall forced.  Proceeding despite dependencies.
--->  Deactivating gobject-introspection @1.40.0_0
--->  Unable to deactivate gobject-introspection @1.40.0_0, the following ports depend on it:
--->  	atk @2.12.0_0
--->  	gdk-pixbuf2 @2.30.8_0+x11
--->  	pango @1.36.5_0+x11
--->  	gtk2 @2.24.24_0+x11
Warning: Deactivate forced.  Proceeding despite dependencies.
--->  Cleaning gobject-introspection
--->  Uninstalling gobject-introspection @1.40.0_0
--->  Cleaning gobject-introspection
--->  Computing dependencies for gobject-introspection
--->  Installing gobject-introspection @1.40.0_0
--->  Activating gobject-introspection @1.40.0_0
--->  Cleaning gobject-introspection
--->  Updating database of binaries
--->  Scanning binaries for linking errors
--->  No broken files found.
Last edited 10 years ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

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

Replying to john.m.harrold@…:

I believe the way to rebuild a package is the following:

sudo port upgrade -n --force   gobject-introspection

The output from rebuilding gobject-introspection is below. This didn't seem to help (poppler still fails to compile).

--->  Fetching archive for gobject-introspection
--->  Attempting to fetch gobject-introspection-1.40.0_0.darwin_12.x86_64.tbz2 from http://packages.macports.org/gobject-introspection
--->  Attempting to fetch gobject-introspection-1.40.0_0.darwin_12.x86_64.tbz2.rmd160 from http://packages.macports.org/gobject-introspection
[snip]

This doesn't necessarily rebuild the port; if a binary is available (and it was in this case), it will re-download and re-install that binary. To rebuild the port from source, you need to also use the -s flag. Note also that single-letter flags like -n and -s need to appear immediately after the word port to have any effect; conversely, double-dash flags like --force need to appear after the word after port. So to rebuild gobject-introspection you would need to run:

sudo port -ns upgrade --force gobject-introspection
Last edited 10 years ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

Changed 10 years ago by john.m.harrold@…

Attachment: main.3.log added

go-main.log

comment:8 in reply to:  7 ; Changed 10 years ago by john.m.harrold@…

Replying to ryandesign@…:

Thanks Ryan,

I'm more of an end user with Mac Ports. That seems to have failed as well:

Error: org.macports.build for port gobject-introspection returned: command execution failed
Please see the log file for port gobject-introspection for details:
    /opt/local/var/macports/logs/_opt_local_var_macports_sources_distfiles.macports.org_ports_gnome_gobject-introspection/gobject-introspection/main.log
Error: Unable to upgrade port: 1
To report a bug, follow the instructions in the guide:
    http://guide.macports.org/#project.tickets

I've uploaded the main.log (go-main.log) as well. There is something fishy going on here. This is from the go-main.log but I don't really know how to interpret these errors.

:info:build Traceback (most recent call last):
:info:build   File "./g-ir-scanner", line 44, in <module>
:info:build     from giscanner.scannermain import scanner_main
:info:build   File "./giscanner/scannermain.py", line 29, in <module>
:info:build     import tempfile
:info:build   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/tempfile.py", line 35, in <module>
:info:build     from random import Random as _Random
:info:build   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/random.py", line 49, in <module>
:info:build     import hashlib as _hashlib
:info:build   File "build/bdist.macosx-10.8-intel/egg/hashlib.py", line 105, in <module>
:info:build     
:info:build   File "build/bdist.macosx-10.8-intel/egg/_hashlib.py", line 7, in <module>
:info:build   File "build/bdist.macosx-10.8-intel/egg/_hashlib.py", line 4, in __bootstrap__
:info:build   File "build/bdist.macosx-10.8-intel/egg/pkg_resources.py", line 954, in resource_filename
:info:build     self, resource_name
:info:build   File "build/bdist.macosx-10.8-intel/egg/pkg_resources.py", line 1647, in get_resource_filename
:info:build     zip_path = self._resource_to_zip(resource_name)
:info:build   File "build/bdist.macosx-10.8-intel/egg/pkg_resources.py", line 1683, in _extract_resource
:info:build     
:info:build   File "build/bdist.macosx-10.8-intel/egg/pkg_resources.py", line 2857, in _mkstemp
:info:build     old_open = os.open
:info:build AttributeError: 'module' object has no attribute 'mkstemp'

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

Cc: ryandesign@… added
Summary: Building poppler failedpoppler, gobject-introspection: AttributeError: 'module' object has no attribute 'mkstemp'

Replying to john.m.harrold@…:

:info:build AttributeError: 'module' object has no attribute 'mkstemp'

This is an uncommon error message. I searched Google and got only 6 hits, including this ticket, and some of the hits were duplicates. Two of them suggested this will occur with very old versions of Python, like 2.2 or 2.3, which are so old we don't even have them in MacPorts anymore. Just out of curiosity, what version of Python is /usr/bin/python on your system? To find out, run:

/usr/bin/python -V

Do you know if you have any other versions of Python installed anywhere else on your system?

comment:10 in reply to:  9 Changed 10 years ago by john.m.harrold@…

Hello Ryan I'm running 2.7.2

$/usr/bin/python -V
Python 2.7.2

comment:11 Changed 9 years ago by outis

I might have a resolution.

I was getting this error when attempting to upgrade Python 2.7, during staging. Consequently, the top of the stack in my error message was different than in John's, but the stack from the import tempfile on was basically the same (the only difference was that modules were located in the build directory rather than the system directory). I could also get the same error by starting python 2.7 and trying to import tempfile:

Python 2.7.8 (default, Jul 16 2014, 01:06:49) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tempfile
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/tempfile.py", line 35, in <module>
    from random import Random as _Random
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/random.py", line 50, in <module>
    from hashlib import sha512 as _sha512
  File "build/bdist.macosx-10.6-x86_64/egg/hashlib.py", line 105, in <module>
    
  File "build/bdist.macosx-10.6-x86_64/egg/_hashlib.py", line 7, in <module>
  File "build/bdist.macosx-10.6-x86_64/egg/_hashlib.py", line 4, in __bootstrap__
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 937, in resource_filename
    self, resource_name
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 1632, in get_resource_filename
    self._extract_resource(manager, self._eager_to_zip(name))
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 1668, in _extract_resource
    outf, tmpnam = _mkstemp(".$extract", dir=os.path.dirname(real_path))
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 2852, in _mkstemp
    return tempfile.mkstemp(*args,**kw)
AttributeError: 'module' object has no attribute 'mkstemp'

(Sure, 10.6 isn't officially supported by MacPorts, but my Mac won't officially support anything newer than 10.7.)

It's a cyclic dependency: tempfile loads random, which loads hashlib, which loads pkg_resources, which calls tempfile.mkstemp, which isn't defined yet. The funny thing is the path for hashlib, which isn't the same as for the other modules, despite there being a hashlib.py in the same directory.

What happened (as you might guess from the path) was that I had an egg for hashlib in the "site-packages" sub-directory seen in the stack above. I:

  • removed the reference to the hashlib egg file in "site-packages/easy-install.pth" (you also may be able to run easy-install -m hashlib, but for me affected a different python installation), then
  • renamed the egg (you can probably delete the egg, but renaming is safer).

After that, python 2.7 staged successfully. I could also import tempfile and hashlib, so I deleted the egg.

comment:12 Changed 4 years ago by kencu (Ken)

Resolution: worksforme
Status: assignedclosed

please reopen a new ticket if this is still an issue.

Note: See TracTickets for help on using tickets.