Skip to content

Commit 3feaaed

Browse files
authored
Merge pull request #69 from DiamondLightSource/py36updates
Drop Python 3.5 support
2 parents 254fdd2 + 79c2516 commit 3feaaed

File tree

13 files changed

+41
-76
lines changed

13 files changed

+41
-76
lines changed

.azure-pipelines.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ jobs:
2626
vmImage: ubuntu-latest
2727
strategy:
2828
matrix:
29-
python35:
30-
PYTHON_VERSION: 3.5
3129
python36:
3230
PYTHON_VERSION: 3.6
3331
python37:
@@ -43,8 +41,6 @@ jobs:
4341
vmImage: macOS-latest
4442
strategy:
4543
matrix:
46-
python35:
47-
PYTHON_VERSION: 3.5
4844
python36:
4945
PYTHON_VERSION: 3.6
5046
python37:
@@ -60,8 +56,6 @@ jobs:
6056
vmImage: windows-latest
6157
strategy:
6258
matrix:
63-
python35:
64-
PYTHON_VERSION: 3.5
6559
python36:
6660
PYTHON_VERSION: 3.6
6761
python37:

.azure-pipelines/syntax-validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
continue
1313
filename = os.path.normpath(os.path.join(base, f))
1414
try:
15-
with open(filename, "r") as fh:
15+
with open(filename) as fh:
1616
ast.parse(fh.read())
1717
except SyntaxError as se:
1818
failures += 1

.github/dependabot.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,3 @@ updates:
99
directory: "/" # Location of package manifests
1010
schedule:
1111
interval: "monthly"
12-
ignore:
13-
- dependency-name: "mock"
14-
# mock 4 requires Python 3.6+
15-
versions: [">=4"]
16-
- dependency-name: "twine"
17-
# twine 2 requires Python 3.6+
18-
versions: [">=2"]

.travis.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ matrix:
1212
- python: 3.8
1313
- python: 3.7
1414
- python: 3.6
15-
- python: 3.5
1615
- os: osx
1716
language: generic
1817
env: CONDA=3.8 TOXENV=py38
@@ -22,9 +21,6 @@ matrix:
2221
- os: osx
2322
language: generic
2423
env: CONDA=3.6 TOXENV=py36
25-
- os: osx
26-
language: generic
27-
env: CONDA=3.5 TOXENV=py35
2824

2925
allow_failures:
3026
- env: OPTIONAL=1

HISTORY.rst

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
History
33
=======
44

5+
2.3.0 (????-??-??)
6+
------------------
7+
* Python 3.6+ only, support for Python 3.5 has been dropped
8+
59
2.2.0 (2020-09-07)
610
------------------
711
* Calling the run() function with unnamed arguments (other than the command
@@ -28,70 +32,58 @@ History
2832

2933
2.0.0 (2020-06-24)
3034
------------------
31-
3235
* Python 3.5+ only, support for Python 2.7 has been dropped
3336
* Deprecated function alias run_process() has been removed
3437
* Fixed a stability issue on Windows
3538

3639
1.1.0 (2019-11-04)
3740
------------------
38-
3941
* Add Python 3.8 support, drop Python 3.4 support
4042

4143
1.0.2 (2019-05-20)
4244
------------------
43-
4445
* Stop environment override variables leaking into the process environment
4546

4647
1.0.1 (2019-04-16)
4748
------------------
48-
4949
* Minor fixes on the return object (implement equality,
5050
mark as unhashable)
5151

5252
1.0.0 (2019-03-25)
5353
------------------
54-
5554
* Support file system path objects (PEP-519) in arguments
5655
* Change the return object to make it similar to
5756
subprocess.CompletedProcess, introduced with Python 3.5+
5857

5958
0.9.1 (2019-02-22)
6059
------------------
61-
6260
* Have deprecation warnings point to correct code locations
6361

6462
0.9.0 (2018-12-07)
6563
------------------
66-
6764
* Trap UnicodeEncodeError when printing output. Offending characters
6865
are replaced and a warning is logged once. Hints at incorrectly set
6966
PYTHONIOENCODING.
7067

7168
0.8.1 (2018-12-04)
7269
------------------
73-
7470
* Fix a few deprecation warnings
7571

7672
0.8.0 (2018-10-09)
7773
------------------
78-
7974
* Add parameter working_directory to set the working directory
8075
of the subprocess
8176

8277
0.7.2 (2018-10-05)
8378
------------------
84-
8579
* Officially support Python 3.7
8680

8781
0.7.1 (2018-09-03)
8882
------------------
89-
9083
* Accept environment variable overriding with numeric values.
9184

9285
0.7.0 (2018-05-13)
9386
------------------
94-
9587
* Unicode fixes. Fix crash on invalid UTF-8 input.
9688
* Clarify that stdout/stderr values are returned as bytestrings.
9789
* Callbacks receive the data decoded as UTF-8 unicode strings
@@ -101,23 +93,19 @@ History
10193

10294
0.6.1 (2018-05-02)
10395
------------------
104-
10596
* Maintenance release to add some tests for executable resolution.
10697

10798
0.6.0 (2018-05-02)
10899
------------------
109-
110100
* Fix Win32 API executable resolution for commands containing a dot ('.') in
111101
addition to a file extension (say '.bat').
112102

113103
0.5.1 (2018-04-27)
114104
------------------
115-
116105
* Fix Win32API dependency installation on Windows.
117106

118107
0.5.0 (2018-04-26)
119108
------------------
120-
121109
* New keyword 'win32resolve' which only takes effect on Windows and is enabled
122110
by default. This causes procrunner to call the Win32 API FindExecutable()
123111
function to try and lookup non-.exe files with the corresponding name. This
@@ -126,21 +114,17 @@ History
126114

127115
0.4.0 (2018-04-23)
128116
------------------
129-
130117
* Python 2.7 support on Windows. Python3 not yet supported on Windows.
131118

132119
0.3.0 (2018-04-17)
133120
------------------
134-
135121
* run_process() renamed to run()
136122
* Python3 compatibility fixes
137123

138124
0.2.0 (2018-03-12)
139125
------------------
140-
141126
* Procrunner is now Python3 3.3-3.6 compatible.
142127

143128
0.1.0 (2018-03-12)
144129
------------------
145-
146130
* First release on PyPI.

appveyor.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ environment:
55
# For Python versions available on Appveyor, see
66
# http://www.appveyor.com/docs/installed-software#python
77

8-
- PYTHON: "C:\\Python35"
98
- PYTHON: "C:\\Python36"
109
- PYTHON: "C:\\Python37"
1110
- PYTHON: "C:\\Python38"
12-
- PYTHON: "C:\\Python35-x64"
1311
- PYTHON: "C:\\Python36-x64"
1412
- PYTHON: "C:\\Python37-x64"
1513
- PYTHON: "C:\\Python38-x64"

procrunner/__init__.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def _path_resolve(obj):
273273
return obj
274274

275275

276-
def _windows_resolve(command):
276+
def _windows_resolve(command, path=None):
277277
"""
278278
Try and find the full path and file extension of the executable to run.
279279
This is so that e.g. calls to 'somescript' will point at 'somescript.cmd'
@@ -288,7 +288,7 @@ def _windows_resolve(command):
288288
if not command or not isinstance(command[0], str):
289289
return command
290290

291-
found_executable = shutil.which(command[0])
291+
found_executable = shutil.which(command[0], path=path)
292292
if found_executable:
293293
logger.debug("Resolved %s as %s", command[0], found_executable)
294294
return (found_executable, *command[1:])
@@ -297,7 +297,7 @@ def _windows_resolve(command):
297297
# Special case. shutil.which may not detect file extensions if a full
298298
# path is given, so try to resolve the executable explicitly
299299
for extension in os.getenv("PATHEXT").split(os.pathsep):
300-
found_executable = shutil.which(command[0] + extension)
300+
found_executable = shutil.which(command[0] + extension, path=path)
301301
if found_executable:
302302
return (found_executable, *command[1:])
303303

@@ -333,7 +333,7 @@ def __getitem__(self, key):
333333
if key in self._extras:
334334
return self._extras[key]
335335
if not hasattr(self, key):
336-
raise KeyError("Unknown attribute {key}".format(key=key))
336+
raise KeyError(f"Unknown attribute {key}")
337337
return getattr(self, key)
338338

339339
def __eq__(self, other):
@@ -516,11 +516,13 @@ def run(
516516
command = tuple(_path_resolve(part) for part in command)
517517
if win32resolve and sys.platform == "win32":
518518
command = _windows_resolve(command)
519+
if working_directory and sys.version_info < (3, 7):
520+
working_directory = os.fspath(working_directory)
519521

520522
p = subprocess.Popen(
521523
command,
522524
shell=False,
523-
cwd=_path_resolve(working_directory),
525+
cwd=working_directory,
524526
env=env,
525527
stdin=stdin_pipe,
526528
stdout=subprocess.PIPE,

requirements_dev.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
bump2version==1.0.0
22
coverage==5.3
33
flake8==3.8.3
4-
mock==3.0.5
54
pip==20.2.3
65
pytest==6.1.0
76
Sphinx==3.2.1

setup.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
setup_requirements = []
1515

16-
test_requirements = ["mock", "pytest"]
16+
test_requirements = ["pytest"]
1717

1818
setup(
1919
author="Markus Gerstel",
@@ -25,7 +25,6 @@
2525
"Natural Language :: English",
2626
"Operating System :: OS Independent",
2727
"Programming Language :: Python :: 3",
28-
"Programming Language :: Python :: 3.5",
2928
"Programming Language :: Python :: 3.6",
3029
"Programming Language :: Python :: 3.7",
3130
"Programming Language :: Python :: 3.8",
@@ -40,7 +39,7 @@
4039
keywords="procrunner",
4140
name="procrunner",
4241
packages=find_packages(include=["procrunner"]),
43-
python_requires=">=3.5",
42+
python_requires=">=3.6",
4443
setup_requires=setup_requirements,
4544
test_suite="tests",
4645
tests_require=test_requirements,

tests/test_procrunner.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import copy
2-
import mock
2+
from unittest import mock
33
import os
4+
import pathlib
45
import procrunner
56
import pytest
67
import sys
@@ -86,13 +87,16 @@ def streamreader_processing(*args, **kwargs):
8687
timeout=0.5,
8788
callback_stdout=mock.sentinel.callback_stdout,
8889
callback_stderr=mock.sentinel.callback_stderr,
89-
working_directory=mock.sentinel.cwd,
90+
working_directory=pathlib.Path("somecwd"),
9091
raise_timeout_exception=True,
9192
)
9293

9394
assert mock_subprocess.Popen.called
9495
assert mock_subprocess.Popen.call_args[1]["env"] == os.environ
95-
assert mock_subprocess.Popen.call_args[1]["cwd"] == mock.sentinel.cwd
96+
assert mock_subprocess.Popen.call_args[1]["cwd"] in (
97+
pathlib.Path("somecwd"),
98+
"somecwd",
99+
)
96100
mock_streamreader.assert_has_calls(
97101
[
98102
mock.call(

0 commit comments

Comments
 (0)