diff --git a/.ci/appveyor/lint.cmd b/.ci/appveyor/lint.cmd index c095410..007eab4 100644 --- a/.ci/appveyor/lint.cmd +++ b/.ci/appveyor/lint.cmd @@ -1,9 +1,7 @@ -%PYTHON%\Scripts\pep8.exe C:\project\pywincffi C:\project\tests || EXIT 1 +%PYTHON%\Scripts\pycodestyle.exe C:\project\pywincffi C:\project\tests || EXIT 1 SET DISABLED_PYWINCFFI_CHECKS="" SET DISABLED_TEST_CHECKS=missing-docstring,invalid-name,too-many-arguments,protected-access,no-self-use,unused-argument,too-few-public-methods -IF "%PYTHON_VERSION%" == "2.6.x" SET DISABLED_PYWINCFFI_CHECKS=bad-option-value,unpacking-non-sequence,maybe-no-member,star-args -IF "%PYTHON_VERSION%" == "2.6.x" SET DISABLED_TEST_CHECKS=missing-docstring,invalid-name,too-many-arguments,protected-access,no-self-use,unused-argument,maybe-no-member,too-few-public-methods,too-many-public-methods,unpacking-non-sequence,bad-option-value,star-args,no-member,import-error %PYTHON%\Scripts\pylint.exe C:\project\pywincffi --reports no --disable %DISABLED_PYWINCFFI_CHECKS% || EXIT 1 %PYTHON%\Scripts\pylint.exe C:\project\tests --reports no --disable %DISABLED_TEST_CHECKS% || EXIT 1 diff --git a/.ci/appveyor/test.cmd b/.ci/appveyor/test.cmd index 697a91f..5cc7985 100644 --- a/.ci/appveyor/test.cmd +++ b/.ci/appveyor/test.cmd @@ -1,7 +1,3 @@ -SET REQUIREMENTS=dev_requirements.txt --upgrade -IF "%PYTHON_VERSION%" == "2.6.x" SET REQUIREMENTS=dev_requirements-2.6.txt -%WITH_COMPILER% %PYTHON%\Scripts\pip.exe install -r %REQUIREMENTS% --quiet || EXIT 1 - -%WITH_COMPILER% %PYTHON%\Scripts\nosetests.exe --with-coverage --cover-package pywincffi -v tests || EXIT 1 -%PYTHON%\Scripts\coverage.exe xml || EXIT 1 -%PYTHON%\Scripts\codecov.exe --required || EXIT 1 +%WITH_COMPILER% %PYTHON%\Scripts\pip.exe install -r dev_requirements.txt --upgrade --quiet || EXIT 1 +%WITH_COMPILER% %PYTHON%\Scripts\py.test.exe --strict --verbose --cov pywincffi --cov-report=xml || EXIT 1 +%PYTHON%\Scripts\codecov.exe -X gcov -f coverage.xml --required || EXIT 1 diff --git a/.gitignore b/.gitignore index 8993944..3a6d169 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,9 @@ /*.egg-info/ /docs/build/ /.tox/ -.coverage +/.coverage +/.coverage.* +/coverage.* /docs/source/modules/ /.vagrant /.provision @@ -14,4 +16,4 @@ /pywincffi.ini /Release* *_pywincffi.c -/.idea/ \ No newline at end of file +/.idea/ diff --git a/README.rst b/README.rst index 4286f95..8fb514c 100644 --- a/README.rst +++ b/README.rst @@ -28,7 +28,7 @@ The core objectives and design principles behind this project are: * It should be easier to to use Windows API functions both in terms of implementation and distribution. - * Python 2.6, 2.7 and 3.x should be supported from a single code base and + * Python 2.7 and 3.x should be supported from a single code base and not require a consumer of pywincffi to worry about how they use the library. * Type conversion, error checking and other 'C like' code should be the @@ -64,7 +64,7 @@ help: Python Version Support ---------------------- -This project supports Python 2.6 and up including Python 3.x. PRs, patches, +This project supports Python 2.7 and up including Python 3.x. PRs, patches, tests etc that don't include support for both 2.x and 3.x will not be merged. The aim is also the support both major versions of Python within the same code base rather than rely on tools such as 2to3, six or other @@ -87,8 +87,6 @@ It's generated directly from this library using sphinx:: The build process also builds the documentation to ensure there are not any obvious problems (including broken links). -Note, if you're running Python 2.6 use dev_requirements-2.6.txt instead. - Function Documentation ~~~~~~~~~~~~~~~~~~~~~~ @@ -131,20 +129,6 @@ Adding new functions is covered in greater detail Testing ------- -Nosetests -~~~~~~~~~ -Tests are located in the ``tests/`` directory. The tests -themselves are run using ``nosetests`` either manually or using -the ``setup.py`` file:: - - virtualenv env - env/bin/activate - pip install -r dev_requirements.txt - pip install -e . - nosetests tests - -Note, if you're running Python 2.6 use dev_requirements-2.6.txt instead. - Continuous Integration ~~~~~~~~~~~~~~~~~~~~~~ @@ -173,38 +157,14 @@ run ``test.bat``: .. code-block:: console - > test.bat - ======================================================================================== - pep8 pywincffi - ======================================================================================== - ======================================================================================== - pep8 tests - ======================================================================================== - ======================================================================================== - pylint pywincffi - ======================================================================================== - ======================================================================================== - pylint tests - ======================================================================================== - ======================================================================================== - sphinx-build -q -b html -W -E -a -d docs/build/doctrees docs/source docs/build/html - ======================================================================================== - ======================================================================================== - sphinx-build -q -b linkcheck -W -E -a -d docs/build/doctrees docs/source docs/build/html - ======================================================================================== - ======================================================================================== - setup.py bdist_wheel - ======================================================================================== - RuntimeWarning: Config variable 'Py_DEBUG' is unset, Python ABI tag may be incorrect - warn=(impl == 'cp')): - RuntimeWarning: Config variable 'WITH_PYMALLOC' is unset, Python ABI tag may be incorrect - warn=(impl == 'cp')): - ======================================================================================== - nosetests -sv tests - ======================================================================================== - [ omitted ] - ======================================================================================== + > check.bat + +This will: +* Check code style for both the library and tests. +* Run all unittests. +* Build the wheel file. +* Build the documentation and treat warnings as errors. Keep in mind that this will not setup the virtualenv or build environment for you. So if you can't build the library or are missing a dependency then diff --git a/appveyor.yml b/appveyor.yml index f6455db..f32ecef 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,14 +5,6 @@ environment: WITH_COMPILER: "cmd /E:ON /V:ON /C C:\\project\\.ci\\appveyor\\run_with_compiler.cmd" matrix: - - PYTHON: "C:\\Python26" - PYTHON_VERSION: "2.6.x" - PYTHON_ARCH: "32" - - - PYTHON: "C:\\Python26-x64" - PYTHON_VERSION: "2.6.x" - PYTHON_ARCH: "64" - - PYTHON: "C:\\Python27" PYTHON_VERSION: "2.7.x" PYTHON_ARCH: "32" @@ -45,6 +37,14 @@ environment: PYTHON_VERSION: "3.5.x" PYTHON_ARCH: "64" + - PYTHON: "C:\\Python36" + PYTHON_VERSION: "3.6.x" + PYTHON_ARCH: "32" + + - PYTHON: "C:\\Python36-x64" + PYTHON_VERSION: "3.6.x" + PYTHON_ARCH: "64" + build: false # Not a C# project, build stuff at the test step instead. clone_folder: C:\\project diff --git a/check.bat b/check.bat new file mode 100644 index 0000000..dd6c61b --- /dev/null +++ b/check.bat @@ -0,0 +1,28 @@ +@ECHO ON + +:: A simple script for testing on Windows. This does almost the same thing +:: that Travis and AppVeyor do except it does not perform additional setup +:: steps such as creating a virtual environment. + +pycodestyle pywincffi +IF %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL% + +pycodestyle tests +IF %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL% + +pylint pywincffi --reports no +IF %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL% + +pylint tests --reports no ^ + --disable missing-docstring,invalid-name,too-many-arguments ^ + --disable protected-access,no-self-use,unused-argument ^ + --disable too-few-public-methods +IF %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL% + +python setup.py bdist_wheel > NUL +IF %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL% + +py.test.exe --strict --verbose --cov pywincffi +IF %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL% + +sphinx-build -q -b html -W -E -a -d docs/build/doctrees docs/source docs/build/html diff --git a/dev_requirements-2.6.txt b/dev_requirements-2.6.txt deleted file mode 100644 index 06b3772..0000000 --- a/dev_requirements-2.6.txt +++ /dev/null @@ -1,17 +0,0 @@ -# NOTE: This requirements file is for Python 2.6 only. Packages are slowly -# dropping support for 2.6, this file allows the project to lock down -# these requirements -nose -unittest2 -logilab-common>=0.53.0 -pylint<1.4 -astroid<=1.3.2 -pep8 -mock -sphinx -wheel -setuptools -coverage -requests -codecov -PyGithub diff --git a/dev_requirements.txt b/dev_requirements.txt index f3bc26c..4da5eac 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -1,8 +1,9 @@ -nose +pytest +pytest-cov unittest2 -pylint==1.5.2 -astroid==1.4.1 -pep8 +pylint==1.7.4 +astroid==1.5.3 +pycodestyle mock sphinx wheel diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 43740c5..e22a1ee 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -8,8 +8,21 @@ versions are shown first. Versions -------- -latest -~~~~~~ +0.5.0 (work in progress) +~~~~~~~~~~~~~~~~~~~~~~~~ + +Notable enhancements and changes are: + + * **Python 2.6 support has been dropped**. Many projects have already moved + on from Python 2.6 including Twisted which this project was initially + intended to support. Additionally many libraries or tools that pywincffi + no longer have direct support for Python 2.6 or simply break in later + versions. This leads to having to maintain and support older libraries + in ths build which is going to become increasing difficult. Pull requests + to support Python 2.6 will be evaluated on a case-by-case basis. + * Various improvements to the tests and build including replacement of + nosetests with pytest, transition from pep8 to pycodestyle and upgrading + tools and libraries to more modern versions. 0.4.0 ~~~~~ diff --git a/docs/source/index.rst b/docs/source/index.rst index c28b164..95a28e7 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -11,7 +11,7 @@ The core objectives and design principles behind this project are: * It should be easier to to use Windows API functions both in terms of implementation and distribution. - * Python 2.6, 2.7 and 3.x should be supported from a single code base and + * Python 2.7 and 3.x should be supported from a single code base and not require a consumer of pywincffi to worry about how they use the library. * Type conversion, error checking and other 'C like' code should be the diff --git a/pywincffi/core/dist.py b/pywincffi/core/dist.py index ffce15e..c1cb430 100644 --- a/pywincffi/core/dist.py +++ b/pywincffi/core/dist.py @@ -200,6 +200,7 @@ def _import_path(path, module_name=MODULE_NAME): elif ExtensionFileLoader is not None: loader = ExtensionFileLoader(module_name, path) + # pylint: disable=deprecated-method return loader.load_module(module_name) elif imp is not None: # pragma: no cover diff --git a/pywincffi/dev/release.py b/pywincffi/dev/release.py index b56a9a1..14e5c11 100644 --- a/pywincffi/dev/release.py +++ b/pywincffi/dev/release.py @@ -195,6 +195,7 @@ def download(cls, url, path=None, chunk_size=1024): return path + Issue = namedtuple( "Issue", ("issue", "closed", "labels", "type", "number", "url", "title")) @@ -380,8 +381,7 @@ def create_release( draft=True, prerelease=prerelease ) - else: - return message + return message AppVeyorArtifact = namedtuple( diff --git a/pywincffi/dev/testutil.py b/pywincffi/dev/testutil.py index 65418e2..2be24f6 100644 --- a/pywincffi/dev/testutil.py +++ b/pywincffi/dev/testutil.py @@ -156,7 +156,6 @@ def setUpClass(cls): # pylint: disable=broad-except except Exception as error: # pragma: no cover if os.name == "nt": - # pylint: disable=redefined-variable-type SharedState.ffi = error cls.HAS_INTERNET = SharedState.HAS_INTERNET diff --git a/pywincffi/wintypes/functions.py b/pywincffi/wintypes/functions.py index cf64de7..0fcab12 100644 --- a/pywincffi/wintypes/functions.py +++ b/pywincffi/wintypes/functions.py @@ -39,10 +39,11 @@ def wintype_to_cdata(wintype): ffi, _ = dist.load() if wintype is None: return ffi.NULL - elif isinstance(wintype, (SOCKET, HANDLE, WSAEVENT)): + + if isinstance(wintype, (SOCKET, HANDLE, WSAEVENT)): return wintype._cdata[0] - else: - return wintype._cdata + + return wintype._cdata def handle_from_file(file_): diff --git a/setup.py b/setup.py index a45d2e3..0573497 100644 --- a/setup.py +++ b/setup.py @@ -84,6 +84,7 @@ def run(self): filename = join(root, filename) self.upload_file(command, pyversion, filename) + setup_keywords = dict( name="pywincffi", version=".".join(map(str, __version__)), @@ -101,15 +102,14 @@ def run(self): long_description=long_description, setup_requires=requirements, install_requires=requirements, - test_suite="nose.collector", classifiers=[ - "Development Status :: 3 - Alpha", + "Development Status :: 5 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Environment :: Win32 (MS Windows)", "Operating System :: Microsoft :: Windows", - "Programming Language :: Python :: 2", + "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", diff --git a/test.bat b/test.bat deleted file mode 100644 index 7b90279..0000000 --- a/test.bat +++ /dev/null @@ -1,52 +0,0 @@ -@ECHO OFF - -:: A simple script for testing on Windows. This does almost the same thing -:: that Travis and AppVeyor do. -:: NOTE: This script does not perform any kind of setup (virtualenv, build -:: tool chanin, etc) - -ECHO ======================================================================================== -ECHO pep8 pywincffi -ECHO ======================================================================================== -pep8 pywincffi -IF %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL% - -ECHO ======================================================================================== -ECHO pep8 tests -ECHO ======================================================================================== -pep8 tests -IF %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL% - -ECHO ======================================================================================== -ECHO pylint pywincffi -ECHO ======================================================================================== -pylint pywincffi --reports no -IF %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL% - -ECHO ======================================================================================== -ECHO pylint tests -ECHO ======================================================================================== -pylint tests --reports no ^ - --disable missing-docstring,invalid-name,too-many-arguments ^ - --disable protected-access,no-self-use,unused-argument ^ - --disable too-few-public-methods -IF %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL% - -ECHO ======================================================================================== -ECHO setup.py bdist_wheel -ECHO ======================================================================================== -python setup.py bdist_wheel > NUL -IF %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL% - -ECHO ======================================================================================== -ECHO nosetests -sv tests -ECHO ======================================================================================== -nosetests -sv tests -IF %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL% - -ECHO ======================================================================================== -ECHO sphinx-build -q -b html -W -E -a -d docs/build/doctrees docs/source docs/build/html -ECHO ======================================================================================== -sphinx-build -q -b html -W -E -a -d docs/build/doctrees docs/source docs/build/html -IF %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL% -ECHO ======================================================================================== diff --git a/tests/test_dev/test_release.py b/tests/test_dev/test_release.py index e0145fd..1472afb 100644 --- a/tests/test_dev/test_release.py +++ b/tests/test_dev/test_release.py @@ -330,6 +330,7 @@ def test_commit(self): # pylint: disable=no-member api.repo.get_branch.assert_called_with(api.branch) + FakeLabel = namedtuple("FakeLabel", ("name", )) diff --git a/tests/test_kernel32/test_file.py b/tests/test_kernel32/test_file.py index e3e3972..a0cbbdc 100644 --- a/tests/test_kernel32/test_file.py +++ b/tests/test_kernel32/test_file.py @@ -103,8 +103,8 @@ def test_replaces_file(self): self.addCleanup(os.remove, path2) os.close(fd) - path1 = text_type(path1) # pylint: disable=redefined-variable-type - path2 = text_type(path2) # pylint: disable=redefined-variable-type + path1 = text_type(path1) + path2 = text_type(path2) MoveFileEx(path1, path2) with open(path2, "r") as file_: @@ -129,8 +129,8 @@ def test_renames_file(self): with os.fdopen(fd, "w") as file_: file_.write(file_contents) - path1 = text_type(path1) # pylint: disable=redefined-variable-type - path2 = text_type(path2) # pylint: disable=redefined-variable-type + path1 = text_type(path1) + path2 = text_type(path2) MoveFileEx(path1, path2) with open(path2, "r") as file_: @@ -142,7 +142,7 @@ def test_run_delete_after_reboot(self): fd, path = tempfile.mkstemp('-removed-on-next-reboot') os.close(fd) - path = text_type(path) # pylint: disable=redefined-variable-type + path = text_type(path) _, library = dist.load() try: @@ -171,7 +171,7 @@ def test_creates_file(self): os.close(fd) os.remove(path) - path = text_type(path) # pylint: disable=redefined-variable-type + path = text_type(path) handle = CreateFile(path, 0) self.addCleanup(os.remove, path) self.addCleanup(CloseHandle, handle) @@ -186,7 +186,7 @@ def test_default_create_disposition(self): file_.flush() os.fsync(file_.fileno()) - path = text_type(path) # pylint: disable=redefined-variable-type + path = text_type(path) handle = CreateFile(path, 0) self.addCleanup(os.remove, path) self.addCleanup(CloseHandle, handle) @@ -207,7 +207,7 @@ def raise_(*_): raise WindowsAPIError("", "", library.ERROR_ALREADY_EXISTS) with patch.object(_file, "error_check", side_effect=raise_): - path = text_type(path) # pylint: disable=redefined-variable-type + path = text_type(path) handle = CreateFile( path, 0, dwCreationDisposition=library.CREATE_ALWAYS) self.addCleanup(os.remove, path) @@ -235,7 +235,7 @@ def setUp(self): os.close(fd) self.addCleanup(os.remove, path) _, library = dist.load() - path = text_type(path) # pylint: disable=redefined-variable-type + path = text_type(path) self.handle = CreateFile(path, library.GENERIC_WRITE) self.assert_last_error(library.ERROR_ALREADY_EXISTS) self.addCleanup(CloseHandle, self.handle) diff --git a/tests/test_kernel32/test_synchronization.py b/tests/test_kernel32/test_synchronization.py index c0a4367..5797692 100644 --- a/tests/test_kernel32/test_synchronization.py +++ b/tests/test_kernel32/test_synchronization.py @@ -21,6 +21,7 @@ def test_wait_failed(self): with self.assertRaises(WindowsAPIError) as exec_: WaitForSingleObject(hProcess, 3) + # pylint: disable=no-member self.assertEqual(exec_.code, library.WAIT_FAILED) self.assertEqual(self.GetLastError()[0], library.ERROR_ACCESS_DENIED) diff --git a/tools/release.py b/tools/release.py index 29d0d57..632974c 100755 --- a/tools/release.py +++ b/tools/release.py @@ -166,5 +166,6 @@ def main(): if not docs_built(version): logger.error("Documentation not built for %s", version) + if __name__ == "__main__": main()