Skip to content

Commit 8abff14

Browse files
authored
Merge pull request #6072 from hugovk/extras_require
Replace requirements.txt with extras
2 parents 2559913 + 0056332 commit 8abff14

File tree

8 files changed

+106
-59
lines changed

8 files changed

+106
-59
lines changed

.readthedocs.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1+
version: 2
2+
13
python:
2-
pip_install: true
4+
install:
5+
- method: pip
6+
path: .
7+
extra_requirements:
8+
- docs

Makefile

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ clean:
99

1010
.PHONY: coverage
1111
coverage:
12-
pytest -qq
12+
python3 -c "import pytest" > /dev/null 2>&1 || python3 -m pip install pytest
13+
python3 -m pytest -qq
1314
rm -r htmlcov || true
14-
coverage report
15+
python3 -c "import coverage" > /dev/null 2>&1 || python3 -m pip install coverage
16+
python3 -m coverage report
1517

1618
.PHONY: doc
1719
doc:
@@ -33,20 +35,16 @@ help:
3335
@echo "Welcome to Pillow development. Please use \`make <target>\` where <target> is one of"
3436
@echo " clean remove build products"
3537
@echo " coverage run coverage test (in progress)"
36-
@echo " doc make html docs"
37-
@echo " docserve run an http server on the docs directory"
38+
@echo " doc make HTML docs"
39+
@echo " docserve run an HTTP server on the docs directory"
3840
@echo " html to make standalone HTML files"
3941
@echo " inplace make inplace extension"
4042
@echo " install make and install"
4143
@echo " install-coverage make and install with C coverage"
42-
@echo " install-req install documentation and test dependencies"
43-
@echo " install-venv (deprecated) install in virtualenv"
4444
@echo " lint run the lint checks"
45-
@echo " lint-fix run black and isort to (mostly) fix lint issues."
45+
@echo " lint-fix run Black and isort to (mostly) fix lint issues"
4646
@echo " release-test run code and package tests before release"
47-
@echo " test run tests on installed pillow"
48-
@echo " upload build and upload sdists to PyPI"
49-
@echo " upload-test build and upload sdists to test.pythonpackages.com"
47+
@echo " test run tests on installed Pillow"
5048

5149
.PHONY: inplace
5250
inplace: clean
@@ -70,28 +68,17 @@ debug:
7068
make clean > /dev/null
7169
CFLAGS='-g -O0' python3 -m pip install --global-option="build_ext" . > /dev/null
7270

73-
.PHONY: install-req
74-
install-req:
75-
python3 -m pip install -r requirements.txt
76-
77-
.PHONY: install-venv
78-
install-venv:
79-
echo "'install-venv' is deprecated and will be removed in a future Pillow release"
80-
virtualenv .
81-
bin/pip install -r requirements.txt
82-
8371
.PHONY: release-test
8472
release-test:
85-
$(MAKE) install-req
86-
python3 -m pip install -e .
73+
python3 -m pip install -e .[tests]
8774
python3 selftest.py
8875
python3 -m pytest Tests
8976
python3 -m pip install .
9077
-rm dist/*.egg
9178
-rmdir dist
9279
python3 -m pytest -qq
93-
check-manifest
94-
pyroma .
80+
python3 -m check-manifest
81+
python3 -m pyroma .
9582
$(MAKE) readme
9683

9784
.PHONY: sdist
@@ -101,26 +88,30 @@ sdist:
10188

10289
.PHONY: test
10390
test:
104-
pytest -qq
91+
python3 -c "import pytest" > /dev/null 2>&1 || python3 -m pip install pytest
92+
python3 -m pytest -qq
10593

10694
.PHONY: valgrind
10795
valgrind:
108-
python3 -c "import pytest_valgrind" || python3 -m pip install pytest-valgrind
96+
python3 -c "import pytest_valgrind" > /dev/null 2>&1 || python3 -m pip install pytest-valgrind
10997
PYTHONMALLOC=malloc valgrind --suppressions=Tests/oss-fuzz/python.supp --leak-check=no \
11098
--log-file=/tmp/valgrind-output \
11199
python3 -m pytest --no-memcheck -vv --valgrind --valgrind-log=/tmp/valgrind-output
112100

113101
.PHONY: readme
114102
readme:
115-
markdown2 README.md > .long-description.html && open .long-description.html
103+
python3 -c "import markdown2" > /dev/null 2>&1 || python3 -m pip install markdown2
104+
python3 -m markdown2 README.md > .long-description.html && open .long-description.html
116105

117106

118107
.PHONY: lint
119108
lint:
120-
tox --help > /dev/null || python3 -m pip install tox
121-
tox -e lint
109+
python3 -c "import tox" > /dev/null 2>&1 || python3 -m pip install tox
110+
python3 -m tox -e lint
122111

123112
.PHONY: lint-fix
124113
lint-fix:
125-
black --target-version py37 .
126-
isort .
114+
python3 -c "import black" > /dev/null 2>&1 || python3 -m pip install black
115+
python3 -c "import isort" > /dev/null 2>&1 || python3 -m pip install isort
116+
python3 -m black --target-version py37 .
117+
python3 -m isort .

docs/Makefile

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# You can set these variables from the command line.
55
SPHINXOPTS =
6-
SPHINXBUILD = sphinx-build
6+
SPHINXBUILD = python3 -m sphinx.cmd.build
77
PAPER =
88
BUILDDIR = _build
99

@@ -41,38 +41,48 @@ help:
4141
clean:
4242
-rm -rf $(BUILDDIR)/*
4343

44+
install-sphinx:
45+
python3 -c "import sphinx" > /dev/null 2>&1 || python3 -m pip install sphinx
46+
4447
html:
48+
$(MAKE) install-sphinx
4549
$(SPHINXBUILD) -b html -W --keep-going $(ALLSPHINXOPTS) $(BUILDDIR)/html
4650
@echo
4751
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
4852

4953
dirhtml:
54+
$(MAKE) install-sphinx
5055
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
5156
@echo
5257
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
5358

5459
singlehtml:
60+
$(MAKE) install-sphinx
5561
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
5662
@echo
5763
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
5864

5965
pickle:
66+
$(MAKE) install-sphinx
6067
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
6168
@echo
6269
@echo "Build finished; now you can process the pickle files."
6370

6471
json:
72+
$(MAKE) install-sphinx
6573
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
6674
@echo
6775
@echo "Build finished; now you can process the JSON files."
6876

6977
htmlhelp:
78+
$(MAKE) install-sphinx
7079
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
7180
@echo
7281
@echo "Build finished; now you can run HTML Help Workshop with the" \
7382
".hhp project file in $(BUILDDIR)/htmlhelp."
7483

7584
qthelp:
85+
$(MAKE) install-sphinx
7686
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
7787
@echo
7888
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
@@ -82,6 +92,7 @@ qthelp:
8292
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/PillowPILfork.qhc"
8393

8494
devhelp:
95+
$(MAKE) install-sphinx
8596
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
8697
@echo
8798
@echo "Build finished."
@@ -91,63 +102,74 @@ devhelp:
91102
@echo "# devhelp"
92103

93104
epub:
105+
$(MAKE) install-sphinx
94106
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
95107
@echo
96108
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
97109

98110
latex:
111+
$(MAKE) install-sphinx
99112
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
100113
@echo
101114
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
102115
@echo "Run \`make' in that directory to run these through (pdf)latex" \
103116
"(use \`make latexpdf' here to do that automatically)."
104117

105118
latexpdf:
119+
$(MAKE) install-sphinx
106120
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
107121
@echo "Running LaTeX files through pdflatex..."
108122
$(MAKE) -C $(BUILDDIR)/latex all-pdf
109123
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
110124

111125
text:
126+
$(MAKE) install-sphinx
112127
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
113128
@echo
114129
@echo "Build finished. The text files are in $(BUILDDIR)/text."
115130

116131
man:
132+
$(MAKE) install-sphinx
117133
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
118134
@echo
119135
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
120136

121137
texinfo:
138+
$(MAKE) install-sphinx
122139
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
123140
@echo
124141
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
125142
@echo "Run \`make' in that directory to run these through makeinfo" \
126143
"(use \`make info' here to do that automatically)."
127144

128145
info:
146+
$(MAKE) install-sphinx
129147
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
130148
@echo "Running Texinfo files through makeinfo..."
131149
make -C $(BUILDDIR)/texinfo info
132150
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
133151

134152
gettext:
153+
$(MAKE) install-sphinx
135154
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
136155
@echo
137156
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
138157

139158
changes:
159+
$(MAKE) install-sphinx
140160
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
141161
@echo
142162
@echo "The overview file is in $(BUILDDIR)/changes."
143163

144164
linkcheck:
165+
$(MAKE) install-sphinx
145166
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck -j auto
146167
@echo
147168
@echo "Link check complete; look for any errors in the above output " \
148169
"or in $(BUILDDIR)/linkcheck/output.txt."
149170

150171
doctest:
172+
$(MAKE) install-sphinx
151173
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
152174
@echo "Testing of doctests in the sources finished, look at the " \
153175
"results in $(BUILDDIR)/doctest/output.txt."

docs/reference/c_extension_debugging.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Then ``sudo apt-get update && sudo apt-get install libtiff5-dbgsym``
5353

5454
virtualenv -p python3.8-dbg ~/vpy38-dbg
5555
source ~/vpy38-dbg/bin/activate
56-
cd ~/Pillow && pip install -r requirements.txt && make install
56+
cd ~/Pillow && make install
5757

5858
Test Case
5959
---------

docs/releasenotes/9.1.0.rst

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,37 @@ Rather than returning a ``SystemError``, passing the incorrect types of coordina
1818
a path will now raise a more specific ``ValueError``, with the message "incorrect
1919
coordinate type".
2020

21+
Replace requirements.txt with extras
22+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
23+
24+
Rather than installing all dependencies for docs and tests via ``requirements.txt``,
25+
``extras_require`` is used instead. This installs only those needed and at the same
26+
time as installing Pillow.
27+
28+
For example:
29+
30+
.. code-block:: bash
31+
32+
# Install with dependencies for tests:
33+
python3 -m pip install .[tests]
34+
35+
# Or for building docs:
36+
python3 -m pip install .[docs]
37+
38+
# Or for all:
39+
python3 -m pip install .[docs,tests]
40+
41+
On macOS, the last argument may need to be wrapped in quotes, e.g.
42+
``python3 -m pip install ".[tests]"``
43+
44+
Therefore ``requirements.txt`` has been removed along with the ``make install-req``
45+
command for installing its contents.
46+
2147
Deprecations
22-
^^^^^^^^^^^^
48+
============
2349

2450
Constants
25-
~~~~~~~~~
51+
^^^^^^^^^
2652

2753
A number of constants have been deprecated and will be removed in Pillow 10.0.0
2854
(2023-07-01). Instead, ``enum.IntEnum`` classes have been added.
@@ -87,7 +113,7 @@ Deprecated Use instead
87113
===================================================== ============================================================
88114

89115
ImageShow.Viewer.show_file file argument
90-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
116+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
91117

92118
The ``file`` argument in :py:meth:`~PIL.ImageShow.Viewer.show_file()` has been
93119
deprecated and will be removed in Pillow 10.0.0 (2023-07-01). It has been replaced by
@@ -98,7 +124,7 @@ In effect, ``viewer.show_file("test.jpg")`` will continue to work unchanged.
98124
``viewer.show_file(path="test.jpg")`` instead.
99125

100126
FitsStubImagePlugin
101-
~~~~~~~~~~~~~~~~~~~
127+
^^^^^^^^^^^^^^^^^^^
102128

103129
.. deprecated:: 9.1.0
104130

requirements.txt

Lines changed: 0 additions & 18 deletions
This file was deleted.

setup.cfg

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,27 @@ project_urls =
3535
[options]
3636
python_requires = >=3.7
3737

38+
[options.extras_require]
39+
docs =
40+
olefile
41+
sphinx>=2.4
42+
sphinx-copybutton
43+
sphinx-issues>=3.0.1
44+
sphinx-removed-in
45+
sphinx-rtd-theme>=1.0
46+
sphinxext-opengraph
47+
tests =
48+
check-manifest
49+
coverage
50+
defusedxml
51+
markdown2
52+
olefile
53+
packaging
54+
pyroma
55+
pytest
56+
pytest-cov
57+
pytest-timeout
58+
3859
[flake8]
3960
extend-ignore = E203
4061
max-line-length = 88

tox.ini

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ envlist =
1010
minversion = 1.9
1111

1212
[testenv]
13+
extras =
14+
tests
1315
commands =
1416
make clean
1517
{envpython} -m pip install --global-option="build_ext" --global-option="--inplace" .
@@ -18,9 +20,6 @@ commands =
1820
deps =
1921
cffi
2022
numpy
21-
olefile
22-
pyroma
23-
pytest
2423

2524
[testenv:lint]
2625
commands =

0 commit comments

Comments
 (0)