From b14aa51037ee810b9db3eb9bc4c6c494d621a0bb Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sat, 19 Feb 2022 15:39:37 +0200 Subject: [PATCH 01/13] Replace requirements.txt with extras_require --- Makefile | 9 +-------- docs/reference/c_extension_debugging.rst | 2 +- requirements.txt | 18 ------------------ setup.cfg | 20 ++++++++++++++++++++ tox.ini | 5 ++--- 5 files changed, 24 insertions(+), 30 deletions(-) delete mode 100644 requirements.txt diff --git a/Makefile b/Makefile index 74a6a5ab209..0c018ad5d24 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,6 @@ help: @echo " inplace make inplace extension" @echo " install make and install" @echo " install-coverage make and install with C coverage" - @echo " install-req install documentation and test dependencies" @echo " install-venv (deprecated) install in virtualenv" @echo " lint run the lint checks" @echo " lint-fix run black and isort to (mostly) fix lint issues." @@ -70,20 +69,14 @@ debug: make clean > /dev/null CFLAGS='-g -O0' python3 -m pip install --global-option="build_ext" . > /dev/null -.PHONY: install-req -install-req: - python3 -m pip install -r requirements.txt - .PHONY: install-venv install-venv: echo "'install-venv' is deprecated and will be removed in a future Pillow release" virtualenv . - bin/pip install -r requirements.txt .PHONY: release-test release-test: - $(MAKE) install-req - python3 -m pip install -e . + python3 -m pip install -e .[tests] python3 selftest.py python3 -m pytest Tests python3 -m pip install . diff --git a/docs/reference/c_extension_debugging.rst b/docs/reference/c_extension_debugging.rst index 2ba95b8a6bc..dc4c2bf94d0 100644 --- a/docs/reference/c_extension_debugging.rst +++ b/docs/reference/c_extension_debugging.rst @@ -53,7 +53,7 @@ Then ``sudo apt-get update && sudo apt-get install libtiff5-dbgsym`` virtualenv -p python3.8-dbg ~/vpy38-dbg source ~/vpy38-dbg/bin/activate - cd ~/Pillow && pip install -r requirements.txt && make install + cd ~/Pillow && make install Test Case --------- diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 1e150e304b2..00000000000 --- a/requirements.txt +++ /dev/null @@ -1,18 +0,0 @@ -# Development, documentation & testing requirements. -black -check-manifest -coverage -defusedxml -markdown2 -olefile -packaging -pyroma -pytest -pytest-cov -pytest-timeout -sphinx>=2.4 -sphinx-copybutton -sphinx-issues>=3.0.1 -sphinx-removed-in -sphinx-rtd-theme>=1.0 -sphinxext-opengraph diff --git a/setup.cfg b/setup.cfg index c3b5a319750..5406716f759 100644 --- a/setup.cfg +++ b/setup.cfg @@ -35,6 +35,26 @@ project_urls = [options] python_requires = >=3.7 +[options.extras_require] +docs = + sphinx>=2.4 + sphinx-copybutton + sphinx-issues>=3.0.1 + sphinx-removed-in + sphinx-rtd-theme>=1.0 + sphinxext-opengraph +tests = + check-manifest + coverage + defusedxml + markdown2 + olefile + packaging + pyroma + pytest + pytest-cov + pytest-timeout + [flake8] extend-ignore = E203 max-line-length = 88 diff --git a/tox.ini b/tox.ini index bdedc2bd5dd..09db058845a 100644 --- a/tox.ini +++ b/tox.ini @@ -10,6 +10,8 @@ envlist = minversion = 1.9 [testenv] +extras = + tests commands = make clean {envpython} -m pip install --global-option="build_ext" --global-option="--inplace" . @@ -18,9 +20,6 @@ commands = deps = cffi numpy - olefile - pyroma - pytest [testenv:lint] commands = From c4f783e099d2928c12a2b2174faf11a2204f6e19 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sat, 19 Feb 2022 15:48:23 +0200 Subject: [PATCH 02/13] Install for docs build using 'pip install .[docs]' --- .readthedocs.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 73e1f821366..0f581ebba90 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,2 +1,8 @@ +version: 2 + python: - pip_install: true + install: + - method: pip + path: . + extra_requirements: + - docs From 3f06b0e3d59776da0265937df5612f47c10898bb Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sat, 19 Feb 2022 16:43:33 +0200 Subject: [PATCH 03/13] Docs: olefile required FpxImagePlugin and MicImagePlugin --- setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.cfg b/setup.cfg index 5406716f759..5ca5831cfd8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -37,6 +37,7 @@ python_requires = >=3.7 [options.extras_require] docs = + olefile sphinx>=2.4 sphinx-copybutton sphinx-issues>=3.0.1 From 247809aa54990c714fc5ecad9de436b89981ecb2 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sat, 19 Feb 2022 16:47:39 +0200 Subject: [PATCH 04/13] Remove non-existent commands from help --- Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Makefile b/Makefile index 0c018ad5d24..a7738ef0cc1 100644 --- a/Makefile +++ b/Makefile @@ -44,8 +44,6 @@ help: @echo " lint-fix run black and isort to (mostly) fix lint issues." @echo " release-test run code and package tests before release" @echo " test run tests on installed pillow" - @echo " upload build and upload sdists to PyPI" - @echo " upload-test build and upload sdists to test.pythonpackages.com" .PHONY: inplace inplace: clean From 8c52290b9452850dd825420b1c733df517b509fa Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sat, 19 Feb 2022 16:47:59 +0200 Subject: [PATCH 05/13] Capitalisation --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index a7738ef0cc1..a7ca1adc23d 100644 --- a/Makefile +++ b/Makefile @@ -33,17 +33,17 @@ help: @echo "Welcome to Pillow development. Please use \`make \` where is one of" @echo " clean remove build products" @echo " coverage run coverage test (in progress)" - @echo " doc make html docs" - @echo " docserve run an http server on the docs directory" + @echo " doc make HTML docs" + @echo " docserve run an HTTP server on the docs directory" @echo " html to make standalone HTML files" @echo " inplace make inplace extension" @echo " install make and install" @echo " install-coverage make and install with C coverage" @echo " install-venv (deprecated) install in virtualenv" @echo " lint run the lint checks" - @echo " lint-fix run black and isort to (mostly) fix lint issues." + @echo " lint-fix run Black and isort to (mostly) fix lint issues" @echo " release-test run code and package tests before release" - @echo " test run tests on installed pillow" + @echo " test run tests on installed Pillow" .PHONY: inplace inplace: clean From c0e770c3c9aff2b385f84c61be3abcc7128949fd Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 22 Feb 2022 11:54:42 +1100 Subject: [PATCH 06/13] Invoke commands through python3 --- Makefile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index a7ca1adc23d..f517c9b8806 100644 --- a/Makefile +++ b/Makefile @@ -81,8 +81,8 @@ release-test: -rm dist/*.egg -rmdir dist python3 -m pytest -qq - check-manifest - pyroma . + python3 -m check-manifest + python3 -m pyroma . $(MAKE) readme .PHONY: sdist @@ -92,7 +92,7 @@ sdist: .PHONY: test test: - pytest -qq + python3 -m pytest -qq .PHONY: valgrind valgrind: @@ -103,15 +103,15 @@ valgrind: .PHONY: readme readme: - markdown2 README.md > .long-description.html && open .long-description.html + python3 -m markdown2 README.md > .long-description.html && open .long-description.html .PHONY: lint lint: - tox --help > /dev/null || python3 -m pip install tox - tox -e lint + python3 -c "import tox" || python3 -m pip install tox + python3 -m tox -e lint .PHONY: lint-fix lint-fix: - black --target-version py37 . - isort . + python3 -m black --target-version py37 . + python3 -m isort . From 7566f8c3b2e2ab082fbfc643f6c0f736b4cf047d Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 22 Feb 2022 11:56:03 +1100 Subject: [PATCH 07/13] Ensure dependencies are installed --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index f517c9b8806..f5d7036493b 100644 --- a/Makefile +++ b/Makefile @@ -92,6 +92,7 @@ sdist: .PHONY: test test: + python3 -c "import pytest" || python3 -m pip install pytest python3 -m pytest -qq .PHONY: valgrind @@ -103,6 +104,7 @@ valgrind: .PHONY: readme readme: + python3 -c "import markdown2" || python3 -m pip install markdown2 python3 -m markdown2 README.md > .long-description.html && open .long-description.html @@ -113,5 +115,7 @@ lint: .PHONY: lint-fix lint-fix: + python3 -c "import black" || python3 -m pip install black + python3 -c "import isort" || python3 -m pip install isort python3 -m black --target-version py37 . python3 -m isort . From c55d5d24018bd32fe99644bfc47fe9b9db87875b Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Thu, 24 Feb 2022 17:59:19 +0200 Subject: [PATCH 08/13] Document requirements.txt -> extras_require in release notes --- docs/releasenotes/9.1.0.rst | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/docs/releasenotes/9.1.0.rst b/docs/releasenotes/9.1.0.rst index f377656b3a1..3870774cd07 100644 --- a/docs/releasenotes/9.1.0.rst +++ b/docs/releasenotes/9.1.0.rst @@ -18,8 +18,31 @@ Rather than returning a ``SystemError``, passing the incorrect types of coordina a path will now raise a more specific ``ValueError``, with the message "incorrect coordinate type". +Replace requirements.txt with extras +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Rather than installing all dependencies for docs and tests via ``requirements.txt``, +``extras_require`` is used instead. This installs only those needed and at the same +time as installing Pillow. + +For example: + +.. code-block:: bash + + # Install with dependencies for tests: + python3 -m pip install .[tests] + + # Or for building docs: + python3 -m pip install .[docs] + + # Or for all: + python3 -m pip install .[docs,tests] + +Therefore ``requirements.txt`` has been removed along with the ``make install-req`` +command for installing its contents. + Deprecations -^^^^^^^^^^^^ +============ Constants ~~~~~~~~~ @@ -87,7 +110,7 @@ Deprecated Use instead ===================================================== ============================================================ ImageShow.Viewer.show_file file argument -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The ``file`` argument in :py:meth:`~PIL.ImageShow.Viewer.show_file()` has been deprecated and will be removed in Pillow 10.0.0 (2023-07-01). It has been replaced by From dac5dfc35bd06ab340b73ae1cc94c547dcd6fc0c Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Fri, 25 Feb 2022 10:24:29 +1100 Subject: [PATCH 09/13] Changed level of other Deprecations subheadings to be consistent --- docs/releasenotes/9.1.0.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/releasenotes/9.1.0.rst b/docs/releasenotes/9.1.0.rst index 3870774cd07..a0b0b5eb7ef 100644 --- a/docs/releasenotes/9.1.0.rst +++ b/docs/releasenotes/9.1.0.rst @@ -45,7 +45,7 @@ Deprecations ============ Constants -~~~~~~~~~ +^^^^^^^^^ A number of constants have been deprecated and will be removed in Pillow 10.0.0 (2023-07-01). Instead, ``enum.IntEnum`` classes have been added. @@ -121,7 +121,7 @@ In effect, ``viewer.show_file("test.jpg")`` will continue to work unchanged. ``viewer.show_file(path="test.jpg")`` instead. FitsStubImagePlugin -~~~~~~~~~~~~~~~~~~~ +^^^^^^^^^^^^^^^^^^^ .. deprecated:: 9.1.0 From 62a80867d67e2339b0136e8b72f611bafb1470af Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Thu, 24 Feb 2022 10:20:15 +1100 Subject: [PATCH 10/13] Removed deprecated install-venv --- Makefile | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Makefile b/Makefile index f5d7036493b..5eb032d8875 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,6 @@ help: @echo " inplace make inplace extension" @echo " install make and install" @echo " install-coverage make and install with C coverage" - @echo " install-venv (deprecated) install in virtualenv" @echo " lint run the lint checks" @echo " lint-fix run Black and isort to (mostly) fix lint issues" @echo " release-test run code and package tests before release" @@ -67,11 +66,6 @@ debug: make clean > /dev/null CFLAGS='-g -O0' python3 -m pip install --global-option="build_ext" . > /dev/null -.PHONY: install-venv -install-venv: - echo "'install-venv' is deprecated and will be removed in a future Pillow release" - virtualenv . - .PHONY: release-test release-test: python3 -m pip install -e .[tests] From fa1e89ff847fd7a71620f5363b0ce7b44c1d58a5 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Thu, 24 Feb 2022 11:01:05 +1100 Subject: [PATCH 11/13] Further invoking of commands through python3 --- Makefile | 4 ++-- docs/Makefile | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 5eb032d8875..604f35bd886 100644 --- a/Makefile +++ b/Makefile @@ -9,9 +9,9 @@ clean: .PHONY: coverage coverage: - pytest -qq + python3 -m pytest -qq rm -r htmlcov || true - coverage report + python3 -m coverage report .PHONY: doc doc: diff --git a/docs/Makefile b/docs/Makefile index 686f0119e37..549ca2c744c 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -3,7 +3,7 @@ # You can set these variables from the command line. SPHINXOPTS = -SPHINXBUILD = sphinx-build +SPHINXBUILD = python3 -m sphinx.cmd.build PAPER = BUILDDIR = _build From 2e71925ee91a4e013a65d8219b1d1789405a7fdb Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Fri, 25 Feb 2022 10:37:38 +1100 Subject: [PATCH 12/13] Further ensuring dependencies are installed --- Makefile | 14 ++++++++------ docs/Makefile | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 604f35bd886..26359859965 100644 --- a/Makefile +++ b/Makefile @@ -9,8 +9,10 @@ clean: .PHONY: coverage coverage: + python3 -c "import pytest" > /dev/null 2>&1 || python3 -m pip install pytest python3 -m pytest -qq rm -r htmlcov || true + python3 -c "import coverage" > /dev/null 2>&1 || python3 -m pip install coverage python3 -m coverage report .PHONY: doc @@ -86,30 +88,30 @@ sdist: .PHONY: test test: - python3 -c "import pytest" || python3 -m pip install pytest + python3 -c "import pytest" > /dev/null 2>&1 || python3 -m pip install pytest python3 -m pytest -qq .PHONY: valgrind valgrind: - python3 -c "import pytest_valgrind" || python3 -m pip install pytest-valgrind + python3 -c "import pytest_valgrind" > /dev/null 2>&1 || python3 -m pip install pytest-valgrind PYTHONMALLOC=malloc valgrind --suppressions=Tests/oss-fuzz/python.supp --leak-check=no \ --log-file=/tmp/valgrind-output \ python3 -m pytest --no-memcheck -vv --valgrind --valgrind-log=/tmp/valgrind-output .PHONY: readme readme: - python3 -c "import markdown2" || python3 -m pip install markdown2 + python3 -c "import markdown2" > /dev/null 2>&1 || python3 -m pip install markdown2 python3 -m markdown2 README.md > .long-description.html && open .long-description.html .PHONY: lint lint: - python3 -c "import tox" || python3 -m pip install tox + python3 -c "import tox" > /dev/null 2>&1 || python3 -m pip install tox python3 -m tox -e lint .PHONY: lint-fix lint-fix: - python3 -c "import black" || python3 -m pip install black - python3 -c "import isort" || python3 -m pip install isort + python3 -c "import black" > /dev/null 2>&1 || python3 -m pip install black + python3 -c "import isort" > /dev/null 2>&1 || python3 -m pip install isort python3 -m black --target-version py37 . python3 -m isort . diff --git a/docs/Makefile b/docs/Makefile index 549ca2c744c..0d352302f93 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -41,38 +41,48 @@ help: clean: -rm -rf $(BUILDDIR)/* +install-sphinx: + python3 -c "import sphinx" > /dev/null 2>&1 || python3 -m pip install sphinx + html: + $(MAKE) install-sphinx $(SPHINXBUILD) -b html -W --keep-going $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: + $(MAKE) install-sphinx $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." singlehtml: + $(MAKE) install-sphinx $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." pickle: + $(MAKE) install-sphinx $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: + $(MAKE) install-sphinx $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: + $(MAKE) install-sphinx $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: + $(MAKE) install-sphinx $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ @@ -82,6 +92,7 @@ qthelp: @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/PillowPILfork.qhc" devhelp: + $(MAKE) install-sphinx $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @@ -91,11 +102,13 @@ devhelp: @echo "# devhelp" epub: + $(MAKE) install-sphinx $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." latex: + $(MAKE) install-sphinx $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @@ -103,22 +116,26 @@ latex: "(use \`make latexpdf' here to do that automatically)." latexpdf: + $(MAKE) install-sphinx $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through pdflatex..." $(MAKE) -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." text: + $(MAKE) install-sphinx $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." man: + $(MAKE) install-sphinx $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." texinfo: + $(MAKE) install-sphinx $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." @@ -126,28 +143,33 @@ texinfo: "(use \`make info' here to do that automatically)." info: + $(MAKE) install-sphinx $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo "Running Texinfo files through makeinfo..." make -C $(BUILDDIR)/texinfo info @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." gettext: + $(MAKE) install-sphinx $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale @echo @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." changes: + $(MAKE) install-sphinx $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: + $(MAKE) install-sphinx $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck -j auto @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: + $(MAKE) install-sphinx $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." From 00563327a28bd051f4ee7354cb04b23625b5c88b Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sun, 27 Feb 2022 18:43:06 +0200 Subject: [PATCH 13/13] Quotes may be needed on macOS Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com> --- docs/releasenotes/9.1.0.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/releasenotes/9.1.0.rst b/docs/releasenotes/9.1.0.rst index a0b0b5eb7ef..aa4b6af061d 100644 --- a/docs/releasenotes/9.1.0.rst +++ b/docs/releasenotes/9.1.0.rst @@ -38,6 +38,9 @@ For example: # Or for all: python3 -m pip install .[docs,tests] +On macOS, the last argument may need to be wrapped in quotes, e.g. +``python3 -m pip install ".[tests]"`` + Therefore ``requirements.txt`` has been removed along with the ``make install-req`` command for installing its contents.