Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
145e091d
Commit
145e091d
authored
Oct 27, 2009
by
Tarek Ziadé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
parent
ecff8b73
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
7 deletions
+62
-7
core.py
core.py
+3
-2
dist.py
dist.py
+30
-5
tests/test_dist.py
tests/test_dist.py
+29
-0
No files found.
core.py
View file @
145e091d
...
...
@@ -129,8 +129,9 @@ def setup (**attrs):
if
_setup_stop_after
==
"config"
:
return
dist
# Parse the command line; any command-line errors are the end user's
# fault, so turn them into SystemExit to suppress tracebacks.
# Parse the command line and override config files; any
# command-line errors are the end user's fault, so turn them into
# SystemExit to suppress tracebacks.
try
:
ok
=
dist
.
parse_command_line
()
except
DistutilsArgError
,
msg
:
...
...
dist.py
View file @
145e091d
...
...
@@ -56,7 +56,9 @@ class Distribution:
(
'quiet'
,
'q'
,
"run quietly (turns verbosity off)"
),
(
'dry-run'
,
'n'
,
"don't actually do anything"
),
(
'help'
,
'h'
,
"show detailed help message"
),
]
(
'no-user-cfg'
,
None
,
'ignore pydistutils.cfg in your home directory'
),
]
# 'common_usage' is a short (2-3 line) string describing the common
# usage of the setup script.
...
...
@@ -264,6 +266,22 @@ Common commands: (see '--help-commands' for more)
else
:
sys
.
stderr
.
write
(
msg
+
"
\
n
"
)
# no-user-cfg is handled before other command line args
# because other args override the config files, and this
# one is needed before we can load the config files.
# If attrs['script_args'] wasn't passed, assume false.
#
# This also make sure we just look at the global options
self
.
want_user_cfg
=
True
if
self
.
script_args
is
not
None
:
for
arg
in
self
.
script_args
:
if
not
arg
.
startswith
(
'-'
):
break
if
arg
==
'--no-user-cfg'
:
self
.
want_user_cfg
=
False
break
self
.
finalize_options
()
def
get_option_dict
(
self
,
command
):
...
...
@@ -316,7 +334,10 @@ Common commands: (see '--help-commands' for more)
Distutils installation directory (ie. where the top-level
Distutils __inst__.py file lives), a file in the user's home
directory named .pydistutils.cfg on Unix and pydistutils.cfg
on Windows/Mac, and setup.cfg in the current directory.
on Windows/Mac; and setup.cfg in the current directory.
The file in the user's home directory can be disabled with the
--no-user-cfg option.
"""
files
=
[]
check_environ
()
...
...
@@ -336,15 +357,19 @@ Common commands: (see '--help-commands' for more)
user_filename
=
"pydistutils.cfg"
# And look for the user config file
user_file
=
os
.
path
.
join
(
os
.
path
.
expanduser
(
'~'
),
user_filename
)
if
os
.
path
.
isfile
(
user_file
):
files
.
append
(
user_file
)
if
self
.
want_user_cfg
:
user_file
=
os
.
path
.
join
(
os
.
path
.
expanduser
(
'~'
),
user_filename
)
if
os
.
path
.
isfile
(
user_file
):
files
.
append
(
user_file
)
# All platforms support local setup.cfg
local_file
=
"setup.cfg"
if
os
.
path
.
isfile
(
local_file
):
files
.
append
(
local_file
)
if
DEBUG
:
self
.
announce
(
"using config files: %s"
%
', '
.
join
(
files
))
return
files
def
parse_config_files
(
self
,
filenames
=
None
):
...
...
tests/test_dist.py
View file @
145e091d
...
...
@@ -209,6 +209,35 @@ class DistributionTestCase(support.TempdirManager,
kwargs
=
{
'level'
:
'ok2'
}
self
.
assertRaises
(
ValueError
,
dist
.
announce
,
args
,
kwargs
)
def
test_find_config_files_disable
(
self
):
# Ticket #1180: Allow user to disable their home config file.
temp_home
=
self
.
mkdtemp
()
if
os
.
name
==
'posix'
:
user_filename
=
os
.
path
.
join
(
temp_home
,
".pydistutils.cfg"
)
else
:
user_filename
=
os
.
path
.
join
(
temp_home
,
"pydistutils.cfg"
)
with
open
(
user_filename
,
'w'
)
as
f
:
f
.
write
(
'[distutils]
\
n
'
)
def
_expander
(
path
):
return
temp_home
old_expander
=
os
.
path
.
expanduser
os
.
path
.
expanduser
=
_expander
try
:
d
=
distutils
.
dist
.
Distribution
()
all_files
=
d
.
find_config_files
()
d
=
distutils
.
dist
.
Distribution
(
attrs
=
{
'script_args'
:
[
'--no-user-cfg'
]})
files
=
d
.
find_config_files
()
finally
:
os
.
path
.
expanduser
=
old_expander
# make sure --no-user-cfg disables the user cfg file
self
.
assertEquals
(
len
(
all_files
)
-
1
,
len
(
files
))
class
MetadataTestCase
(
support
.
TempdirManager
,
support
.
EnvironGuard
,
unittest
.
TestCase
):
...
...
Write
Preview
Markdown
is supported
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