Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"The way of the world is to praise dead saints and prosecute live ones." -- Nathaniel Howe


devel / comp.lang.python / Re: Compiling and Linking pre-built Windows Python libraries with C++ files on Linux for Windows

SubjectAuthor
* Compiling and Linking pre-built Windows Python libraries with C++Ankit Agarwal
`- Re: Compiling and Linking pre-built Windows Python libraries with C++Christian Gollwitzer

1
Compiling and Linking pre-built Windows Python libraries with C++ files on Linux for Windows

<mailman.326.1647658988.2329.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17545&group=comp.lang.python#17545

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ank...@applied.co (Ankit Agarwal)
Newsgroups: comp.lang.python
Subject: Compiling and Linking pre-built Windows Python libraries with C++
files on Linux for Windows
Date: Fri, 18 Mar 2022 17:08:48 -0700
Lines: 34
Message-ID: <mailman.326.1647658988.2329.python-list@python.org>
References: <CA+yD4TcUKX+eBMYK8zf7L9RDkxNvM--fo4rwL2iDFk9+r5reCg@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de jgJae832qNsN/Rjb/C4RfAr2RySzhG+3yMt45vYpKBIw==
Return-Path: <ankit@applied.co>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=applied.co header.i=@applied.co header.b=JwtyzrmP;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.005
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'engineer': 0.02; '3.7':
0.03; 'subject:Windows': 0.07; 'compiler': 0.09; 'hi,\xc2\xa0':
0.09; 'received:209.85.219': 0.09; 'subject:files': 0.09;
'subject:Python': 0.12; 'import': 0.15; 'c++': 0.16; 'compiled':
0.16; 'dll': 0.16; 'pre-built': 0.16; 'windows.': 0.16;
'with\xc2\xa0the': 0.16; 'problem': 0.16; 'python': 0.16;
'figure': 0.19; 'libraries': 0.19; 'to:addr:python-list': 0.20;
'code': 0.23; 'run': 0.23; 'binary': 0.26; 'interface': 0.26;
'question': 0.32; 'message-id:@mail.gmail.com': 0.32;
'subject:for': 0.33; 'there': 0.33; 'url:blog': 0.33; 'windows':
0.34; 'able': 0.34; 'received:google.com': 0.34; 'trying': 0.35;
'question.': 0.35; 'runs': 0.35; 'work,': 0.36; 'using': 0.37;
'received:209.85': 0.37; 'this.': 0.37; 'way': 0.38; 'thanks':
0.38; 'received:209': 0.39; 'use': 0.39; 'both': 0.40; 'want':
0.40; 'should': 0.40; 'url-ip:216/8': 0.60; 'url:co': 0.63;
'between': 0.63; 'skip:b 10': 0.63; 'let': 0.66; 'url-ip:3/8':
0.67; 'order': 0.69; ':)\xc2\xa0': 0.69; 'inc.': 0.73;
'subject:pre': 0.84; 'think,': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=applied.co; s=google;
h=mime-version:from:date:message-id:subject:to;
bh=eSonBDlLpDWM016JdpTZ3hWCvKJvfiih9GFG0NAgWIc=;
b=JwtyzrmP2uTjDwFovj1umdTmxSBo67rg0UArW9JsbhMSc6OSpJlFRwxTFmISkT39JI
GjJMiA0KaYc0xqyqOh9+oXLfzrHYHoT6ndUn7lGKVcxKDh9aMBROFzvaAe77OrQW6pw7
J2/g5DovIE7s+RUlwGXZ7yrW6u7PC4x7Fakf3KAjc5ByzkDy+BpP+36oQUh6aPFddLwK
uNifpFBt/DpmWzRdMkAWHDpAXVdu+Mw1+mTZdn9+ajDCSwhjdAJy3ydzZXOZsCeWq6hP
aK5C2Y1bAdeeSEOpLbdPI5YEH//UP7qNFVlb9V3+FidJdUgd7Tng3qpJTGaK46QALhNH
ODnA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
bh=eSonBDlLpDWM016JdpTZ3hWCvKJvfiih9GFG0NAgWIc=;
b=uiznmS9H9/67JfwJdVhBOucaJAeG/4heRkmlB0QZtp/8qU2r3Z3iWRFn0ZJFE+IXyj
x2iLVZd8FLLkJ6hQdkTN7BMGWxCos9YBJB3EibJfyxIkwKdElgqWCDWMm7o/QsIecbN5
c839BVPyZeYXlpH8tfCbhr7tStAvcBKIM4UH7G/AeHIhF/sFtUfNVApeeCO4kpd8/CZQ
ewOAhj422PaFNPO0BtsAs4883nZ1OsSFCEAwaooyV225xj7IwuYOXQlLXssbfFSOqZk8
7KcALhqhyGl4MUC+eGvv5kvZ0hZ3Qa1GYeq8vCGHsUBDnTogPNldS6eZkkVpHPqIPEYf
ekwQ==
X-Gm-Message-State: AOAM531W2MB2NWBZ722InQ6puqSELQihTiutRoCYIQfiTLUjtUAilqWp
GkbWQSF6XRBc/QsJEgVzz88ZG1xqPgzkThemlJj23fXtB9vsQw==
X-Google-Smtp-Source: ABdhPJwdrxrDYRzulRIle2QpIOmLA32v5GGU8e/WWnd82p6F9LbrVyuPAzjfLL1kvTfzUqHwR6fdUqGfgdcKZqGX6io=
X-Received: by 2002:a25:b9ca:0:b0:619:649f:1bf6 with SMTP id
y10-20020a25b9ca000000b00619649f1bf6mr12900578ybj.196.1647648537888; Fri, 18
Mar 2022 17:08:57 -0700 (PDT)
X-Mailman-Approved-At: Fri, 18 Mar 2022 23:03:07 -0400
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CA+yD4TcUKX+eBMYK8zf7L9RDkxNvM--fo4rwL2iDFk9+r5reCg@mail.gmail.com>
 by: Ankit Agarwal - Sat, 19 Mar 2022 00:08 UTC

Hi,

This is a very specific question. I am trying to figure out whether or not
I can use pre-built python libraries and headers on Windows in a MinGW
build on Linux. Essentially I have some python and C++ code which interface
via cython and pybind. I want to build a self contained C++ binary for
Windows with the MinGW compiler that runs on Linux. For both Cython and
PyBind, they need to compile with the python headers and link against the
python DLL in order to run on Windows.

I know that the python DLL specifically are compiled with the MSVC
compiler, however since it is in C, the ABI between the DLL should be
compatible with MinGW, and I should be able to import and link against it.
My question is will this work, or will there be some other problem that I
might run into.

I am using python 3.7 by the way for this.

Let me know what you think,

Thanks :)

Ankit

*Ankit Agarwal*

Software Engineer

ankit@applied.co

+1 630.506.4914

Applied Intuition, Inc. <https://applied.co>
blog.applied.co

Re: Compiling and Linking pre-built Windows Python libraries with C++ files on Linux for Windows

<t13rph$gmm$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17547&group=comp.lang.python#17547

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: aurio...@gmx.de (Christian Gollwitzer)
Newsgroups: comp.lang.python
Subject: Re: Compiling and Linking pre-built Windows Python libraries with C++
files on Linux for Windows
Date: Sat, 19 Mar 2022 07:04:33 +0100
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <t13rph$gmm$1@dont-email.me>
References: <CA+yD4TcUKX+eBMYK8zf7L9RDkxNvM--fo4rwL2iDFk9+r5reCg@mail.gmail.com>
<mailman.326.1647658988.2329.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 19 Mar 2022 06:04:33 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="ec4edd45ebbe7c3e306358a55d47302f";
logging-data="17110"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+xDrT4KpCdq6Ag4r8TZOyr5f7YMc2vsxI="
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:91.0)
Gecko/20100101 Thunderbird/91.7.0
Cancel-Lock: sha1:BS0wb1ksa4UByAxK8QixM2zFFds=
In-Reply-To: <mailman.326.1647658988.2329.python-list@python.org>
 by: Christian Gollwitzer - Sat, 19 Mar 2022 06:04 UTC

Am 19.03.22 um 01:08 schrieb Ankit Agarwal:
> This is a very specific question. I am trying to figure out whether or not
> I can use pre-built python libraries and headers on Windows in a MinGW
> build on Linux.

With the mingw cross-compiler on Linux that should be possible, however
I guess it might be difficult to set it up. Setuptools is not good for
crosscompiling. The easiest way to build Python extensions across
multiple OSes is cibuildwheel: https://github.com/pypa/cibuildwheel

Especially if your code lives on Github, then you can simply add
cibuildwheel to your workflow and it will build for multiple OSes and
Python versions on every commit. For OpenSource projects, Githubs build
servers are even for free! Otherwise, the prices are moderate as well.

If you happen to have your own build server farm (as in a commercial
setting) then you can also use other CI tools with cibuildwheel.

Christian

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor