Repository: psycopg/psycopg2

Issue #248: pip -e /path/to/psycopg2: psycopg/connection_type.c:810: error: ‘psyco_conn_get_exception’ undeclared here (not in a function)
Created: 2010-11-17T19:09:32Z
Originally submitted by: Jeff Kowalczyk
Originally submitted as number 18 - http://psycopg.lighthouseapp.com/projects/62710/tickets/18
When I try to build psycopg2 with a pip -e /path/to/psycopg2, I get the following error:
psycopg/connection_type.c:810: error: 'psyco_conn_get_exception' undeclared here (not in a function)

error: command 'gcc' failed with exit status 1

This error is consistent for psycopg versions 2.2.2, 2.3.0_beta1, and git.
Using the alternative install method works fine, I'm using a virtualenv, BTW:
(cd /path/to/psycopg2 && python setup.py install)

To keep the environment reproducible on multiple platforms, the virtualenvs use non-system pythons, e.g. an /opt/python2x. These are built with zc-buildout 1.4.4, zc.cmmi recipe:
# cat /opt/python27/buildout.cfg 
[buildout]
parts = python
parts-directory = .
download-cache = cache

[python]
recipe = zc.recipe.cmmi
url = http://www.python.org/ftp/python/2.7.1/Python-2.7.1rc1.tgz
extra_options = --enable-unicode=ucs2

The complete pip log is below:
------------------------------------------------------------
/path/to/acme/bin/pip run on Wed Nov 17 11:06:48 2010
Obtaining file:///path/to/psycopg2
  Running setup.py egg_info for package from file:///path/to/psycopg2
    running egg_info
    writing psycopg2.egg-info/PKG-INFO
    writing top-level names to psycopg2.egg-info/top_level.txt
    writing dependency_links to psycopg2.egg-info/dependency_links.txt
    warning: manifest_maker: standard file '-c' not found

    reading manifest file 'psycopg2.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching '*.html' under directory 'doc'
    warning: no files found matching '*.js' under directory 'doc'
    warning: no files found matching '*' under directory 'doc/html'
    no previously-included directories found matching 'doc/src/_build'
    warning: no files found matching 'PKG-INFO'
    warning: no files found matching 'MANIFEST'
    writing manifest file 'psycopg2.egg-info/SOURCES.txt'
Installing collected packages: psycopg2
  Running setup.py develop for psycopg2
    Running command /path/to/acme/bin/python -c "import setuptools; __file__='/path/to/psycopg2/setup.py'; execfile('/path/to/psycopg2/setup.py')" develop --no-deps
    running develop
    install_dir /path/to/acme/lib/python2.7/site-packages/
    running egg_info
    writing psycopg2.egg-info/PKG-INFO
    writing top-level names to psycopg2.egg-info/top_level.txt
    writing dependency_links to psycopg2.egg-info/dependency_links.txt
    warning: manifest_maker: standard file '-c' not found

    reading manifest file 'psycopg2.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching '*.html' under directory 'doc'
    warning: no files found matching '*.js' under directory 'doc'
    warning: no files found matching '*' under directory 'doc/html'
    no previously-included directories found matching 'doc/src/_build'
    warning: no files found matching 'PKG-INFO'
    warning: no files found matching 'MANIFEST'
    writing manifest file 'psycopg2.egg-info/SOURCES.txt'
    running build_ext
    building 'psycopg2._psycopg' extension
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.3.0-beta2 (dt dec ext pq3)" -DPG_VERSION_HEX=0x090001 -DPG_VERSION_HEX=0x090001 -I/opt/python27/python/include/python2.7 -I. -I/usr/include/postgresql-9.0 -I/usr/include/postgresql-9.0/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-2.7/psycopg/psycopgmodule.o -Wdeclaration-after-statement -Wdeclaration-after-statement
    /opt/python27/python/include/python2.7/datetime.h:188: warning: ‘PyDateTimeAPI’ defined but not used
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.3.0-beta2 (dt dec ext pq3)" -DPG_VERSION_HEX=0x090001 -DPG_VERSION_HEX=0x090001 -I/opt/python27/python/include/python2.7 -I. -I/usr/include/postgresql-9.0 -I/usr/include/postgresql-9.0/server -c psycopg/pqpath.c -o build/temp.linux-x86_64-2.7/psycopg/pqpath.o -Wdeclaration-after-statement -Wdeclaration-after-statement
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.3.0-beta2 (dt dec ext pq3)" -DPG_VERSION_HEX=0x090001 -DPG_VERSION_HEX=0x090001 -I/opt/python27/python/include/python2.7 -I. -I/usr/include/postgresql-9.0 -I/usr/include/postgresql-9.0/server -c psycopg/typecast.c -o build/temp.linux-x86_64-2.7/psycopg/typecast.o -Wdeclaration-after-statement -Wdeclaration-after-statement
    psycopg/typecast.c:40: warning: ‘skip_until_space’ defined but not used
    /opt/python27/python/include/python2.7/datetime.h:188: warning: ‘PyDateTimeAPI’ defined but not used
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.3.0-beta2 (dt dec ext pq3)" -DPG_VERSION_HEX=0x090001 -DPG_VERSION_HEX=0x090001 -I/opt/python27/python/include/python2.7 -I. -I/usr/include/postgresql-9.0 -I/usr/include/postgresql-9.0/server -c psycopg/microprotocols.c -o build/temp.linux-x86_64-2.7/psycopg/microprotocols.o -Wdeclaration-after-statement -Wdeclaration-after-statement
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.3.0-beta2 (dt dec ext pq3)" -DPG_VERSION_HEX=0x090001 -DPG_VERSION_HEX=0x090001 -I/opt/python27/python/include/python2.7 -I. -I/usr/include/postgresql-9.0 -I/usr/include/postgresql-9.0/server -c psycopg/microprotocols_proto.c -o build/temp.linux-x86_64-2.7/psycopg/microprotocols_proto.o -Wdeclaration-after-statement -Wdeclaration-after-statement
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.3.0-beta2 (dt dec ext pq3)" -DPG_VERSION_HEX=0x090001 -DPG_VERSION_HEX=0x090001 -I/opt/python27/python/include/python2.7 -I. -I/usr/include/postgresql-9.0 -I/usr/include/postgresql-9.0/server -c psycopg/connection_type.c -o build/temp.linux-x86_64-2.7/psycopg/connection_type.o -Wdeclaration-after-statement -Wdeclaration-after-statement
    psycopg/connection_type.c:796: error: ‘psyco_conn_get_exception’ undeclared here (not in a function)
    error: command 'gcc' failed with exit status 1
    Complete output from command /path/to/acme/bin/python -c "import setuptools; __file__='/path/to/psycopg2/setup.py'; execfile('/path/to/psycopg2/setup.py')" develop --no-deps:
    running develop

install_dir /path/to/acme/lib/python2.7/site-packages/

running egg_info

writing psycopg2.egg-info/PKG-INFO

writing top-level names to psycopg2.egg-info/top_level.txt

writing dependency_links to psycopg2.egg-info/dependency_links.txt

warning: manifest_maker: standard file '-c' not found



reading manifest file 'psycopg2.egg-info/SOURCES.txt'

reading manifest template 'MANIFEST.in'

warning: no files found matching '*.html' under directory 'doc'

warning: no files found matching '*.js' under directory 'doc'

warning: no files found matching '*' under directory 'doc/html'

no previously-included directories found matching 'doc/src/_build'

warning: no files found matching 'PKG-INFO'

warning: no files found matching 'MANIFEST'

writing manifest file 'psycopg2.egg-info/SOURCES.txt'

running build_ext

building 'psycopg2._psycopg' extension

gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.3.0-beta2 (dt dec ext pq3)" -DPG_VERSION_HEX=0x090001 -DPG_VERSION_HEX=0x090001 -I/opt/python27/python/include/python2.7 -I. -I/usr/include/postgresql-9.0 -I/usr/include/postgresql-9.0/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-2.7/psycopg/psycopgmodule.o -Wdeclaration-after-statement -Wdeclaration-after-statement

/opt/python27/python/include/python2.7/datetime.h:188: warning: ‘PyDateTimeAPI’ defined but not used

gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.3.0-beta2 (dt dec ext pq3)" -DPG_VERSION_HEX=0x090001 -DPG_VERSION_HEX=0x090001 -I/opt/python27/python/include/python2.7 -I. -I/usr/include/postgresql-9.0 -I/usr/include/postgresql-9.0/server -c psycopg/pqpath.c -o build/temp.linux-x86_64-2.7/psycopg/pqpath.o -Wdeclaration-after-statement -Wdeclaration-after-statement

gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.3.0-beta2 (dt dec ext pq3)" -DPG_VERSION_HEX=0x090001 -DPG_VERSION_HEX=0x090001 -I/opt/python27/python/include/python2.7 -I. -I/usr/include/postgresql-9.0 -I/usr/include/postgresql-9.0/server -c psycopg/typecast.c -o build/temp.linux-x86_64-2.7/psycopg/typecast.o -Wdeclaration-after-statement -Wdeclaration-after-statement

psycopg/typecast.c:40: warning: ‘skip_until_space’ defined but not used

/opt/python27/python/include/python2.7/datetime.h:188: warning: ‘PyDateTimeAPI’ defined but not used

gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.3.0-beta2 (dt dec ext pq3)" -DPG_VERSION_HEX=0x090001 -DPG_VERSION_HEX=0x090001 -I/opt/python27/python/include/python2.7 -I. -I/usr/include/postgresql-9.0 -I/usr/include/postgresql-9.0/server -c psycopg/microprotocols.c -o build/temp.linux-x86_64-2.7/psycopg/microprotocols.o -Wdeclaration-after-statement -Wdeclaration-after-statement

gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.3.0-beta2 (dt dec ext pq3)" -DPG_VERSION_HEX=0x090001 -DPG_VERSION_HEX=0x090001 -I/opt/python27/python/include/python2.7 -I. -I/usr/include/postgresql-9.0 -I/usr/include/postgresql-9.0/server -c psycopg/microprotocols_proto.c -o build/temp.linux-x86_64-2.7/psycopg/microprotocols_proto.o -Wdeclaration-after-statement -Wdeclaration-after-statement

gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.3.0-beta2 (dt dec ext pq3)" -DPG_VERSION_HEX=0x090001 -DPG_VERSION_HEX=0x090001 -I/opt/python27/python/include/python2.7 -I. -I/usr/include/postgresql-9.0 -I/usr/include/postgresql-9.0/server -c psycopg/connection_type.c -o build/temp.linux-x86_64-2.7/psycopg/connection_type.o -Wdeclaration-after-statement -Wdeclaration-after-statement

psycopg/connection_type.c:796: error: ‘psyco_conn_get_exception’ undeclared here (not in a function)

error: command 'gcc' failed with exit status 1

----------------------------------------
Command /path/to/acme/bin/python -c "import setuptools; __file__='/path/to/psycopg2/setup.py'; execfile('/path/to/psycopg2/setup.py')" develop --no-deps failed with error code 1
Exception information:
Traceback (most recent call last):
  File "/path/to/acme/lib/python2.7/site-packages/pip-0.8.1-py2.7.egg/pip/basecommand.py", line 130, in main
    self.run(options, args)
  File "/path/to/acme/lib/python2.7/site-packages/pip-0.8.1-py2.7.egg/pip/commands/install.py", line 228, in run
    requirement_set.install(install_options, global_options)
  File "/path/to/acme/lib/python2.7/site-packages/pip-0.8.1-py2.7.egg/pip/req.py", line 1043, in install
    requirement.install(install_options, global_options)
  File "/path/to/acme/lib/python2.7/site-packages/pip-0.8.1-py2.7.egg/pip/req.py", line 534, in install
    self.install_editable(install_options, global_options)
  File "/path/to/acme/lib/python2.7/site-packages/pip-0.8.1-py2.7.egg/pip/req.py", line 617, in install_editable
    show_stdout=False)
  File "/path/to/acme/lib/python2.7/site-packages/pip-0.8.1-py2.7.egg/pip/__init__.py", line 249, in call_subprocess
    % (command_desc, proc.returncode))
InstallationError: Command /path/to/acme/bin/python -c "import setuptools; __file__='/path/to/psycopg2/setup.py'; execfile('/path/to/psycopg2/setup.py')" develop --no-deps failed with error code 1

Duplicate issue #204: pip fails to build psycopg from url
Created: 2014-04-03T10:30:34Z
Psycopg is affected by this bug (pip? setuptools? don't know)
pypa/pip#1630
which makes impossible to build from url:
mkvirtualenv testpip
pip install -U pip setuptools virtualenv
pip install --verbose -e git+https://github.com/psycopg/psycopg2.git#egg=psycopg2

the bug is caused by the setup.cfg not being parsed when installing from url.
We may work around that by checking if the setup.cfg has not been imported at all, in which case we may apply the defaults, with the rationale that if sb. is installing from url he has not changed the .cfg. Of course changes in the .cfg defaults should be reflected in the setup.py as well: we need comments in both the files to clarify that.

Closing comment (2014-04-04T17:10:27Z): Bug fixed: now checking out from master and maint_2_5 works as expected.
This bug can be considered a duplicate of #248.
Georges, can you test it with zc.buildout? Thank you :)