Skip to content

Commit 77545b5

Browse files
committed
Update setup.py to support Python 3.6 and above
- Removed support for older Python versions (2.6, 2.7, 3.5) and updated the Python requirement to '>=3.6' to ensure compatibility with modern Python features.
1 parent 3e7c3bf commit 77545b5

2 files changed

Lines changed: 40 additions & 3 deletions

File tree

‎setup.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,8 @@ def run():
8484
'Intended Audience :: Developers',
8585
'License :: OSI Approved :: MIT License',
8686
'Operating System :: OS Independent',
87-
'Programming Language :: Python :: 2.6',
88-
'Programming Language :: Python :: 2.7',
89-
'Programming Language :: Python :: 3.5',
87+
'Programming Language :: Python :: 3',
88+
'Programming Language :: Python :: 3.6',
9089
'Programming Language :: Python',
9190
'Topic :: Education',
9291
],
@@ -102,6 +101,7 @@ def run():
102101
long_description=long_description,
103102
name='translate',
104103
packages=find_packages(exclude=['docs', 'tests', 'tests.*', 'requirements']),
104+
python_requires='>=3.6',
105105
setup_requires=['pytest-runner'],
106106
tests_require=tests_requirements,
107107
url='https://github.com/terryyin/google-translate-python',

‎tests/test_setup.py‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env python
2+
# encoding: utf-8
3+
import importlib.util
4+
import os
5+
from unittest import mock
6+
7+
8+
def _load_setup_module():
9+
root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
10+
setup_path = os.path.join(root, 'setup.py')
11+
spec = importlib.util.spec_from_file_location('project_setup', setup_path)
12+
setup_module = importlib.util.module_from_spec(spec)
13+
spec.loader.exec_module(setup_module)
14+
return setup_module
15+
16+
17+
def test_setup_declares_python_36_minimum():
18+
captured = {}
19+
20+
def fake_setup(**kwargs):
21+
captured.update(kwargs)
22+
23+
setup_module = _load_setup_module()
24+
with mock.patch.object(setup_module, 'setup', side_effect=fake_setup), \
25+
mock.patch.object(setup_module, 'save_version'):
26+
setup_module.run()
27+
28+
assert captured.get('python_requires') == '>=3.6'
29+
30+
classifiers = captured.get('classifiers', [])
31+
stale = {
32+
'Programming Language :: Python :: 2.6',
33+
'Programming Language :: Python :: 2.7',
34+
'Programming Language :: Python :: 3.5',
35+
}
36+
assert not stale.intersection(classifiers)
37+
assert 'Programming Language :: Python :: 3.6' in classifiers

0 commit comments

Comments
 (0)