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

[REQ] Install instructions for pywin32 under MingGW/msys2 #1552

Open
brianddk opened this issue Jul 6, 2020 · 7 comments
Open

[REQ] Install instructions for pywin32 under MingGW/msys2 #1552

brianddk opened this issue Jul 6, 2020 · 7 comments

Comments

@brianddk
Copy link

brianddk commented Jul 6, 2020

There are notes in CHANGES.txt discussing work by @joankaradimov to make pywin32 buildable under MingGW/msys2

Significant work by @joankaradimov in porting pywin32 so that it works in a MingGW/msys2 environment.

but there are no relevant instructions in build_env.md as to how to build it.

There seems to be some interesting patches listed in mingw-w64-python-pywin32, but since it never released, its hard to tell how stale these patches are.

Doing the obvious stuff yields obvious errors

wget https://github.com/mhammond/pywin32/archive/b228.tar.gz
tar -xzvf b224.tar.gz
cd pywin32-b224
python setup.py install

yields

Building pywin32 3.8.228.0
running install
running build
running build_py
copying win32\lib/afxres.py -> build/lib.mingw-3.8/win32\lib

<... clip ...>

Refactoring build/lib.mingw-3.8/adodbapi/adodbapi.py
Refactoring build/lib.mingw-3.8/adodbapi/ado_consts.py
Refactoring build/lib.mingw-3.8/adodbapi/apibase.py
Refactoring build/lib.mingw-3.8/adodbapi/is64bit.py
Refactoring build/lib.mingw-3.8/adodbapi/process_connect_string.py
Refactoring build/lib.mingw-3.8/adodbapi/remote.py
Refactoring build/lib.mingw-3.8/adodbapi/schema_table.py
Refactoring build/lib.mingw-3.8/adodbapi/setup.py
Refactoring build/lib.mingw-3.8/adodbapi/__init__.py
running build_ext
Traceback (most recent call last):
  File "setup.py", line 2478, in <module>
    dist = setup(name="pywin32",
  File "<redacted>/.venv/lib/python3.8/site-packages/setuptools/__init__.py", line 165, in setup
    return distutils.core.setup(**attrs)

<... clip ...>

  File "<redacted>/msys64/mingw64/lib/python3.8/distutils/msvccompiler.py", line 602, in get_msvc_paths
    r"\Win32 (%s)\Directories" % (self.__root, platform))
AttributeError: 'my_compiler' object has no attribute '_MSVCCompiler__root'
  • MinGW: MINGW64_NT-10.0-16299 3.1.5-340.x86_64 x86_64 Msys
  • Python: version 3.8.2
  • setuptools: version 49.1.0
  • pywin32: 3.8.228.0

Thoughts?

@joankaradimov
Copy link
Contributor

There seems to be some interesting patches listed in mingw-w64-python-pywin32, but since it never released, its hard to tell how stale these patches are.

These are stale, yes. My patches are not included in the master for MINGW-packages yet. But you can find them here:
https://github.com/joankaradimov/MINGW-packages/tree/pywin32-updates/mingw-w64-python-pywin32

Doing the obvious stuff yields obvious errors

You'll need to do a bunch more. See the prepare and build functions in pacman's PKGBUILD. And unfortunately -- even after that the build that's produced will not work on Python 3.8 -- most likely because of #1327.

Thoughts?

I'm interested in writing instruction and getting CI builds working for mingw. But I'd say it's too early now.

This is still a WIP. You can see the current progress here: msys2/MINGW-packages#5615. It turned out to be quite the task. It included a bunch of patches in mingw-w64. A few more patches would need to be submitted in mingw to get mapi and propsys to compile. I'll also need to figure out a nicer way to distribute my SEH code (I might have some ideas). And some more stuff would need to be polished and brought in as pull requests here.

TL;DR
It's too early. But if you're willing to experiment - you could get Python 2.7 to work by looking at this.

@mhammond
Copy link
Owner

mhammond commented Jul 7, 2020

even after that the build that's produced will not work on Python 3.8 -- most likely because of #1327.

I'd like to understand that issue better, but it's a commonly reported problem when there are duplicate DLLs etc installed (eg, from another or different installation). 3.8 installs seem to work OK on a clean system (although obviously not any mingw specific stuff).

It's too early. But if you're willing to experiment - you could get Python 2.7 to work by looking at this.

I'd advise against putting too much effort into anything 2.7 specific - I'm hoping to land #1510 in the next week or 2, which will remove all 2.x support forever.

That branch also has better CI integration which should make some things easier. Let me know if I can help further.

@raedrizqie
Copy link

Hi Mark and all..

I had successfully built pywin32 on mingw-w64. Using Python v3.5.2 (x64) & MinGW-w64 5.3.0 (mingw-build).

Here is the build log:

pywin32-220-3.5-w64-5.3.0-build.txt

Install log:

pywin32-220-3.5-w64-5.3.0-install.txt

Some changes are required to support UNICODE for the includes files from Win SDK 7.1 & Exchange.

I also had to use libs from winddk 7.1 in order to compile successfully:
ADSIid.Lib
Bits.Lib
Htmlhelp.Lib
MsXml2.Lib
NtQuery.Lib
propsys.lib
RunTmChk.lib
Uuid.lib
windowscodecs.lib

Here is the patch:

pywin32-220_mingw-python.diff.txt

@mhammond
Copy link
Owner

Thanks - but that's a massive patch, and if it was against build 220, is almost certainly out of date. Any chance of a pull request?

@QGB
Copy link

QGB commented Jul 28, 2022

嗨,马克和所有..

我已经在 mingw-w64 上成功构建了 pywin32。使用 Python v3.5.2 (x64) 和 MinGW-w64 5.3.0 (mingw-build)。

这是构建日志:

pywin32-220-3.5-w64-5.3.0-build.txt

安装日志:

pywin32-220-3.5-w64-5.3.0-install.txt

Win SDK 7.1 和 Exchange 中的包含文件需要进行一些更改才能支持 UNICODE。

我还必须使用 winddk 7.1 中的库才能成功编译: ADSIid.Lib Bits.Lib Htmlhelp.Lib MsXml2.Lib NtQuery.Lib propsys.lib RunTmChk.lib Uuid.lib windowscodecs.lib

这是补丁:

pywin32-220_mingw-python.diff.txt

could you provide the mingw_x64 pywin32 .whl file?

@mhammond
Copy link
Owner

could you provide the mingw_x64 pywin32 .whl file?

Not until it actually builds.

@Avasam
Copy link
Collaborator

Avasam commented Mar 14, 2024

wget https://github.com/mhammond/pywin32/archive/b228.tar.gz
tar -xzvf b224.tar.gz
cd pywin32-b224
python setup.py install

Note to readers that python setup.py and the use of setup.py as a command line tool are deprecated. pywin32 itself needs to move away from it. #2208

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

No branches or pull requests

6 participants