Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
kwant
tinyarray
Commits
e8a39e6e
Commit
e8a39e6e
authored
Dec 21, 2016
by
Christoph Groth
Browse files
setup.py: restore compatibility with Python 2 ConfigParser module
parent
69433493
Pipeline
#1816
passed with stage
in 49 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
setup.py
View file @
e8a39e6e
...
...
@@ -15,7 +15,6 @@ import subprocess
import
os
import
sys
import
collections
import
configparser
from
setuptools
import
setup
,
Extension
,
Command
from
sysconfig
import
get_platform
from
distutils.errors
import
DistutilsError
,
DistutilsModuleError
...
...
@@ -23,6 +22,11 @@ from setuptools.command.build_ext import build_ext as build_ext_orig
from
setuptools.command.sdist
import
sdist
as
sdist_orig
from
setuptools.command.test
import
test
as
test_orig
try
:
import
configparser
except
ImportError
:
import
ConfigParser
as
configparser
try
:
from
os.path
import
samefile
except
ImportError
:
...
...
@@ -74,7 +78,7 @@ def configure_extensions(exts, aliases=(), build_summary=None):
configs
=
configparser
.
ConfigParser
()
try
:
with
open
(
config_file
)
as
f
:
configs
.
read
_file
(
f
)
configs
.
read
fp
(
f
)
except
IOError
:
config_file_present
=
False
else
:
...
...
@@ -93,9 +97,14 @@ def configure_extensions(exts, aliases=(), build_summary=None):
#### Apply config from file. Use [DEFAULT] section for missing sections.
defaultconfig
=
configs
.
defaults
()
for
name
,
kwargs
in
exts
.
items
():
config
=
configs
[
name
]
if
name
in
configs
else
defaultconfig
for
key
,
value
in
config
.
items
():
try
:
items
=
configs
.
items
(
name
)
except
configparser
.
NoSectionError
:
items
=
defaultconfig
.
items
()
else
:
configs
.
remove_section
(
name
)
for
key
,
value
in
items
:
# Most, but not all, keys are lists of strings
if
key
==
'language'
:
pass
...
...
@@ -117,8 +126,6 @@ def configure_extensions(exts, aliases=(), build_summary=None):
kwargs
[
key
]
=
value
kwargs
.
setdefault
(
'depends'
,
[]).
append
(
config_file
)
if
config
is
not
defaultconfig
:
del
configs
[
name
]
unknown_sections
=
configs
.
sections
()
if
unknown_sections
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment