Skip to content
This repository was archived by the owner on Feb 1, 2023. It is now read-only.

Commit 673f99c

Browse files
fchapotonMatthias Koeppe
authored andcommitted
start replacing distutils by setuptools
1 parent 13b4090 commit 673f99c

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

src/sage_setup/command/sage_build_cython.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
import time
1010
import json
1111
from distutils import log
12-
from distutils.cmd import Command
13-
from distutils.errors import (DistutilsModuleError,
14-
DistutilsOptionError)
12+
from setuptools import Command
1513

1614
from sage_setup.util import stable_uniq
1715
from sage_setup.find import find_extra_files
@@ -130,12 +128,12 @@ def finalize_options(self):
130128
try:
131129
self.parallel = int(self.parallel)
132130
except ValueError:
133-
raise DistutilsOptionError("parallel should be an integer")
131+
raise ValueError("parallel should be an integer")
134132

135133
try:
136134
import Cython
137135
except ImportError:
138-
raise DistutilsModuleError(
136+
raise ImportError(
139137
"Cython must be installed and importable in order to run "
140138
"the cythonize command")
141139

src/sage_setup/find.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
"""
22
Recursive Directory Contents
33
"""
4-
#*****************************************************************************
4+
# ****************************************************************************
55
# Copyright (C) 2014 Volker Braun <[email protected]>
66
#
77
# This program is free software: you can redistribute it and/or modify
88
# it under the terms of the GNU General Public License as published by
99
# the Free Software Foundation, either version 2 of the License, or
1010
# (at your option) any later version.
1111
# http://www.gnu.org/licenses/
12-
#*****************************************************************************
13-
12+
# ****************************************************************************
1413

1514
import importlib.machinery
1615
import importlib.util
@@ -19,6 +18,7 @@
1918

2019
from collections import defaultdict
2120

21+
2222
def read_distribution(src_file):
2323
"""
2424
Parse ``src_file`` for a ``# sage_setup: distribution = PKG`` directive.
@@ -58,6 +58,7 @@ def read_distribution(src_file):
5858
return value
5959
return ''
6060

61+
6162
def find_python_sources(src_dir, modules=['sage'], distributions=None):
6263
"""
6364
Find all Python packages and Python/Cython modules in the sources.
@@ -115,7 +116,7 @@ def find_python_sources(src_dir, modules=['sage'], distributions=None):
115116
Filtering by distribution (distutils package)::
116117
117118
sage: find_python_sources(SAGE_SRC, distributions=['sage-tdlib'])
118-
([], [], [<distutils.extension.Extension('sage.graphs.graph_decompositions.tdlib')...>])
119+
([], [], [<setuptools.extension.Extension('sage.graphs.graph_decompositions.tdlib')...>])
119120
120121
Benchmarking::
121122
@@ -130,7 +131,7 @@ def find_python_sources(src_dir, modules=['sage'], distributions=None):
130131
sage: find_python_sources(SAGE_SRC, modules=['sage_setup'])
131132
(['sage_setup', ...], [...'sage_setup.find'...], [])
132133
"""
133-
from distutils.extension import Extension
134+
from setuptools import Extension
134135

135136
PYMOD_EXT = get_extensions('source')[0]
136137
INIT_FILE = '__init__' + PYMOD_EXT
@@ -172,6 +173,7 @@ def is_in_distributions(filename):
172173
os.chdir(cwd)
173174
return python_packages, python_modules, cython_modules
174175

176+
175177
def find_extra_files(src_dir, modules, cythonized_dir, special_filenames=[]):
176178
"""
177179
Find all extra files which should be installed.

src/sage_setup/optional_extension.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,17 @@
77
package which must be installed.
88
"""
99

10-
#*****************************************************************************
10+
# ****************************************************************************
1111
# Copyright (C) 2015 Jeroen Demeyer <[email protected]>
1212
#
1313
# This program is free software: you can redistribute it and/or modify
1414
# it under the terms of the GNU General Public License as published by
1515
# the Free Software Foundation, either version 2 of the License, or
1616
# (at your option) any later version.
17-
# http://www.gnu.org/licenses/
18-
#*****************************************************************************
17+
# https://www.gnu.org/licenses/
18+
# ****************************************************************************
1919

20-
21-
from distutils.extension import Extension
20+
from setuptools.extension import Extension
2221
from sage.misc.package import list_packages
2322

2423
all_packages = list_packages(local=True)
@@ -40,6 +39,7 @@ class CythonizeExtension(Extension):
4039
"""
4140
skip_build = True
4241

42+
4343
def is_package_installed_and_updated(pkg):
4444
from sage.misc.package import is_package_installed
4545
try:
@@ -51,6 +51,7 @@ def is_package_installed_and_updated(pkg):
5151
condition = (pkginfo["installed_version"] == pkginfo["remote_version"])
5252
return condition
5353

54+
5455
def OptionalExtension(*args, **kwds):
5556
"""
5657
If some condition (see INPUT) is satisfied, return an ``Extension``.

0 commit comments

Comments
 (0)