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

Merged
merged 22 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1398dea
Removing EXE binary installers code paths
Avasam Oct 11, 2024
263055d
Simplify long_description
Avasam Oct 12, 2024
1242af0
Python 3.7 builds
Avasam Oct 12, 2024
0123ecc
Merge branch 'main' of https://github.com/mhammond/pywin32 into Remov…
Avasam Oct 13, 2024
8d6a699
Remove .exe from searched artefacts
Avasam Oct 13, 2024
2080fc3
Stop calling setup.py
Avasam Oct 13, 2024
a926c1f
Removing EXE binary installers code paths
Avasam Oct 13, 2024
e478814
Merge branch 'main' of https://github.com/mhammond/pywin32 into Remov…
Avasam Oct 13, 2024
f1e91f3
PR comments
Avasam Oct 13, 2024
5d117b5
Mention lack of postinstall script in wheels
Avasam Oct 13, 2024
8041aaf
Merge branch 'main' of https://github.com/mhammond/pywin32 into Stop-…
Avasam Oct 13, 2024
0fd62ee
install build module
Avasam Oct 13, 2024
ec5e70a
try multiple --config-setting=--build-option=
Avasam Oct 18, 2024
03632ea
Fixed all --config-setting=--build-option=
Avasam Oct 18, 2024
2c04533
Merge branch 'main' of https://github.com/mhammond/pywin32 into Stop-…
Avasam Oct 18, 2024
9f7bac9
Merge branch 'main' of https://github.com/mhammond/pywin32 into Remov…
Avasam Oct 18, 2024
81e4108
Merge branch 'Removing-EXE-binary-installers' of https://github.com/A…
Avasam Oct 18, 2024
f6e62c3
rerun black
Avasam Oct 18, 2024
475103f
Rerun pycln
Avasam Oct 18, 2024
a0d6bdb
pip wheel into dist
Avasam Oct 18, 2024
af3b4de
Merge branch 'main' of https://github.com/mhammond/pywin32 into Stop-…
Avasam Dec 12, 2024
ee924f1
Add a line about build instructions
Avasam Dec 12, 2024
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
28 changes: 12 additions & 16 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,8 +40,7 @@ jobs:
pip install --upgrade setuptools>=74 wheel

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

# This needs to happen *after* installing pywin32 since
# AutoDuck/py2d.py currently relies on runtime imports for introspection
Expand All @@ -56,15 +55,15 @@ jobs:
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
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 @@ -75,7 +74,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 @@ -92,21 +91,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 @@ -139,8 +136,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 @@ -158,7 +154,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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ __pycache__
*.chw
*.pyo
*.pdb
*.whl
arm64libs/
pywin32.egg-info/
PyWin32.kpf
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 @@ -361,8 +361,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 +364 to +365
Copy link
Collaborator Author

@Avasam Avasam Oct 18, 2024

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
(merging that first would reduce changes here by 1 file, but they can be done in any order)

)
else:
cmd = f'{py} "{pychecker}" {options} {files} 2>&1'
Expand Down
24 changes: 4 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ To run as a service, you probably want to install pywin32 globally from an eleva
command prompt - see above.

You also need to ensure Python is installed in a location where the user running
the service has access to the installation and is able to load `pywintypesXX.dll` and `pythonXX.dll`. In particular, the `LocalSystem` account typically will not have access
to your local `%USER%` directory structure.
the service has access to the installation and is able to load `pywintypesXX.dll` and `pythonXX.dll`.
In particular, the `LocalSystem` account typically will not have access to your local `%USER%` directory structure.

## Troubleshooting

Expand Down Expand Up @@ -112,23 +112,7 @@ Install Visual Studio 2019 (later probably works, but options might be different
follow the instructions in [Build environment](/build_env.md#build-environment)
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).
Then follow the [Build](/build_env.md#build) instructions for the build itself (including ARM64 cross-compilation).

## Release process

Expand All @@ -147,7 +131,7 @@ Since build 307 the release process is based on the artifacts created by Github
* Push these changes to github, wait for the actions to complete, then
download the artifacts from that run.

* Upload .whl artifacts to pypi - we do this before pushing the tag because they might be
* Upload `.whl` artifacts to pypi - we do this before pushing the tag because they might be
rejected for an invalid `README.md`. Done via `py -3.? -m twine upload dist/*XXX*.whl`.

* Create a new git tag for the release.
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 @@ where mc

# Build

One everything is setup, just execute:
Once 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
```
37 changes: 16 additions & 21 deletions make_all.bat
Original file line number Diff line number Diff line change
@@ -1,40 +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

py -3.8-32 setup.py -q bdist_wheel --skip-build
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_wheel --skip-build
py -3.9 setup.py -q bdist_wheel --skip-build
py -3.9-32 -m build --wheel
py -3.9 -m build --wheel

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.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.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.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
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

To build and install locally for testing etc, you need a build environment
which is capable of building the version of Python you are targeting, then:
python setup.py -q install
pip install . -v

For a debug (_d) version, you need a local debug build of Python, but must use
the release version executable for the build. eg:
python setup.py -q build --debug install
pip install . -v --config-setting=--build-option=build --config-setting=--build-option=--debug

Cross-compilation from x86 to ARM is well supported (assuming installed vs tools etc) - eg:
python setup.py -q build_ext --plat-name win-arm64 build --plat-name win-arm64 bdist_wheel --plat-name win-arm64
python -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

Some modules require special SDKs or toolkits to build (eg, mapi/exchange),
which often aren't available in CI. The build process treats them as optional -
Expand Down
2 changes: 1 addition & 1 deletion win32/Demos/c_extension/setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# A sample distutils script to show to build your own
# extension module which extends pywintypes or pythoncom.
#
# Use 'python setup.py build' to build this extension.
# Use 'python -m build' to build this extension.
import os
from setuptools import Extension, setup
from sysconfig import get_paths
Expand Down
2 changes: 1 addition & 1 deletion win32/Lib/pywintypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def __import_pywin32_system_module__(modname, globs):

# There are 2 site-packages directories - one "global" and one "user".
# We could be in either, or both (but with different versions!). Factors include
# virtualenvs, post-install script being run or not, `setup.py install` flags, etc.
# virtualenvs, post-install script being run or not, `pip install` flags, etc.

# In a worst-case, it means, say 'python -c "import win32api"'
# will not work but 'python -c "import pywintypes, win32api"' will,
Expand Down