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

Stop calling setup.py, use a build frontend #2396

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/issue_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ Python version and distribution:

pywin32 version:

Installed from PyPI or exe installer:

Windows Version:
<!-- You can find this under "System Information", ie: Version 10.0.19045 Build 19045 -->

Expand Down
33 changes: 14 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13-dev"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
architecture: ["x64", "x86"]

steps:
Expand All @@ -40,25 +40,23 @@ jobs:
pip install --upgrade setuptools>=74 wheel

- name: Build and install
run: |
python setup.py install --user
run: pip install . -v --user

- name: Run tests
# Run the tests directly from the source dir so support files (eg, .wav files etc)
# can be found - they aren't installed into the Python tree.
run: python pywin32_testall.py -v -skip-adodbapi

- name: Build wheels
run: |
python setup.py bdist_wheel --skip-build
run: pip wheel . -v --wheel-dir=dist

- uses: actions/upload-artifact@v3
# Upload artifacts even if tests fail
if: ${{ always() }}
with:
name: artifacts
path: |
dist/*.whl
dist/*.exe
path: dist/*.whl
if-no-files-found: error

# We cannot build and test on ARM64, so we cross-compile.
# Later, when available, we can add tests using this wheel on ARM64 VMs
Expand All @@ -69,7 +67,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13-dev"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4

Expand All @@ -86,21 +84,19 @@ jobs:
run: |
python --version
pip --version
pip install --upgrade setuptools>=74 wheel
pip install --upgrade setuptools>=74 wheel build

- name: Obtain ARM64 library files
run: |
python .github\workflows\download-arm64-libs.py .\arm64libs
run: python .github\workflows\download-arm64-libs.py .\arm64libs

- name: Build wheels
run: python setup.py build_ext -L .\arm64libs --plat-name win-arm64 build --plat-name win-arm64 bdist_wheel --plat-name win-arm64
run: python -m build --wheel --config-setting=--build-option=build_ext --config-setting=--build-option=-L.\arm64libs --config-setting=--build-option=--plat-name=win-arm64 --config-setting=--build-option=build --config-setting=--build-option=--plat-name=win-arm64 --config-setting=--build-option=bdist_wheel --config-setting=--build-option=--plat-name=win-arm64

- uses: actions/upload-artifact@v3
if: ${{ always() }}
with:
name: artifacts
path: |-
dist/*.whl
path: dist/*.whl
if-no-files-found: error

# This job can be run locally by running `pre-commit run`
checkers:
Expand Down Expand Up @@ -134,8 +130,7 @@ jobs:
strategy:
fail-fast: false
matrix:
# mypy won't understand "3.13-dev", keeping the CI simple by just omitting it
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand All @@ -153,7 +148,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13-dev"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ MANIFEST
build
dist
__pycache__
*.exe
*.zip
*.dbg
*.exp
Expand All @@ -14,6 +13,7 @@ __pycache__
*.chw
*.pyo
*.pdb
*.whl
arm64libs/
pywin32.egg-info/
PyWin32.kpf
Expand Down
21 changes: 6 additions & 15 deletions Pythonwin/pywin/framework/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import os
import sys
import traceback
import warnings
from typing import TYPE_CHECKING

import regutil
Expand Down Expand Up @@ -344,27 +345,17 @@ def OnInitDialog(self):
win32ui.copyright, sys.copyright, scintilla, idle, contributors
)
self.SetDlgItemText(win32ui.IDC_EDIT1, text)
# Get the build number - written by installers.
# For distutils build, read pywin32.version.txt
import sysconfig

site_packages = sysconfig.get_paths()["platlib"]
version_path = os.path.join(site_packages, "pywin32.version.txt")
try:
build_no = (
open(os.path.join(site_packages, "pywin32.version.txt")).read().strip()
)
ver = "pywin32 build %s" % build_no
with open(version_path) as f:
ver = "pywin32 build %s" % f.read().strip()
except OSError:
ver = None
if ver is None:
# See if we are Part of Active Python
ver = _GetRegistryValue(
"SOFTWARE\\ActiveState\\ActivePython", "CurrentVersion"
)
if ver is not None:
ver = f"ActivePython build {ver}"
if ver is None:
ver = ""
if not ver:
warnings.warn(f"Could not read pywin32's version from '{version_path}'")
self.SetDlgItemText(win32ui.IDC_ABOUT_VERSION, ver)
self.HookCommand(self.OnButHomePage, win32ui.IDC_BUTTON1)

Expand Down
4 changes: 2 additions & 2 deletions Pythonwin/pywin/framework/mdi_pychecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ def threadPycheckerRun(self):
result = "Can't find python.exe!\n"
elif not os.path.isfile(pychecker):
result = (
"Can't find checker.py - please install pychecker "
"(or run 'setup.py install' if you have the source version)\n"
"Can't find checker.py - please install PyChecker "
"(https://pypi.org/project/PyChecker/)\n"
Comment on lines +365 to +366
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is getting removed by #2412 anyway

)
else:
cmd = f'{py} "{pychecker}" {options} {files} 2>&1'
Expand Down
18 changes: 1 addition & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ See [CHANGES.txt](https://github.com/mhammond/pywin32/blob/master/CHANGES.txt) f
## Docs

The docs are a long and sad story, but [there's now an online version](https://mhammond.github.io/pywin32/)
of the helpfile that ships with the installers (thanks [@ofek](https://github.com/mhammond/pywin32/pull/1774)!).
of the `PyWin32.chm` helpfile (thanks [@ofek](https://github.com/mhammond/pywin32/pull/1774)!).
Lots of that is very old, but some is auto-generated and current. Would love help untangling the docs!

## Support
Expand Down Expand Up @@ -114,22 +114,6 @@ for the version you install.

(the free compilers probably work too, but haven't been tested - let me know your experiences!)

`setup.py` is a standard distutils build script, so you probably want:

```shell
python setup.py install
```

or

```shell
python setup.py --help
```

Some modules need obscure SDKs to build - `setup.py` should succeed, gracefully
telling you why it failed to build them - if the build actually fails with your
configuration, please [open an issue](https://github.com/mhammond/pywin32/issues).

## Release process

The following steps are performed when making a new release - this is mainly
Expand Down
2 changes: 1 addition & 1 deletion adodbapi/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Prerequisites:
and pywin32 (Mark Hammond's python for windows extensions.)

Installation:
* (C-Python on Windows): Install pywin32 ("pip install pywin32") which includes adodbapi.
* (C-Python on Windows): Install pywin32 (`python -m pip install pywin32`) which includes adodbapi.
* (IronPython on Windows): Download adodbapi from http://sf.net/projects/adodbapi. Unpack the zip.

NOTE: ...........
Expand Down
30 changes: 0 additions & 30 deletions build_all.bat

This file was deleted.

12 changes: 7 additions & 5 deletions build_env.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,15 @@ markh hasn't tried with VS2019 - please share your experiences!)

# Build

One everything is setup, just execute:
One everything is setup, just execute the following from the pywin32 directory.:

```shell
python setup.py -q install
pip install . -v
```

from the pywin32 directory.
Some modules need obscure SDKs to build - `pip install` should succeed, gracefully
telling you why it failed to build them with the `-v` flag - if the build actually fails with your
configuration, please [open an issue](https://github.com/mhammond/pywin32/issues).

## Cross-compiling for ARM64 (Microsoft Visual C++ 14.1 and up)

Expand Down Expand Up @@ -155,13 +157,13 @@ from the pywin32 directory.
- Build the extensions, passing the directory from earlier. You may optionally add the `bdist_wheel` command to generate a wheel.

```shell
python setup.py build_ext -L "<temporary path from earlier>" bdist_wheel
python -m build --wheel --config-setting=--build-option=build_ext --config-setting=--build-option=-L.\arm64libs --config-setting=--build-option=--plat-name=win-arm64 --config-setting=--build-option=bdist_wheel --config-setting=--build-option=--plat-name=win-arm64
```

- If you are not using an initialized build environment, you will need to specify the `build_ext`, `build` and `bdist_wheel` commands and pass `--plat-name win-arm64` to *each* of them separately. Otherwise you may get a mixed platform build and/or linker errors.

- Copy the built wheel to the target machine and install directly:

```shell
python -m pip install "<path to wheel>"
pip install "<path to wheel>" -v
```
3 changes: 1 addition & 2 deletions com/win32com/server/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,11 +523,10 @@ def UnregisterClasses(*classes, **flags):
extra()


#
# Unregister info is for installers or external uninstallers.
# The WISE installer, for example firstly registers the COM server,
# then queries for the Unregister info, appending it to its
# install log. Uninstalling the package will the uninstall the server
# install log. Uninstalling the package will uninstall the server.
def UnregisterInfoClasses(*classes, **flags):
ret = []
for cls in classes:
Expand Down
48 changes: 16 additions & 32 deletions make_all.bat
Original file line number Diff line number Diff line change
@@ -1,51 +1,35 @@
@if "%1"=="quick" goto quick
@if "%1"=="already_built" goto already_built
if exist build\. rd /s/q build
if exist build\. goto couldnt_rm
:quick
call build_all.bat
@if errorlevel 1 goto failed
py autoduck\make.py
@if errorlevel 1 goto failed
:already_built
rem Now the binaries.

rem Check /build_env.md#build-environment to make sure you have all the required components installed

rem (bdist_wininst needs --target-version to name the installers correctly!)
py -3.8-32 setup.py -q bdist_wininst --skip-build --target-version=3.8
py -3.8-32 setup.py -q bdist_wheel --skip-build
py -3.8 setup.py -q bdist_wininst --skip-build --target-version=3.8
py -3.8 setup.py -q bdist_wheel --skip-build
py -3.8-32 -m build --wheel
py -3.8 -m build --wheel

py -3.9-32 setup.py -q bdist_wininst --skip-build --target-version=3.9
py -3.9-32 setup.py -q bdist_wheel --skip-build
py -3.9 setup.py -q bdist_wininst --skip-build --target-version=3.9
py -3.9 setup.py -q bdist_wheel --skip-build
py -3.9-32 -m build --wheel
py -3.9 -m build --wheel

rem 3.10 stopped supporting bdist_wininst, but we can still build them with 3.9
rem (but 32bit builds seem broken doing this :( #1805)
py -3.9 setup.py -q bdist_wininst --skip-build --target-version=3.10
py -3.10-32 setup.py -q bdist_wheel --skip-build
py -3.10 setup.py -q bdist_wheel --skip-build
py -3.10-32 -m build --wheel
py -3.10 -m build --wheel

py -3.9 setup.py -q bdist_wininst --skip-build --target-version=3.11
py -3.11-32 setup.py -q bdist_wheel --skip-build
py -3.11 setup.py -q bdist_wheel --skip-build
py -3.11-32 -m build --wheel
py -3.11 -m build --wheel

py -3.9 setup.py -q bdist_wininst --skip-build --target-version=3.12
py -3.12-32 setup.py -q bdist_wheel --skip-build
py -3.12 setup.py -q bdist_wheel --skip-build
py -3.12-32 -m build --wheel
py -3.12 -m build --wheel

py -3.9 setup.py -q bdist_wininst --skip-build --target-version=3.13
py -3.13-32 setup.py -q bdist_wheel --skip-build
py -3.13 setup.py -q bdist_wheel --skip-build
py -3.13-32 -m build --wheel
py -3.13 -m build --wheel

rem Check /build_env.md#build-environment to make sure you have all the required ARM64 components installed
py -3.10 setup.py -q build_ext --plat-name win-arm64 build --plat-name win-arm64 bdist_wheel --plat-name win-arm64
py -3.11 setup.py -q build_ext --plat-name win-arm64 build --plat-name win-arm64 bdist_wheel --plat-name win-arm64
py -3.12 setup.py -q build_ext --plat-name win-arm64 build --plat-name win-arm64 bdist_wheel --plat-name win-arm64
py -3.13 setup.py -q build_ext --plat-name win-arm64 build --plat-name win-arm64 bdist_wheel --plat-name win-arm64
py -3.10 -m build --wheel --config-setting=--build-option=build_ext --config-setting=--build-option=--plat-name=win-arm64 --config-setting=--build-option=build --config-setting=--build-option=--plat-name=win-arm64 --config-setting=--build-option=bdist_wheel --config-setting=--build-option=--plat-name=win-arm64
py -3.11 -m build --wheel --config-setting=--build-option=build_ext --config-setting=--build-option=--plat-name=win-arm64 --config-setting=--build-option=build --config-setting=--build-option=--plat-name=win-arm64 --config-setting=--build-option=bdist_wheel --config-setting=--build-option=--plat-name=win-arm64
py -3.12 -m build --wheel --config-setting=--build-option=build_ext --config-setting=--build-option=--plat-name=win-arm64 --config-setting=--build-option=build --config-setting=--build-option=--plat-name=win-arm64 --config-setting=--build-option=bdist_wheel --config-setting=--build-option=--plat-name=win-arm64
py -3.13 -m build --wheel --config-setting=--build-option=build_ext --config-setting=--build-option=--plat-name=win-arm64 --config-setting=--build-option=build --config-setting=--build-option=--plat-name=win-arm64 --config-setting=--build-option=bdist_wheel --config-setting=--build-option=--plat-name=win-arm64

@goto xit
:couldnt_rm
Expand Down
Loading
Loading