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

Add Mingw recognition to pyport.h to allow building extensions #50921

Closed
f0k mannequin opened this issue Aug 9, 2009 · 6 comments
Closed

Add Mingw recognition to pyport.h to allow building extensions #50921

f0k mannequin opened this issue Aug 9, 2009 · 6 comments
Labels
3.8 only security fixes 3.9 only security fixes 3.10 only security fixes build The build process and cross-build OS-windows

Comments

@f0k
Copy link
Mannequin

f0k mannequin commented Aug 9, 2009

BPO 6672
Nosy @merwok, @briancurtin
Superseder
  • bpo-45538: MinGW is unsupported - close all open issues and list them here.
  • Files
  • pyport-issue6672.diff: Patch to pyport.h of Python 2.6 or 2.7 to handle Mingw correctly
  • 0002-MINGW-issue6672-add-mingw-recognition-to-pyport.h-to.patch: issue3871 split : pyport.h for extentions module build with gcc(mingw*)
  • 0003-issue6672-v2-Add-Mingw-recognition-to-pyport.h-to-al.patch: v2 with defined Py_BUILD_CORE_MODULE
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-10-20.12:55:11.226>
    created_at = <Date 2009-08-09.12:24:49.034>
    labels = ['3.10', 'build', '3.8', '3.9', 'OS-windows']
    title = 'Add Mingw recognition to pyport.h to allow building extensions'
    updated_at = <Date 2021-10-21.10:03:53.773>
    user = 'https://bugs.python.org/f0k'

    bugs.python.org fields:

    activity = <Date 2021-10-21.10:03:53.773>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-10-20.12:55:11.226>
    closer = 'iritkatriel'
    components = ['Build', 'Windows']
    creation = <Date 2009-08-09.12:24:49.034>
    creator = 'f0k'
    dependencies = []
    files = ['15169', '28935', '30957']
    hgrepos = []
    issue_num = 6672
    keywords = ['patch']
    message_count = 6.0
    messages = ['91427', '94259', '94273', '116137', '181187', '193247']
    nosy_count = 6.0
    nosy_names = ['jlt63', 'stutzbach', 'eric.araujo', 'rpetrov', 'brian.curtin', 'f0k']
    pr_nums = []
    priority = 'normal'
    resolution = 'wont fix'
    stage = 'resolved'
    status = 'closed'
    superseder = '45538'
    type = None
    url = 'https://bugs.python.org/issue6672'
    versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

    @f0k
    Copy link
    Mannequin Author

    f0k mannequin commented Aug 9, 2009

    This addresses missing statements for recognizing the Mingw compiler in
    pyport.h, needed to build several extension modules on Windows using
    Mingw. I will first explain the background, then indicate what needs to
    be changed and end with some pointers to "related work".

    Pyport.h of Python 2.5 and 2.6 (I do not have other versions to check)
    addresses an issue with Cygwin's gcc by preventing the declaration of
    "__declspec(dllimport)" for function definitions (using the PyAPI_FUNC
    (RTYPE) makro), relying on the compiler's auto-import definition
    instead, because the compiler would not otherwise throw an "initializer
    element is not constant" error when using e.g. PyObject_GenericGetAttr
    in a PyTypeObject declaration of a C/C++ extension module (more
    generally, whenever an imported Python API function is used as a
    constant).
    Python 2.6.2 (r262:71605) and Python 2.5.4 (r254:67916) do not check
    for the Mingw compiler in pyport.h, although Mingw behaves the same as
    the Cygwin version, at least regarding the "__declspec" declaration.

    To fix that, each check for __CYGWIN__ in pyport.h should also check
    for __MINGW32___ to behave the same way. svn.python.org currently does
    not reply, so I can not create a patch against the trunk nor check
    whether this issue has already been addressed.

    bpo-5046 included a patch to pyport.h fixing this, but it has been
    rejected due to other suggested changes that were not mature.
    http://recipes.gobolinux.org/r/?list=Python&ver=3.1-
    r1&file=arm/20061116160247-
    bf48b-7db78fe2f80b3137ce349cf4314364768555ff50.gz.diff suggests the
    same change.
    http://www.indashpc.org/vbullettin/viewtopic.php?p=5003#5003 gives some
    more background information on how I found and fixed the problem.
    An internet search for "python initializer element is not constant"
    shows that numerous people have been encountering this problem when
    trying to build a python extension module.

    @f0k f0k mannequin added the build The build process and cross-build label Aug 9, 2009
    @stutzbach
    Copy link
    Mannequin

    stutzbach mannequin commented Oct 19, 2009

    svn.python.org seems to be up again. Could you create a patch?

    @f0k
    Copy link
    Mannequin Author

    f0k mannequin commented Oct 20, 2009

    Hello!

    Thanks, you're right. I have created a patch against the latest SVN
    revision (75557) of branches/release26-maint/Include/pyport.h. The
    patch also applies fine to trunk/Include/pyport.h.
    As it applies to both versions, I have created the patch directly from
    inside the Include directory rather than from the svn root.

    As I am abroad for a couple of months and do not have access to my
    Windows machine, I currently cannot test the patch (i.e. compile Python
    on Windows using Mingw), but I successfully compiled the PyMedia
    package using Mingw and the modified pyport.h.

    Please let me know if you have any questions or remarks!

    @stutzbach stutzbach mannequin added the OS-windows label Apr 27, 2010
    @merwok
    Copy link
    Member

    merwok commented Sep 12, 2010

    A tip about versions: Bugs are fixed on the active branch, py3k (which will become 3.2), then backported to 3.1 and 2.7. Security fixes go into 2.5 and 2.6 too.

    @rpetrov
    Copy link
    Mannequin

    rpetrov mannequin commented Feb 2, 2013

    Version against current (2013-02-02) source.

    @rpetrov
    Copy link
    Mannequin

    rpetrov mannequin commented Jul 17, 2013

    new patch - improved version with support for build of core modules

    @iritkatriel iritkatriel added 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes labels Nov 11, 2020
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes 3.9 only security fixes 3.10 only security fixes build The build process and cross-build OS-windows
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants