Skip to content

Commit b7f1af7

Browse files
authored
Merge pull request #7230 from nulano/add-pyproject.toml
2 parents 0ac3677 + b2d7f1e commit b7f1af7

File tree

8 files changed

+86
-120
lines changed

8 files changed

+86
-120
lines changed

.appveyor.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ environment:
2020

2121
install:
2222
- '%PYTHON%\%EXECUTABLE% --version'
23+
- '%PYTHON%\%EXECUTABLE% -m pip install --upgrade pip'
2324
- curl -fsSL -o pillow-depends.zip https://github.com/python-pillow/pillow-depends/archive/main.zip
2425
- curl -fsSL -o pillow-test-images.zip https://github.com/python-pillow/test-images/archive/main.zip
2526
- 7z x pillow-depends.zip -oc:\
@@ -37,10 +38,9 @@ install:
3738
- path C:\pillow\winbuild\build\bin;%PATH%
3839

3940
build_script:
40-
- ps: |
41-
c:\pillow\winbuild\build\build_pillow.cmd install
42-
$host.SetShouldExit(0)
4341
- cd c:\pillow
42+
- winbuild\build\build_env.cmd
43+
- '%PYTHON%\%EXECUTABLE% -m pip install -v -C raqm=vendor -C fribidi=vendor .'
4444
- '%PYTHON%\%EXECUTABLE% selftest.py --installed'
4545

4646
test_script:
@@ -62,18 +62,15 @@ cache:
6262
- '%LOCALAPPDATA%\pip\Cache'
6363

6464
artifacts:
65-
- path: pillow\dist\*.egg
65+
- path: pillow\*.egg
6666
name: egg
67-
- path: pillow\dist\*.wheel
67+
- path: pillow\*.whl
6868
name: wheel
6969

7070
before_deploy:
7171
- cd c:\pillow
72-
- '%PYTHON%\%EXECUTABLE% -m pip install wheel'
73-
- cd c:\pillow\winbuild\
74-
- c:\pillow\winbuild\build\build_pillow.cmd bdist_wheel
75-
- cd c:\pillow
76-
- ps: Get-ChildItem .\dist\*.* | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
72+
- '%PYTHON%\%EXECUTABLE% -m pip wheel -v -C raqm=vendor -C fribidi=vendor .'
73+
- ps: Get-ChildItem .\*.whl | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
7774

7875
deploy:
7976
provider: S3

.github/workflows/test-windows.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ jobs:
5757
- name: Print build system information
5858
run: python3 .github/workflows/system-info.py
5959

60-
- name: python3 -m pip install setuptools wheel pytest pytest-cov pytest-timeout defusedxml
61-
run: python3 -m pip install setuptools wheel pytest pytest-cov pytest-timeout defusedxml
60+
- name: python3 -m pip install pytest pytest-cov pytest-timeout defusedxml
61+
run: python3 -m pip install pytest pytest-cov pytest-timeout defusedxml
6262

6363
- name: Install dependencies
6464
id: install
@@ -89,7 +89,7 @@ jobs:
8989
- name: Prepare build
9090
if: steps.build-cache.outputs.cache-hit != 'true'
9191
run: |
92-
& python.exe winbuild\build_prepare.py -v --python $env:pythonLocation
92+
& python.exe winbuild\build_prepare.py -v
9393
shell: pwsh
9494

9595
- name: Build dependencies / libjpeg-turbo
@@ -157,9 +157,9 @@ jobs:
157157

158158
- name: Build Pillow
159159
run: |
160-
$FLAGS=""
161-
if ('${{ github.event_name }}' -ne 'pull_request') { $FLAGS="--disable-imagequant" }
162-
& winbuild\build\build_pillow.cmd $FLAGS install
160+
$FLAGS="-C raqm=vendor -C fribidi=vendor"
161+
if ('${{ github.event_name }}' -ne 'pull_request') { $FLAGS+=" -C imagequant=disable" }
162+
cmd /c "winbuild\build\build_env.cmd && $env:pythonLocation\python.exe -m pip install -v $FLAGS ."
163163
& $env:pythonLocation\python.exe selftest.py --installed
164164
shell: pwsh
165165

@@ -223,15 +223,16 @@ jobs:
223223
)
224224
)
225225
for /f "tokens=3 delims=/" %%a in ("${{ github.ref }}") do echo dist=dist-%%a >> %GITHUB_OUTPUT%
226-
winbuild\\build\\build_pillow.cmd --disable-imagequant bdist_wheel
226+
call winbuild\\build\\build_env.cmd
227+
%pythonLocation%\python.exe -m pip wheel -v -C raqm=vendor -C fribidi=vendor -C imagequant=disable .
227228
shell: cmd
228229

229230
- name: Upload wheel
230231
uses: actions/upload-artifact@v3
231232
if: "github.event_name != 'pull_request'"
232233
with:
233234
name: ${{ steps.wheel.outputs.dist }}
234-
path: dist\*.whl
235+
path: "*.whl"
235236

236237
- name: Upload fribidi.dll
237238
if: "github.event_name != 'pull_request' && matrix.python-version == 3.11"

.pre-commit-config.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,24 @@ repos:
4646
hooks:
4747
- id: check-merge-conflict
4848
- id: check-json
49+
- id: check-toml
4950
- id: check-yaml
5051

5152
- repo: https://github.com/sphinx-contrib/sphinx-lint
5253
rev: v0.6.7
5354
hooks:
5455
- id: sphinx-lint
5556

57+
- repo: https://github.com/tox-dev/pyproject-fmt
58+
rev: 0.12.1
59+
hooks:
60+
- id: pyproject-fmt
61+
62+
- repo: https://github.com/abravalheri/validate-pyproject
63+
rev: v0.13
64+
hooks:
65+
- id: validate-pyproject
66+
5667
- repo: https://github.com/tox-dev/tox-ini-fmt
5768
rev: 1.3.0
5869
hooks:

pyproject.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
[build-system]
2-
requires = ["setuptools >= 40.8.0", "wheel"]
32
build-backend = "backend"
4-
backend-path = ["_custom_build"]
3+
requires = [
4+
"setuptools>=67.8",
5+
"wheel",
6+
]
7+
backend-path = [
8+
"_custom_build",
9+
]

setup.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ class RequiredDependencyException(Exception):
137137

138138

139139
PLATFORM_MINGW = os.name == "nt" and "GCC" in sys.version
140-
PLATFORM_PYPY = hasattr(sys, "pypy_version_info")
141140

142141

143142
def _dbg(s, tp=None):
@@ -848,14 +847,7 @@ def build_extensions(self):
848847
if struct.unpack("h", b"\0\1")[0] == 1:
849848
defs.append(("WORDS_BIGENDIAN", None))
850849

851-
if (
852-
sys.platform == "win32"
853-
and sys.version_info < (3, 9)
854-
and not (PLATFORM_PYPY or PLATFORM_MINGW)
855-
):
856-
defs.append(("PILLOW_VERSION", f'"\\"{PILLOW_VERSION}\\""'))
857-
else:
858-
defs.append(("PILLOW_VERSION", f'"{PILLOW_VERSION}"'))
850+
defs.append(("PILLOW_VERSION", f'"{PILLOW_VERSION}"'))
859851

860852
self._update_extension("PIL._imaging", libs, defs)
861853

winbuild/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ The following is a simplified version of the script used on AppVeyor:
1818
```
1919
set PYTHON=C:\Python38\bin
2020
cd /D C:\Pillow\winbuild
21-
C:\Python39\bin\python.exe build_prepare.py -v --depends=C:\pillow-depends
21+
%PYTHON%\python.exe build_prepare.py -v --depends=C:\pillow-depends
2222
build\build_dep_all.cmd
23-
build\build_pillow.cmd install
2423
cd ..
24+
%PYTHON%\python.exe -m pip install -v -C raqm=vendor -C fribidi=vendor .
2525
path C:\Pillow\winbuild\build\bin;%PATH%
2626
%PYTHON%\python.exe selftest.py
2727
%PYTHON%\python.exe -m pytest -vx --cov PIL --cov Tests --cov-report term --cov-report xml Tests
28-
build\build_pillow.cmd bdist_wheel
28+
%PYTHON%\python.exe -m pip wheel -v -C raqm=vendor -C fribidi=vendor .
2929
```

winbuild/build.rst

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,10 @@ Run ``build_prepare.py`` to configure the build::
4242

4343
usage: winbuild\build_prepare.py [-h] [-v] [-d PILLOW_BUILD]
4444
[--depends PILLOW_DEPS]
45-
[--architecture {x86,x64,ARM64}]
46-
[--python PYTHON] [--executable EXECUTABLE]
47-
[--nmake] [--no-imagequant] [--no-fribidi]
45+
[--architecture {x86,x64,ARM64}] [--nmake]
46+
[--no-imagequant] [--no-fribidi]
4847

49-
Download dependencies and generate build scripts for Pillow.
48+
Download and generate build scripts for Pillow dependencies.
5049

5150
options:
5251
-h, --help show this help message and exit
@@ -58,17 +57,13 @@ Run ``build_prepare.py`` to configure the build::
5857
'winbuild\depends')
5958
--architecture {x86,x64,ARM64}
6059
build architecture (default: same as host Python)
61-
--python PYTHON Python install directory (default: use host Python)
62-
--executable EXECUTABLE
63-
Python executable (default: use host Python)
6460
--nmake build dependencies using NMake instead of Ninja
6561
--no-imagequant skip GPL-licensed optional dependency libimagequant
6662
--no-fribidi, --no-raqm
6763
skip LGPL-licensed optional dependency FriBiDi
6864

6965
Arguments can also be supplied using the environment variables PILLOW_BUILD,
70-
PILLOW_DEPS, ARCHITECTURE, PYTHON, EXECUTABLE. See winbuild\build.rst for more
71-
information.
66+
PILLOW_DEPS, ARCHITECTURE. See winbuild\build.rst for more information.
7267

7368
**Warning:** The build directory is wiped when ``build_prepare.py`` is run.
7469

@@ -86,14 +81,16 @@ or run the individual scripts in order to build each dependency separately.
8681
Building Pillow
8782
---------------
8883

89-
Once the dependencies are built, run
90-
``winbuild\build\build_pillow.cmd install`` to build and install
91-
Pillow for the selected version of Python.
92-
``winbuild\build\build_pillow.cmd bdist_wheel`` will build wheels
93-
instead of installing Pillow.
84+
Once the dependencies are built, make sure the required environment variables
85+
are set by running ``winbuild\build\build_env.cmd`` and install Pillow with pip::
9486

95-
You can also use ``winbuild\build\build_pillow.cmd --inplace develop`` to build
96-
and install Pillow in develop mode (instead of ``python3 -m pip install --editable``).
87+
winbuild\build\build_env.cmd
88+
python.exe -m pip install -v -C raqm=vendor -C fribidi=vendor .
89+
90+
To build a wheel instead, run::
91+
92+
winbuild\build\build_env.cmd
93+
python.exe -m pip wheel -v -C raqm=vendor -C fribidi=vendor .
9794

9895
Testing Pillow
9996
--------------
@@ -112,11 +109,12 @@ The following is a simplified version of the script used on AppVeyor::
112109

113110
set PYTHON=C:\Python38\bin
114111
cd /D C:\Pillow\winbuild
115-
C:\Python39\bin\python.exe build_prepare.py -v --depends C:\pillow-depends
112+
%PYTHON%\python.exe build_prepare.py -v --depends C:\pillow-depends
116113
build\build_dep_all.cmd
117-
build\build_pillow.cmd install
114+
build\build_env.cmd
118115
cd ..
116+
%PYTHON%\python.exe -m pip install -v -C raqm=vendor -C fribidi=vendor .
119117
path C:\Pillow\winbuild\build\bin;%PATH%
120118
%PYTHON%\python.exe selftest.py
121119
%PYTHON%\python.exe -m pytest -vx --cov PIL --cov Tests --cov-report term --cov-report xml Tests
122-
build\build_pillow.cmd bdist_wheel
120+
%PYTHON%\python.exe -m pip wheel -v -C raqm=vendor -C fribidi=vendor .

0 commit comments

Comments
 (0)