Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not compile with Python 3.8.0a2, PyInterpreterState opaque type #854

Closed
nascheme opened this issue Mar 1, 2019 · 13 comments
Closed

Comments

@nascheme
Copy link

nascheme commented Mar 1, 2019

I get the following error when trying to compile:

psycopg/psycopgmodule.c: In function ‘psyco_is_main_interp’:
psycopg/psycopgmodule.c:689:18: error: dereferencing pointer to incomplete type ‘PyInterpreterState’ {aka ‘struct _is’}
     while (interp->next)

This occurs for the 'master' branch from github as well. I believe the correct fix is to use PEP 3121 (Extension Module Initialization and Finalization) APIs so that psycopg can have per-interpreter state. Within that state, it can keep a cache to the decimal type object.

@vstinner
Copy link

vstinner commented Mar 1, 2019

I believe the correct fix is to use PEP 3121

Right, it would be nice. But it can require a lot of work.

Just to fix the compilation error, psyco_is_main_inter() can be modified to use the new PyInterpreterState_Main() function introduced in Python 3.7.

@dvarrazzo
Copy link
Member

dvarrazzo commented Mar 1, 2019

@nascheme @vstinner PyInterpreterState_Main is not documented, and bears the disclaimer in the source code:

/* Routines for advanced debuggers, requested by David Beazley.
   Don't use unless you know what you are doing! */

Maybe you could provide a patch to suggest the correct usage?

Thank you

dvarrazzo added a commit that referenced this issue Mar 4, 2019
dvarrazzo added a commit that referenced this issue Mar 4, 2019
bors bot added a commit to chronhq/backend that referenced this issue Oct 27, 2019
167: Update psycopg2 requirement from ~=2.8.3 to ~=2.8.4 in /config r=MiklerGM a=dependabot-preview[bot]

Updates the requirements on [psycopg2](https://github.com/psycopg/psycopg2) to permit the latest version.
<details>
<summary>Changelog</summary>

*Sourced from [psycopg2's changelog](https://github.com/psycopg/psycopg2/blob/master/NEWS).*

> Current release
> ---------------
> 
> What's new in psycopg 2.8.4
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> - Fixed building with Python 3.8 (:ticket:`[#854](psycopg/psycopg2#854).
> - Don't swallow keyboard interrupts on connect when a password is specified
>   in the connection string (:ticket:`[#898](psycopg/psycopg2#898).
> - Don't advance replication cursor when the message wasn't confirmed
>   (:ticket:`[#940](psycopg/psycopg2#940).
> - Fixed inclusion of ``time.h`` on linux (:ticket:`[#951](psycopg/psycopg2#951).
> - Fixed int overflow for large values in `~psycopg2.extensions.Column.table_oid`
>   and `~psycopg2.extensions.Column.type_code` (:ticket:`[#961](psycopg/psycopg2#961).
> - `~psycopg2.errorcodes` map and `~psycopg2.errors` classes updated to
>   PostgreSQL 12.
> - Wheel package compiled against OpenSSL 1.1.1d and PostgreSQL at least 11.4.
> 
> 
> What's new in psycopg 2.8.3
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> - Added *interval_status* parameter to
>   `~psycopg2.extras.ReplicationCursor.start_replication()` method and other
>   facilities to send automatic replication keepalives at periodic intervals
>   (:ticket:`[#913](psycopg/psycopg2#913).
> - Fixed namedtuples caching introduced in 2.8 (:ticket:`[#928](psycopg/psycopg2#928).
> 
> 
> What's new in psycopg 2.8.2
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> - Fixed `~psycopg2.extras.RealDictCursor` when there are repeated columns
>   (:ticket:`[#884](psycopg/psycopg2#884).
> - Binary packages built with openssl 1.1.1b. Should fix concurrency problems
>   (:tickets:`[#543](psycopg/psycopg2#543), [#836](psycopg/psycopg2#836).
> 
> 
> What's new in psycopg 2.8.1
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> - Fixed `~psycopg2.extras.RealDictRow` modifiability (:ticket:`[#886](psycopg/psycopg2#886).
> - Fixed "there's no async cursor" error polling a connection with no cursor
>   (:ticket:`[#887](psycopg/psycopg2#887).
> 
> 
> What's new in psycopg 2.8
> -------------------------
> 
> New features:
></tr></table> ... (truncated)
</details>
<details>
<summary>Commits</summary>

- See full diff in [compare view](https://github.com/psycopg/psycopg2/commits)
</details>
<br />

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com):
- Update frequency (including time of day and day of week)
- Pull request limits (per update run and/or open at any time)
- Automerge options (never/patch/minor, and dev/runtime dependencies)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)



</details>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
haikoschol added a commit to aboutcode-org/vulnerablecode that referenced this issue Dec 6, 2019
See psycopg/psycopg2#854

Signed-off-by: Haiko Schol <hs@haikoschol.com>
MGlauer added a commit to OpenEnergyPlatform/oeplatform that referenced this issue Dec 19, 2019
Because psycopg2 does not seem to work with python 3.8 on travis.
Might be linked to psycopg/psycopg2#854
mart-e added a commit to odoo-dev/odoo that referenced this issue Jan 3, 2020
psycopg2 2.7 not be installed on python 3.8, needs at least psycopg2 2.8
use the same version as windows to avoid complicated rules if windows
AND python 3.8
Note that psycopg2 3.8.4 is currently the only one released after the
release of python 3.8 but reported compatibilty issued seems to be
fixed since 3.8 at psycopg/psycopg2#854

Fixes odoo#42660
MGlauer added a commit to OpenEnergyPlatform/oeplatform that referenced this issue Jan 13, 2020
Because psycopg2 does not seem to work with python 3.8 on travis.
Might be linked to psycopg/psycopg2#854
yuanfang-chen pushed a commit to yuanfang-chen/llvm-lnt that referenced this issue Jan 27, 2020
mart-e added a commit to odoo-dev/odoo that referenced this issue Jan 28, 2020
psycopg2 2.7 not be installed on python 3.8, needs at least psycopg2 2.8
use the same version as windows to avoid complicated rules if windows
AND python 3.8
Note that psycopg2 3.8.4 is currently the only one released after the
release of python 3.8 but reported compatibilty issued seems to be
fixed since 3.8 at psycopg/psycopg2#854

Fixes odoo#42660
robodoo pushed a commit to odoo/odoo that referenced this issue Jan 28, 2020
psycopg2 2.7 not be installed on python 3.8, needs at least psycopg2 2.8
use the same version as windows to avoid complicated rules if windows
AND python 3.8
Note that psycopg2 3.8.4 is currently the only one released after the
release of python 3.8 but reported compatibilty issued seems to be
fixed since 3.8 at psycopg/psycopg2#854

Fixes #42660

closes #42705

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
fw-bot pushed a commit to odoo-dev/odoo that referenced this issue Jan 28, 2020
psycopg2 2.7 not be installed on python 3.8, needs at least psycopg2 2.8
use the same version as windows to avoid complicated rules if windows
AND python 3.8
Note that psycopg2 3.8.4 is currently the only one released after the
release of python 3.8 but reported compatibilty issued seems to be
fixed since 3.8 at psycopg/psycopg2#854

Fixes odoo#42660

X-original-commit: f615826
fw-bot pushed a commit to odoo-dev/odoo that referenced this issue Jan 28, 2020
psycopg2 2.7 not be installed on python 3.8, needs at least psycopg2 2.8
use the same version as windows to avoid complicated rules if windows
AND python 3.8
Note that psycopg2 3.8.4 is currently the only one released after the
release of python 3.8 but reported compatibilty issued seems to be
fixed since 3.8 at psycopg/psycopg2#854

Fixes odoo#42660

X-original-commit: f615826
robodoo pushed a commit to odoo/odoo that referenced this issue Jan 29, 2020
psycopg2 2.7 not be installed on python 3.8, needs at least psycopg2 2.8
use the same version as windows to avoid complicated rules if windows
AND python 3.8
Note that psycopg2 3.8.4 is currently the only one released after the
release of python 3.8 but reported compatibilty issued seems to be
fixed since 3.8 at psycopg/psycopg2#854

Fixes #42660

closes #44139

X-original-commit: f615826
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
robodoo pushed a commit to odoo/odoo that referenced this issue Jan 29, 2020
psycopg2 2.7 not be installed on python 3.8, needs at least psycopg2 2.8
use the same version as windows to avoid complicated rules if windows
AND python 3.8
Note that psycopg2 3.8.4 is currently the only one released after the
release of python 3.8 but reported compatibilty issued seems to be
fixed since 3.8 at psycopg/psycopg2#854

Fixes #42660

closes #44143

X-original-commit: f615826
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
robodoo pushed a commit to odoo/odoo that referenced this issue Jan 29, 2020
psycopg2 2.7 not be installed on python 3.8, needs at least psycopg2 2.8
use the same version as windows to avoid complicated rules if windows
AND python 3.8
Note that psycopg2 3.8.4 is currently the only one released after the
release of python 3.8 but reported compatibilty issued seems to be
fixed since 3.8 at psycopg/psycopg2#854

Fixes #42660

closes #44143

X-original-commit: f615826
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
@optimostech
Copy link

Any can help me please?

Best match: psycopg2-binary 2.7.4
Processing psycopg2-binary-2.7.4.tar.gz
Writing /tmp/easy_install-ttdt6d/psycopg2-binary-2.7.4/setup.cfg
Running psycopg2-binary-2.7.4/setup.py -q bdist_egg --dist-dir /tmp/easy_install-ttdt6d/psycopg2-binary-2.7.4/egg-dist-tmp-l99_u3nq
psycopg/psycopgmodule.c: In function ‘psyco_is_main_interp’:
psycopg/psycopgmodule.c:685:18: error: dereferencing pointer to incomplete type ‘PyInterpreterState’ {aka ‘struct _is’}
685 | while (interp->next)
| ^~

It appears you are missing some prerequisite to build the package from source.

You may install a binary package by installing 'psycopg2-binary' from PyPI.
If you want to install psycopg2 from source, please install the packages
required for the build and try again.

For further information please check the 'doc/src/install.rst' file (also at
http://initd.org/psycopg/docs/install.html).

error: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

@dvarrazzo
Copy link
Member

@optimostech what part of "Support to Python 3.8 was added in psycopg 2.8.4" is not clear to you?

spk added a commit to spk/flask-recipes that referenced this issue Jul 5, 2020
signedav added a commit to opengisch/QgisModelBaker that referenced this issue Aug 31, 2020
signedav added a commit to opengisch/QgisModelBaker that referenced this issue Aug 31, 2020
use latest version but minimum 2.7.4 since we need > 2.8.3 for psycopg from python version 3.8
psycopg/psycopg2#854 (comment)
bakboka added a commit to bakboka/odoo that referenced this issue Sep 24, 2020
Current version of psycopg2 (2.7.4.1) does not support python3. Support had been added in version 2.8.4 
psycopg/psycopg2#854 (comment)
@tomasz-szymanek
Copy link

@optimostech what part of "Support to Python 3.8 was added in psycopg 2.8.4" is not clear to you?

This is really rude.

@dvarrazzo
Copy link
Member

@tomasz-szymanek So are requests demanding help which don't care for the work already used to answer them.

@fogzot
Copy link
Member

fogzot commented Feb 12, 2021

Even if @dvarrazzo answer was a bit rude, that is not reason for insults. I marked @free-variation comment as hidden.

Please, lets stop here.

@free-variation
Copy link

Vabbe' -- "a bit rude" -- pare che non sia la prima volta, ma fate come volete.

@Patrick-Chong
Copy link

I get the following error when trying to compile:

psycopg/psycopgmodule.c: In function ‘psyco_is_main_interp’:
psycopg/psycopgmodule.c:689:18: error: dereferencing pointer to incomplete type ‘PyInterpreterState’ {aka ‘struct _is’}
     while (interp->next)

This occurs for the 'master' branch from github as well. I believe the correct fix is to use PEP 3121 (Extension Module Initialization and Finalization) APIs so that psycopg can have per-interpreter state. Within that state, it can keep a cache to the decimal type object.

Apologies if this is a basic question, but how do we 'use' PEP 3121? As I am facing the same problem while installing psycopg2

@dvarrazzo
Copy link
Member

@Patrick-Chong the suggestion of using PEP 3121 is addressed to the people writing and maintaining psycopg, not to the people using it. You should look into how to ask pip to install the right version :)

@lucaswiman
Copy link

If you run into this error on pypy, the following worked for me.

  • Install psycopg2cffi.
  • Then before you import any database code, run:
from psycopg2cffi import compat
compat.register()

Approach taken from this post (Auto-translated from Turkish.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants