Skip to content

Commit df57f70

Browse files
committed
issue2551183 - Replace references to distutils in roundup/dist/command
First pass at fixing this. Seems to work in: native install virtual env python 2.7 and 3.6. Also docker python 3. Could use more testing though.
1 parent 96c0973 commit df57f70

File tree

4 files changed

+43
-14
lines changed

4 files changed

+43
-14
lines changed

roundup/dist/command/bdist_rpm.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,22 @@
33
# All rights reserved.
44
# For license terms see the file COPYING.txt.
55
#
6-
from distutils.command.bdist_rpm import bdist_rpm as base
7-
from distutils.file_util import write_file
6+
# converted to not use distutils 2021
7+
from setuptools.command.bdist_rpm import bdist_rpm as base
88
import os
99

10+
# cribbed from 2.7 distutils
11+
def write_file (filename, contents):
12+
"""Create a file with the specified name and write 'contents' (a
13+
sequence of strings without line terminators) to it.
14+
"""
15+
f = open(filename, "w")
16+
try:
17+
for line in contents:
18+
f.write(line + "\n")
19+
finally:
20+
f.close()
21+
1022
class bdist_rpm(base):
1123

1224
def finalize_options(self):

roundup/dist/command/build.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
#
66
from __future__ import print_function
77
from roundup import msgfmt
8-
from distutils.command.build import build as base
8+
try:
9+
from setuptool.command.install import install as base
10+
raise ImportError
11+
except ImportError:
12+
from distutils.command.build import build as base
913
import os
1014
from glob import glob
1115

@@ -24,10 +28,11 @@ def check_manifest():
2428
"""Check that the files listed in the MANIFEST are present when the
2529
source is unpacked.
2630
"""
31+
manifest_file = 'roundup.egg-info/SOURCES.txt'
2732
try:
28-
f = open('MANIFEST')
33+
f=open(manifest_file)
2934
except:
30-
print('\n*** SOURCE WARNING: The MANIFEST file is missing!')
35+
print('\n*** SOURCE WARNING: The MANIFEST file "%s" is missing!' % manifest_file)
3136
return
3237
try:
3338
manifest = [l.strip() for l in f.readlines()]

roundup/dist/command/build_doc.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,26 @@
88
import os.path
99
import glob
1010

11-
from distutils.command import build
12-
from distutils.spawn import spawn, find_executable
13-
from distutils.dep_util import newer, newer_group
14-
from distutils.dir_util import copy_tree, remove_tree, mkpath
15-
from distutils.file_util import copy_file
16-
from distutils import sysconfig
17-
18-
class build_doc(build.build):
11+
try:
12+
from setuptools.command.install import install as _build_py
13+
raise ImportError
14+
except ImportError:
15+
from distutils.command.build import build as _build_py # try/except clause
16+
orig_build = _build_py
17+
18+
try:
19+
# would be nice to use setuptools.Command.spawn() as it
20+
# obeys the dry-run flag.
21+
from subprocess import run as spawn
22+
except ImportError:
23+
from distutils.spawn import spawn # try/except: in except for subprocess
24+
25+
try:
26+
from distutils.spawn import find_executable # try/except: in try local find
27+
except ImportError:
28+
from roundup.dist.command import find_executable
29+
30+
class build_doc(_build_py):
1931
"""Defines the specific procedure to build roundup's documentation."""
2032

2133
description = "build documentation"

roundup/dist/command/install_lib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from roundup.dist.command.build import build_message_files, check_manifest
2-
from distutils.command.install_lib import install_lib as base
2+
from setuptools.command.install_lib import install_lib as base
33

44
class install_lib(base):
55

0 commit comments

Comments
 (0)