Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
7c45632f
Kaydet (Commit)
7c45632f
authored
Tem 02, 2014
tarafından
Jason R. Coombs
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Normalize style per PEP-8
üst
3e887222
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
35 deletions
+34
-35
dist.py
Lib/distutils/dist.py
+34
-35
No files found.
Lib/distutils/dist.py
Dosyayı görüntüle @
7c45632f
...
@@ -4,7 +4,9 @@ Provides the Distribution class, which represents the module distribution
...
@@ -4,7 +4,9 @@ Provides the Distribution class, which represents the module distribution
being built/installed/distributed.
being built/installed/distributed.
"""
"""
import
sys
,
os
,
re
import
sys
import
os
import
re
from
email
import
message_from_file
from
email
import
message_from_file
try
:
try
:
...
@@ -22,7 +24,7 @@ from distutils.debug import DEBUG
...
@@ -22,7 +24,7 @@ from distutils.debug import DEBUG
# the same as a Python NAME -- I don't allow leading underscores. The fact
# the same as a Python NAME -- I don't allow leading underscores. The fact
# that they're very similar is no coincidence; the default naming scheme is
# that they're very similar is no coincidence; the default naming scheme is
# to look for a Python module named after the command.
# to look for a Python module named after the command.
command_re
=
re
.
compile
(
r'^[a-zA-Z]([a-zA-Z0-9_]*)$'
)
command_re
=
re
.
compile
(
r'^[a-zA-Z]([a-zA-Z0-9_]*)$'
)
class
Distribution
:
class
Distribution
:
...
@@ -39,7 +41,6 @@ class Distribution:
...
@@ -39,7 +41,6 @@ class Distribution:
See the code for 'setup()', in core.py, for details.
See the code for 'setup()', in core.py, for details.
"""
"""
# 'global_options' describes the command-line options that may be
# 'global_options' describes the command-line options that may be
# supplied to the setup script prior to any actual commands.
# supplied to the setup script prior to any actual commands.
# Eg. "./setup.py -n" or "./setup.py --quiet" both take advantage of
# Eg. "./setup.py -n" or "./setup.py --quiet" both take advantage of
...
@@ -48,12 +49,13 @@ class Distribution:
...
@@ -48,12 +49,13 @@ class Distribution:
# don't want to pollute the commands with too many options that they
# don't want to pollute the commands with too many options that they
# have minimal control over.
# have minimal control over.
# The fourth entry for verbose means that it can be repeated.
# The fourth entry for verbose means that it can be repeated.
global_options
=
[(
'verbose'
,
'v'
,
"run verbosely (default)"
,
1
),
global_options
=
[
(
'quiet'
,
'q'
,
"run quietly (turns verbosity off)"
),
(
'verbose'
,
'v'
,
"run verbosely (default)"
,
1
),
(
'dry-run'
,
'n'
,
"don't actually do anything"
),
(
'quiet'
,
'q'
,
"run quietly (turns verbosity off)"
),
(
'help'
,
'h'
,
"show detailed help message"
),
(
'dry-run'
,
'n'
,
"don't actually do anything"
),
(
'no-user-cfg'
,
None
,
(
'help'
,
'h'
,
"show detailed help message"
),
'ignore pydistutils.cfg in your home directory'
),
(
'no-user-cfg'
,
None
,
'ignore pydistutils.cfg in your home directory'
),
]
]
# 'common_usage' is a short (2-3 line) string describing the common
# 'common_usage' is a short (2-3 line) string describing the common
...
@@ -115,10 +117,9 @@ Common commands: (see '--help-commands' for more)
...
@@ -115,10 +117,9 @@ Common commands: (see '--help-commands' for more)
# negative options are options that exclude other options
# negative options are options that exclude other options
negative_opt
=
{
'quiet'
:
'verbose'
}
negative_opt
=
{
'quiet'
:
'verbose'
}
# -- Creation/initialization methods -------------------------------
# -- Creation/initialization methods -------------------------------
def
__init__
(
self
,
attrs
=
None
):
def
__init__
(
self
,
attrs
=
None
):
"""Construct a new Distribution instance: initialize all the
"""Construct a new Distribution instance: initialize all the
attributes of a Distribution, and then use 'attrs' (a dictionary
attributes of a Distribution, and then use 'attrs' (a dictionary
mapping attribute names to values) to assign some of those
mapping attribute names to values) to assign some of those
...
@@ -532,15 +533,15 @@ Common commands: (see '--help-commands' for more)
...
@@ -532,15 +533,15 @@ Common commands: (see '--help-commands' for more)
# to be sure that the basic "command" interface is implemented.
# to be sure that the basic "command" interface is implemented.
if
not
issubclass
(
cmd_class
,
Command
):
if
not
issubclass
(
cmd_class
,
Command
):
raise
DistutilsClassError
(
raise
DistutilsClassError
(
"command class
%
s must subclass Command"
%
cmd_class
)
"command class
%
s must subclass Command"
%
cmd_class
)
# Also make sure that the command object provides a list of its
# Also make sure that the command object provides a list of its
# known options.
# known options.
if
not
(
hasattr
(
cmd_class
,
'user_options'
)
and
if
not
(
hasattr
(
cmd_class
,
'user_options'
)
and
isinstance
(
cmd_class
.
user_options
,
list
)):
isinstance
(
cmd_class
.
user_options
,
list
)):
raise
DistutilsClassError
((
"command class
%
s must provide "
+
msg
=
(
"command class
%
s must provide "
"'user_options' attribute (a list of tuples)"
)
%
\
"'user_options' attribute (a list of tuples)"
)
cmd_class
)
raise
DistutilsClassError
(
msg
%
cmd_class
)
# If the command class has a list of negative alias options,
# If the command class has a list of negative alias options,
# merge it in with the global negative aliases.
# merge it in with the global negative aliases.
...
@@ -552,12 +553,11 @@ Common commands: (see '--help-commands' for more)
...
@@ -552,12 +553,11 @@ Common commands: (see '--help-commands' for more)
# Check for help_options in command class. They have a different
# Check for help_options in command class. They have a different
# format (tuple of four) so we need to preprocess them here.
# format (tuple of four) so we need to preprocess them here.
if
(
hasattr
(
cmd_class
,
'help_options'
)
and
if
(
hasattr
(
cmd_class
,
'help_options'
)
and
isinstance
(
cmd_class
.
help_options
,
list
)):
isinstance
(
cmd_class
.
help_options
,
list
)):
help_options
=
fix_help_options
(
cmd_class
.
help_options
)
help_options
=
fix_help_options
(
cmd_class
.
help_options
)
else
:
else
:
help_options
=
[]
help_options
=
[]
# All commands support the global options too, just by adding
# All commands support the global options too, just by adding
# in 'global_options'.
# in 'global_options'.
parser
.
set_option_table
(
self
.
global_options
+
parser
.
set_option_table
(
self
.
global_options
+
...
@@ -570,7 +570,7 @@ Common commands: (see '--help-commands' for more)
...
@@ -570,7 +570,7 @@ Common commands: (see '--help-commands' for more)
return
return
if
(
hasattr
(
cmd_class
,
'help_options'
)
and
if
(
hasattr
(
cmd_class
,
'help_options'
)
and
isinstance
(
cmd_class
.
help_options
,
list
)):
isinstance
(
cmd_class
.
help_options
,
list
)):
help_option_found
=
0
help_option_found
=
0
for
(
help_option
,
short
,
desc
,
func
)
in
cmd_class
.
help_options
:
for
(
help_option
,
short
,
desc
,
func
)
in
cmd_class
.
help_options
:
if
hasattr
(
opts
,
parser
.
get_attr_name
(
help_option
)):
if
hasattr
(
opts
,
parser
.
get_attr_name
(
help_option
)):
...
@@ -647,7 +647,7 @@ Common commands: (see '--help-commands' for more)
...
@@ -647,7 +647,7 @@ Common commands: (see '--help-commands' for more)
else
:
else
:
klass
=
self
.
get_command_class
(
command
)
klass
=
self
.
get_command_class
(
command
)
if
(
hasattr
(
klass
,
'help_options'
)
and
if
(
hasattr
(
klass
,
'help_options'
)
and
isinstance
(
klass
.
help_options
,
list
)):
isinstance
(
klass
.
help_options
,
list
)):
parser
.
set_option_table
(
klass
.
user_options
+
parser
.
set_option_table
(
klass
.
user_options
+
fix_help_options
(
klass
.
help_options
))
fix_help_options
(
klass
.
help_options
))
else
:
else
:
...
@@ -814,7 +814,7 @@ Common commands: (see '--help-commands' for more)
...
@@ -814,7 +814,7 @@ Common commands: (see '--help-commands' for more)
klass_name
=
command
klass_name
=
command
try
:
try
:
__import__
(
module_name
)
__import__
(
module_name
)
module
=
sys
.
modules
[
module_name
]
module
=
sys
.
modules
[
module_name
]
except
ImportError
:
except
ImportError
:
continue
continue
...
@@ -823,8 +823,8 @@ Common commands: (see '--help-commands' for more)
...
@@ -823,8 +823,8 @@ Common commands: (see '--help-commands' for more)
klass
=
getattr
(
module
,
klass_name
)
klass
=
getattr
(
module
,
klass_name
)
except
AttributeError
:
except
AttributeError
:
raise
DistutilsModuleError
(
raise
DistutilsModuleError
(
"invalid command '
%
s' (no class '
%
s' in module '
%
s')"
"invalid command '
%
s' (no class '
%
s' in module '
%
s')"
%
(
command
,
klass_name
,
module_name
))
%
(
command
,
klass_name
,
module_name
))
self
.
cmdclass
[
command
]
=
klass
self
.
cmdclass
[
command
]
=
klass
return
klass
return
klass
...
@@ -840,7 +840,7 @@ Common commands: (see '--help-commands' for more)
...
@@ -840,7 +840,7 @@ Common commands: (see '--help-commands' for more)
cmd_obj
=
self
.
command_obj
.
get
(
command
)
cmd_obj
=
self
.
command_obj
.
get
(
command
)
if
not
cmd_obj
and
create
:
if
not
cmd_obj
and
create
:
if
DEBUG
:
if
DEBUG
:
self
.
announce
(
"Distribution.get_command_obj(): "
\
self
.
announce
(
"Distribution.get_command_obj(): "
"creating '
%
s' command object"
%
command
)
"creating '
%
s' command object"
%
command
)
klass
=
self
.
get_command_class
(
command
)
klass
=
self
.
get_command_class
(
command
)
...
@@ -897,8 +897,8 @@ Common commands: (see '--help-commands' for more)
...
@@ -897,8 +897,8 @@ Common commands: (see '--help-commands' for more)
setattr
(
command_obj
,
option
,
value
)
setattr
(
command_obj
,
option
,
value
)
else
:
else
:
raise
DistutilsOptionError
(
raise
DistutilsOptionError
(
"error in
%
s: command '
%
s' has no such option '
%
s'"
"error in
%
s: command '
%
s' has no such option '
%
s'"
%
(
source
,
command_name
,
option
))
%
(
source
,
command_name
,
option
))
except
ValueError
as
msg
:
except
ValueError
as
msg
:
raise
DistutilsOptionError
(
msg
)
raise
DistutilsOptionError
(
msg
)
...
@@ -974,7 +974,6 @@ Common commands: (see '--help-commands' for more)
...
@@ -974,7 +974,6 @@ Common commands: (see '--help-commands' for more)
cmd_obj
.
run
()
cmd_obj
.
run
()
self
.
have_run
[
command
]
=
1
self
.
have_run
[
command
]
=
1
# -- Distribution query methods ------------------------------------
# -- Distribution query methods ------------------------------------
def
has_pure_modules
(
self
):
def
has_pure_modules
(
self
):
...
@@ -1112,17 +1111,17 @@ class DistributionMetadata:
...
@@ -1112,17 +1111,17 @@ class DistributionMetadata:
"""
"""
version
=
'1.0'
version
=
'1.0'
if
(
self
.
provides
or
self
.
requires
or
self
.
obsoletes
or
if
(
self
.
provides
or
self
.
requires
or
self
.
obsoletes
or
self
.
classifiers
or
self
.
download_url
):
self
.
classifiers
or
self
.
download_url
):
version
=
'1.1'
version
=
'1.1'
file
.
write
(
'Metadata-Version:
%
s
\n
'
%
version
)
file
.
write
(
'Metadata-Version:
%
s
\n
'
%
version
)
file
.
write
(
'Name:
%
s
\n
'
%
self
.
get_name
()
)
file
.
write
(
'Name:
%
s
\n
'
%
self
.
get_name
())
file
.
write
(
'Version:
%
s
\n
'
%
self
.
get_version
()
)
file
.
write
(
'Version:
%
s
\n
'
%
self
.
get_version
())
file
.
write
(
'Summary:
%
s
\n
'
%
self
.
get_description
()
)
file
.
write
(
'Summary:
%
s
\n
'
%
self
.
get_description
())
file
.
write
(
'Home-page:
%
s
\n
'
%
self
.
get_url
()
)
file
.
write
(
'Home-page:
%
s
\n
'
%
self
.
get_url
())
file
.
write
(
'Author:
%
s
\n
'
%
self
.
get_contact
()
)
file
.
write
(
'Author:
%
s
\n
'
%
self
.
get_contact
())
file
.
write
(
'Author-email:
%
s
\n
'
%
self
.
get_contact_email
()
)
file
.
write
(
'Author-email:
%
s
\n
'
%
self
.
get_contact_email
())
file
.
write
(
'License:
%
s
\n
'
%
self
.
get_license
()
)
file
.
write
(
'License:
%
s
\n
'
%
self
.
get_license
())
if
self
.
download_url
:
if
self
.
download_url
:
file
.
write
(
'Download-URL:
%
s
\n
'
%
self
.
download_url
)
file
.
write
(
'Download-URL:
%
s
\n
'
%
self
.
download_url
)
...
@@ -1131,7 +1130,7 @@ class DistributionMetadata:
...
@@ -1131,7 +1130,7 @@ class DistributionMetadata:
keywords
=
','
.
join
(
self
.
get_keywords
())
keywords
=
','
.
join
(
self
.
get_keywords
())
if
keywords
:
if
keywords
:
file
.
write
(
'Keywords:
%
s
\n
'
%
keywords
)
file
.
write
(
'Keywords:
%
s
\n
'
%
keywords
)
self
.
_write_list
(
file
,
'Platform'
,
self
.
get_platforms
())
self
.
_write_list
(
file
,
'Platform'
,
self
.
get_platforms
())
self
.
_write_list
(
file
,
'Classifier'
,
self
.
get_classifiers
())
self
.
_write_list
(
file
,
'Classifier'
,
self
.
get_classifiers
())
...
...
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