Merge pull request #2911 from wiredfool/src-reorg

Source layout reorg
This commit is contained in:
wiredfool 2017-12-29 22:00:32 +00:00 committed by GitHub
commit 81c88b1ead
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
215 changed files with 126 additions and 181 deletions

9
.gitignore vendored
View File

@ -6,6 +6,7 @@ __pycache__/
*.so
# Distribution / packaging
.eggs/
.Python
env/
bin/
@ -69,3 +70,11 @@ docs/_build/
#OS
.DS_Store
# JetBrains
.idea
# Extra test images installed from pillow-depends/test_images
Tests/images/README.md
Tests/images/msp
Tests/images/picins
Tests/images/sunraster

View File

@ -17,19 +17,18 @@ matrix:
- python: "2.7_with_system_site_packages" # For PyQt4
- python: '3.5'
- python: '3.4'
- python: '3.3'
- python: '3.7-dev'
- env: DOCKER="alpine"
- env: DOCKER="arch" # contains PyQt5
- env: DOCKER="ubuntu-trusty-x86"
- env: DOCKER="ubuntu-xenial-amd64"
- env: DOCKER="debian-stretch-x86"
- env: DOCKER="centos-6-amd64"
- env: DOCKER="centos-7-amd64"
- env: DOCKER="amazon-1-amd64"
- env: DOCKER="amazon-2-amd64"
- env: DOCKER="fedora-26-amd64"
- env: DOCKER="fedora-27-amd64"
- env: DOCKER="alpine" DOCKER_TAG="pytest"
- env: DOCKER="arch" DOCKER_TAG="pytest" # contains PyQt5
- env: DOCKER="ubuntu-trusty-x86" DOCKER_TAG="pytest"
- env: DOCKER="ubuntu-xenial-amd64" DOCKER_TAG="pytest"
- env: DOCKER="debian-stretch-x86" DOCKER_TAG="pytest"
- env: DOCKER="centos-6-amd64" DOCKER_TAG="pytest"
- env: DOCKER="centos-7-amd64" DOCKER_TAG="pytest"
- env: DOCKER="amazon-1-amd64" DOCKER_TAG="pytest"
- env: DOCKER="amazon-2-amd64" DOCKER_TAG="pytest"
- env: DOCKER="fedora-26-amd64" DOCKER_TAG="pytest"
- env: DOCKER="fedora-27-amd64" DOCKER_TAG="pytest"
dist: trusty
@ -42,7 +41,7 @@ install:
- if [ "$DOCKER" == "" ]; then .travis/install.sh; fi
before_install:
- if [ "$DOCKER" ]; then docker pull pythonpillow/$DOCKER; fi
- if [ "$DOCKER" ]; then docker pull pythonpillow/$DOCKER:$DOCKER_TAG; fi
before_script:
# Qt needs a display for some of the tests, and it's only run on the system site packages install
@ -56,7 +55,7 @@ script:
else
# the Pillow user in the docker container is UID 1000
sudo chown -R 1000 $TRAVIS_BUILD_DIR
docker run -v $TRAVIS_BUILD_DIR:/Pillow pythonpillow/$DOCKER
docker run -v $TRAVIS_BUILD_DIR:/Pillow pythonpillow/$DOCKER:$DOCKER_TAG
fi
after_success:

View File

@ -17,10 +17,10 @@ codecov
if [ "$DOCKER" == "" ]; then
pip install pyflakes pycodestyle
pyflakes *.py | tee >(wc -l)
pyflakes PIL/*.py | tee >(wc -l)
pyflakes *.py | tee >(wc -l)
pyflakes src/PIL/*.py | tee >(wc -l)
pyflakes Tests/*.py | tee >(wc -l)
pycodestyle --statistics --count PIL/*.py
pycodestyle --statistics --count src/PIL/*.py
pycodestyle --statistics --count Tests/*.py
fi

View File

@ -8,11 +8,12 @@ sudo apt-get -qq install libfreetype6-dev liblcms2-dev python-tk\
libharfbuzz-dev libfribidi-dev
pip install cffi
pip install nose
pip install check-manifest
pip install olefile
pip install pyroma
pip install coverage
pip install olefile
pip install -U pytest
pip install -U pytest-cov
pip install pyroma
pip install test-image-results
# docs only on Python 2.7

View File

@ -3,12 +3,13 @@
set -e
coverage erase
python setup.py clean
CFLAGS="-coverage" python setup.py build_ext --inplace
make clean
make install-coverage
python selftest.py
python -m pytest -vx --cov PIL --cov-report term Tests
coverage run --append --include=PIL/* selftest.py
coverage run --append --include=PIL/* -m nose -vx Tests/test_*.py
pushd /tmp/check-manifest && check-manifest --ignore ".coveragerc,.editorconfig,*.yml,*.yaml,tox.ini" && popd
# Docs
if [ "$TRAVIS_PYTHON_VERSION" == "2.7" ]; then make install && make doccheck; fi
if [ "$TRAVIS_PYTHON_VERSION" == "2.7" ]; then make doccheck; fi

View File

@ -2,7 +2,7 @@
Changelog (Pillow)
==================
4.4.0 (unreleased)
5.0.0 (unreleased)
------------------
- Dynamically link libraqm #2753

View File

@ -10,9 +10,8 @@ include *.txt
include LICENSE
include Makefile
graft Tests
graft PIL
graft src
graft Tk
graft libImaging
graft depends
graft winbuild
graft docs

View File

@ -15,12 +15,9 @@ co:
done
coverage:
coverage erase
coverage run --parallel-mode --include=PIL/* selftest.py
nosetests --with-cov --cov='PIL/' --cov-report=html Tests/test_*.py
# Doesn't combine properly before report, writing report instead of displaying invalid report.
python selftest.py
python setup.py test
rm -r htmlcov || true
coverage combine
coverage report
doc:
@ -53,15 +50,15 @@ help:
@echo " upload-test build and upload sdists to test.pythonpackages.com"
inplace: clean
python setup.py build_ext --inplace
python setup.py develop build_ext --inplace
install:
python setup.py install
python selftest.py --installed
python selftest.py
install-coverage:
CFLAGS="-coverage" python setup.py build_ext install
python selftest.py --installed
python selftest.py
debug:
# make a debug version if we don't have a -dbg python. Leaves in symbols
@ -81,9 +78,9 @@ release-test:
$(MAKE) install-req
python setup.py develop
python selftest.py
nosetests Tests/test_*.py
python -m pytest Tests
python setup.py install
python test-installed.py
python -m pytest -qq
check-manifest
pyroma .
viewdoc
@ -92,7 +89,7 @@ sdist:
python setup.py sdist --format=gztar
test:
python test-installed.py
pytest -qq
# https://docs.python.org/2/distutils/packageindex.html#the-pypirc-file
upload-test:

View File

@ -8,7 +8,7 @@ Dependencies
Install::
pip install coverage nose
pip install pytest pytest-cov
Execution
---------
@ -21,12 +21,11 @@ To run an individual test::
Run all the tests from the root of the Pillow source distribution::
nosetests -vx Tests/test_*.py
pytest -vx Tests
Or with coverage::
coverage run --append --include=PIL/* -m nose -vx Tests/test_*.py
coverage report
pytest -vx --cov PIL --cov-report term Tests
coverage html
open htmlcov/index.html
@ -34,11 +33,8 @@ Or with coverage::
To run an individual test::
./test-installed.py Tests/test_image.py
pytest -k Tests/test_image.py
Run all the tests from the root of the Pillow source distribution::
./test-installed.py
pytest

View File

@ -63,9 +63,8 @@ class PillowTestCase(unittest.TestCase):
def delete_tempfile(self, path):
try:
ok = self.currentResult.wasSuccessful()
except AttributeError: # for nosetests
proxy = self.currentResult
ok = (len(proxy.errors) + len(proxy.failures) == 0)
except AttributeError: # for pytest
ok = True
if ok:
# only clean out tempfiles if test passed
@ -210,10 +209,6 @@ class PillowTestCase(unittest.TestCase):
if skip:
self.skipTest(msg or "Known Bad Test")
def shortDescription(self):
# Prevents `nose -v` printing docstrings
return None
def tempfile(self, template):
assert template[:5] in ("temp.", "temp_")
fd, path = tempfile.mkstemp(template[4:], template[:4])
@ -256,8 +251,8 @@ class PillowLeakTestCase(PillowTestCase):
# linux
# man 2 getrusage
# ru_maxrss (since Linux 2.6.32)
# This is the maximum resident set size used (in kilobytes).
return mem # Kb
# This is the maximum resident set size used (in kilobytes).
return mem # Kb
def _test_leak(self, core):
start_mem = self._get_mem_usage()

View File

@ -251,7 +251,7 @@ class TestCffi(AccessTest):
class TestEmbeddable(unittest.TestCase):
@unittest.skipIf(not sys.platform.startswith('win32') or
sys.version_info[:2] in ((3, 3), (3, 4)) or
sys.version_info[:2] == (3, 4) or
on_appveyor(), # failing on appveyor when run from
# subprocess, not from shell
"requires Python 2.7 or >=3.5 for Windows")
@ -293,7 +293,7 @@ int main(int argc, char* argv[])
compiler = ccompiler.new_compiler()
compiler.add_include_dir(sysconfig.get_python_inc())
libdir = sysconfig.get_config_var('LIBDIR') or sysconfig.get_python_inc().replace('include', 'libs')
print (libdir)
compiler.add_library_dir(libdir)
@ -302,10 +302,10 @@ int main(int argc, char* argv[])
env = os.environ.copy()
env["PATH"] = sys.prefix + ';' + env["PATH"]
# do not display the Windows Error Reporting dialog
ctypes.windll.kernel32.SetErrorMode(0x0002)
process = subprocess.Popen(['embed_pil.exe'], env=env)
process.communicate()
self.assertEqual(process.returncode, 0)

View File

@ -21,8 +21,6 @@ environment:
- PYTHON: C:/Python34
- PYTHON: C:/Python27
- PYTHON: C:/Python34-x64
- PYTHON: C:/Python33
- PYTHON: C:/Python33-x64
- PYTHON: C:/msys64/mingw32
EXECUTABLE: bin/python3
PIP_DIR: bin
@ -69,13 +67,17 @@ build_script:
$host.SetShouldExit(0)
}
- cd c:\pillow
- mv PIL PIL.temp
- '%PYTHON%\%EXECUTABLE% selftest.py --installed'
test_script:
- cd c:\pillow
- '%PYTHON%\%PIP_DIR%\pip.exe install nose'
- '%PYTHON%\%EXECUTABLE% test-installed.py -v -s %TEST_OPTIONS%'
- '%PYTHON%\%PIP_DIR%\pip.exe install pytest pytest-cov'
- '%PYTHON%\%EXECUTABLE% -m pytest -vx --cov PIL --cov-report term --cov-report xml Tests'
#- '%PYTHON%\%EXECUTABLE% test-installed.py -v -s %TEST_OPTIONS%' TODO TEST_OPTIONS with pytest?
after_test:
- pip install codecov
- codecov --file coverage.xml --name %PYTHON%
matrix:
fast_finish: true
@ -88,7 +90,6 @@ artifacts:
before_deploy:
- cd c:\pillow
- mv PIL.temp PIL
- '%PYTHON%\%PIP_DIR%\pip.exe install wheel'
- cd c:\pillow\winbuild\
- '%PYTHON%\%EXECUTABLE% c:\pillow\winbuild\build.py --wheel'

View File

@ -17,7 +17,9 @@ Notes
.. note:: Pillow >= 2.0.0 < 4.0.0 supports Python versions 2.6, 2.7, 3.2, 3.3, 3.4, 3.5
.. note:: Pillow >= 4.0.0 supports Python versions 2.7, 3.3, 3.4, 3.5, 3.6
.. note:: Pillow >= 4.0.0 < 5.0.0 supports Python versions 2.7, 3.3, 3.4, 3.5, 3.6
.. note:: Pillow >= 5.0.0 supports Python versions 2.7, 3.4, 3.5, 3.6
Basic Installation
------------------
@ -382,16 +384,16 @@ These platforms are built and tested for every change.
+----------------------------------+-------------------------------+-----------------------+
| Fedora 26 | 2.7 |x86-64 |
+----------------------------------+-------------------------------+-----------------------+
| Mac OS X 10.10 Yosemite* | 2.7, 3.3, 3.4, 3.5, 3.6 |x86-64 |
| Mac OS X 10.10 Yosemite* | 2.7, 3.4, 3.5, 3.6 |x86-64 |
+----------------------------------+-------------------------------+-----------------------+
| Ubuntu Linux 16.04 LTS | 2.7 |x86-64 |
+----------------------------------+-------------------------------+-----------------------+
| Ubuntu Linux 14.04 LTS | 2.7, 3.3, 3.4, 3.5, 3.6, |x86-64 |
| Ubuntu Linux 14.04 LTS | 2.7, 3.4, 3.5, 3.6, |x86-64 |
| | pypy, pypy3 | |
| | | |
| | 2.7 |x86 |
+----------------------------------+-------------------------------+-----------------------+
| Windows Server 2012 R2 | 2.7, 3.3, 3.4 |x86, x86-64 |
| Windows Server 2012 R2 | 2.7, 3.4 |x86, x86-64 |
| | | |
| | pypy, 3.5/mingw |x86 |
+----------------------------------+-------------------------------+-----------------------+

View File

@ -1,6 +1,17 @@
4.4.0
5.0.0
-----
Backwards Incompatible Changes
==============================
Python 3.3 Dropped
^^^^^^^^^^^^^^^^^^
Python 3.3 is EOL and no longer supported due to moving testing from nose,
which is deprecated, to pytest, which doesn't support Python 3.3. We will not
be creating binaries, testing, or retaining compatibility with this version.
The final version of Pillow for Python 3.3 is 4.3.0.
API Changes
===========
@ -17,7 +28,6 @@ Further, the vendored version was removed in Pillow 4.0.0 and replaced with a
deprecation warning that PIL.OleFileIO would be removed in a future version.
This warning has been upgraded to an import error pending future removal.
API Additions
=============

View File

@ -6,7 +6,7 @@ Release Notes
.. toctree::
:maxdepth: 2
4.4.0
5.0.0
4.3.0
4.2.1
4.2.0

View File

@ -54,19 +54,12 @@ def _mp_compile(self, sources, output_dir=None, macros=None,
def install():
fl_pypy3 = (hasattr(sys, 'pypy_version_info') and
(3, 0) < sys.version_info < (3, 3))
fl_win = sys.platform.startswith('win')
fl_cygwin = sys.platform.startswith('cygwin')
if fl_pypy3:
# see https://github.com/travis-ci/travis-ci/issues/3587
print("Single threaded build for pypy3")
return
if fl_win or fl_cygwin:
# windows barfs on multiprocessing installs
print("Single threaded build for windows")
# Windows barfs on multiprocessing installs
print("Single threaded build for Windows")
return
if MAX_PROCS != 1:

View File

@ -1,25 +0,0 @@
#!/usr/bin/env python
import os
import sys
import glob
import profile
# monkey with the path, removing the local directory but adding the Tests/
# directory for helper.py and the other local imports there.
del(sys.path[0])
sys.path.insert(0, os.path.abspath('./Tests'))
# if there's no test selected (mostly) choose a working default.
# Something is required, because if we import the tests from the local
# directory, once again, we've got the non-installed PIL in the way
if len(sys.argv) == 1:
sys.argv.extend(glob.glob('Tests/test*.py'))
# Make sure that nose doesn't muck with our paths.
if ('--no-path-adjustment' not in sys.argv) and ('-P' not in sys.argv):
sys.argv.insert(1, '--no-path-adjustment')
if __name__ == '__main__':
profile.run("nose.main()", sort=2)

View File

@ -11,10 +11,10 @@ docutils
jarn.viewdoc
Jinja2
MarkupSafe
nose
nose-cov
olefile
pycodestyle
pytest
pytest-cov
pyflakes
Pygments
pyroma

View File

@ -5,15 +5,9 @@ from __future__ import print_function
import sys
import os
if "--installed" in sys.argv:
sys_path_0 = sys.path.pop(0)
from PIL import Image, ImageDraw, ImageFilter, ImageMath
from PIL import features
if "--installed" in sys.argv:
sys.path.insert(0, sys_path_0)
try:
Image.core.ping
except ImportError as v:

View File

@ -1,2 +1,6 @@
[aliases]
test=pytest
[metadata]
license_file = LICENSE
[tool:pytest]
addopts = -vx Tests

View File

@ -19,7 +19,7 @@ import warnings
from distutils import ccompiler, sysconfig
from distutils.command.build_ext import build_ext
from setuptools import Extension, find_packages, setup
from setuptools import Extension, setup
# monkey patch import hook. Even though flake8 says it's not used, it is.
# comment this out to disable multi threaded builds.
@ -122,7 +122,7 @@ def _read(file):
def get_version():
version_file = 'PIL/version.py'
version_file = 'src/PIL/version.py'
with open(version_file, 'r') as f:
exec(compile(f.read(), version_file, 'exec'))
return locals()['__version__']
@ -223,7 +223,7 @@ class pil_build_ext(build_ext):
library_dirs = []
include_dirs = []
_add_directory(include_dirs, "libImaging")
_add_directory(include_dirs, "src/libImaging")
pkg_config = None
if _cmd_exists('pkg-config'):
@ -583,11 +583,11 @@ class pil_build_ext(build_ext):
#
# core library
files = ["_imaging.c"]
files = ["src/_imaging.c"]
for src_file in _IMAGING:
files.append(src_file + ".c")
files.append("src/" + src_file + ".c")
for src_file in _LIB_IMAGING:
files.append(os.path.join("libImaging", src_file + ".c"))
files.append(os.path.join("src/libImaging", src_file + ".c"))
libs = []
defs = []
@ -630,7 +630,7 @@ class pil_build_ext(build_ext):
libs = ["freetype"]
defs = []
exts.append(Extension(
"PIL._imagingft", ["_imagingft.c"], libraries=libs,
"PIL._imagingft", ["src/_imagingft.c"], libraries=libs,
define_macros=defs))
if feature.lcms:
@ -638,7 +638,7 @@ class pil_build_ext(build_ext):
if sys.platform == "win32":
extra.extend(["user32", "gdi32"])
exts.append(Extension("PIL._imagingcms",
["_imagingcms.c"],
["src/_imagingcms.c"],
libraries=[feature.lcms] + extra))
if feature.webp:
@ -651,18 +651,18 @@ class pil_build_ext(build_ext):
libs.append(feature.webpmux.replace('pmux', 'pdemux'))
exts.append(Extension("PIL._webp",
["_webp.c"],
["src/_webp.c"],
libraries=libs,
define_macros=defs))
tk_libs = ['psapi'] if sys.platform == 'win32' else []
exts.append(Extension("PIL._imagingtk",
["_imagingtk.c", "Tk/tkImaging.c"],
["src/_imagingtk.c", "Tk/tkImaging.c"],
include_dirs=['Tk'],
libraries=tk_libs))
exts.append(Extension("PIL._imagingmath", ["_imagingmath.c"]))
exts.append(Extension("PIL._imagingmorph", ["_imagingmorph.c"]))
exts.append(Extension("PIL._imagingmath", ["src/_imagingmath.c"]))
exts.append(Extension("PIL._imagingmorph", ["src/_imagingmorph.c"]))
self.extensions[:] = exts
@ -751,6 +751,9 @@ def debug_build():
return hasattr(sys, 'gettotalrefcount')
needs_pytest = {'pytest', 'test', 'ptr'}.intersection(sys.argv)
pytest_runner = ['pytest-runner'] if needs_pytest else []
try:
setup(name=NAME,
version=PILLOW_VERSION,
@ -770,19 +773,20 @@ try:
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
],
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*",
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
cmdclass={"build_ext": pil_build_ext},
ext_modules=[Extension("PIL._imaging", ["_imaging.c"])],
include_package_data=True,
packages=find_packages(),
test_suite='nose.collector',
setup_requires=pytest_runner,
tests_require=['pytest'],
packages=["PIL"],
package_dir={'':'src'},
keywords=["Imaging", ],
license='Standard PIL License',
zip_safe=not (debug_build() or PLATFORM_MINGW), )

Some files were not shown because too many files have changed in this diff Show More