Skip to content

Commit

Permalink
Update Python < 3.7 (3.2 to 3.6) obsolete code and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Oct 27, 2023
1 parent 2384d91 commit 01ca1f2
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 45 deletions.
11 changes: 1 addition & 10 deletions pkg_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,7 @@
import importlib
from pkgutil import get_importer

try:
import _imp
except ImportError:
# Python 3.2 compatibility
import imp as _imp

try:
FileExistsError
except NameError:
FileExistsError = OSError
import _imp

# capture these to bypass sandboxing
from os import utime
Expand Down
13 changes: 1 addition & 12 deletions pkg_resources/tests/test_pkg_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,6 @@
import pkg_resources


def timestamp(dt):
"""
Return a timestamp for a local, naive datetime instance.
"""
try:
return dt.timestamp()
except AttributeError:
# Python 3.2 and earlier
return time.mktime(dt.timetuple())


class EggRemover(str):
def __call__(self):
if self in sys.path:
Expand Down Expand Up @@ -123,7 +112,7 @@ def test_resource_filename_rewrites_on_change(self):
f = open(filename, 'w')
f.write('hello, world?')
f.close()
ts = timestamp(self.ref_time)
ts = self.ref_time.timestamp()
os.utime(filename, (ts, ts))
filename = zp.get_resource_filename(manager, 'data.dat')
with open(filename) as f:
Expand Down
3 changes: 2 additions & 1 deletion setuptools/command/easy_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,9 @@ def finalize_options(self): # noqa: C901 # is too complex (25) # FIXME
'py_version_nodot': f'{sys.version_info.major}{sys.version_info.minor}',
'sys_prefix': self.config_vars['prefix'],
'sys_exec_prefix': self.config_vars['exec_prefix'],
# Only python 3.2+ has abiflags
# Only POSIX systems have abiflags
'abiflags': getattr(sys, 'abiflags', ''),
# Only python 3.9+ has platlibdir
'platlibdir': getattr(sys, 'platlibdir', 'lib'),
}
)
Expand Down
8 changes: 0 additions & 8 deletions setuptools/command/sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,6 @@ def run(self):
def initialize_options(self):
orig.sdist.initialize_options(self)

self._default_to_gztar()

def _default_to_gztar(self):
# only needed on Python prior to 3.6.
if sys.version_info >= (3, 6, 0, 'beta', 1):
return
self.formats = ['gztar']

def make_distribution(self):
"""
Workaround for #516
Expand Down
3 changes: 1 addition & 2 deletions setuptools/monkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ def patch_for_msvc_specialized_compiler():
Patch functions in distutils to use standalone Microsoft Visual C++
compilers.
"""
# import late to avoid circular imports on Python < 3.5
msvc = import_module('setuptools.msvc')
from . import msvc

if platform.system() != 'Windows':
# Compilers only available on Microsoft Windows
Expand Down
13 changes: 1 addition & 12 deletions setuptools/tests/test_find_packages.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
"""Tests for automatic package discovery"""
import os
import sys
import shutil
import tempfile
import platform

import pytest

Expand All @@ -27,15 +25,6 @@ def can_symlink():
return can


def has_symlink():
bad_symlink = (
# Windows symlink directory detection is broken on Python 3.2
platform.system() == 'Windows'
and sys.version_info[:2] == (3, 2)
)
return can_symlink() and not bad_symlink


class TestFindPackages:
def setup_method(self, method):
self.dist_dir = tempfile.mkdtemp()
Expand Down Expand Up @@ -134,7 +123,7 @@ def test_dir_with_packages_in_subdir_is_excluded(self):
packages = find_packages(self.dist_dir)
assert 'build.pkg' not in packages

@pytest.mark.skipif(not has_symlink(), reason='Symlink support required')
@pytest.mark.skipif(not can_symlink(), reason='Symlink support required')
def test_symlinked_packages_are_included(self):
"""
A symbolically-linked directory should be treated like any other
Expand Down

0 comments on commit 01ca1f2

Please sign in to comment.