Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
98b65922
Commit
98b65922
authored
Jun 01, 2011
by
Éric Araujo
Browse files
Options
Browse Files
Download
Plain Diff
Branch merge
parents
c0725162
25987d0c
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
45 additions
and
143 deletions
+45
-143
Lib/packaging/command/bdist.py
Lib/packaging/command/bdist.py
+1
-0
Lib/packaging/command/sdist.py
Lib/packaging/command/sdist.py
+2
-34
Lib/packaging/compiler/__init__.py
Lib/packaging/compiler/__init__.py
+1
-4
Lib/packaging/compiler/ccompiler.py
Lib/packaging/compiler/ccompiler.py
+1
-1
Lib/packaging/fancy_getopt.py
Lib/packaging/fancy_getopt.py
+28
-91
Lib/packaging/pypi/simple.py
Lib/packaging/pypi/simple.py
+2
-2
Lib/packaging/pypi/xmlrpc.py
Lib/packaging/pypi/xmlrpc.py
+4
-4
Lib/packaging/tests/test_command_build_ext.py
Lib/packaging/tests/test_command_build_ext.py
+2
-2
Lib/packaging/tests/test_command_sdist.py
Lib/packaging/tests/test_command_sdist.py
+4
-5
No files found.
Lib/packaging/command/bdist.py
View file @
98b65922
...
...
@@ -128,6 +128,7 @@ class bdist(Command):
for
i
in
range
(
len
(
self
.
formats
)):
cmd_name
=
commands
[
i
]
sub_cmd
=
self
.
get_reinitialized_command
(
cmd_name
)
sub_cmd
.
format
=
self
.
formats
[
i
]
# passing the owner and group names for tar archiving
if
cmd_name
==
'bdist_dumb'
:
...
...
Lib/packaging/command/sdist.py
View file @
98b65922
"""Create a source distribution."""
import
os
import
sys
import
re
import
sys
from
io
import
StringIO
from
glob
import
glob
from
shutil
import
get_archive_formats
,
rmtree
from
packaging
import
logger
...
...
@@ -203,45 +202,14 @@ class sdist(Command):
def
add_defaults
(
self
):
"""Add all the default files to self.filelist:
- README or README.txt
- test/test*.py
- all pure Python modules mentioned in setup script
- all files pointed by package_data (build_py)
- all files defined in data_files.
- all files defined as scripts.
- all C sources listed as part of extensions or C libraries
in the setup script (doesn't catch C headers!)
Warns if (README or README.txt) or setup.py are missing; everything
else is optional.
Everything is optional.
"""
standards
=
[(
'README'
,
'README.txt'
)]
for
fn
in
standards
:
if
isinstance
(
fn
,
tuple
):
alts
=
fn
got_it
=
False
for
fn
in
alts
:
if
os
.
path
.
exists
(
fn
):
got_it
=
True
self
.
filelist
.
append
(
fn
)
break
if
not
got_it
:
logger
.
warning
(
'%s: standard file not found: should have one of %s'
,
self
.
get_command_name
(),
', '
.
join
(
alts
))
else
:
if
os
.
path
.
exists
(
fn
):
self
.
filelist
.
append
(
fn
)
else
:
logger
.
warning
(
'%s: standard file %r not found'
,
self
.
get_command_name
(),
fn
)
optional
=
[
'test/test*.py'
,
'setup.cfg'
]
for
pattern
in
optional
:
files
=
[
f
for
f
in
glob
(
pattern
)
if
os
.
path
.
isfile
(
f
)]
if
files
:
self
.
filelist
.
extend
(
files
)
for
cmd_name
in
get_command_names
():
try
:
cmd_obj
=
self
.
get_finalized_command
(
cmd_name
)
...
...
Lib/packaging/compiler/__init__.py
View file @
98b65922
...
...
@@ -83,19 +83,16 @@ def customize_compiler(compiler):
# patterns. Order is important; platform mappings are preferred over
# OS names.
_default_compilers
=
(
# Platform string mappings
# on a cygwin built python we can use gcc like an ordinary UNIXish
# compiler
(
'cygwin.*'
,
'unix'
),
(
'os2emx'
,
'emx'
),
# OS name mappings
(
'posix'
,
'unix'
),
(
'nt'
,
'msvc'
),
)
)
def
get_default_compiler
(
osname
=
None
,
platform
=
None
):
""" Determine the default compiler to use for the given platform.
...
...
Lib/packaging/compiler/ccompiler.py
View file @
98b65922
...
...
@@ -352,7 +352,7 @@ class CCompiler:
return
macros
,
objects
,
extra
,
pp_opts
,
build
def
_get_cc_args
(
self
,
pp_opts
,
debug
,
before
):
# works for unixccompiler
, emxccompiler,
cygwinccompiler
# works for unixccompiler
and
cygwinccompiler
cc_args
=
pp_opts
+
[
'-c'
]
if
debug
:
cc_args
[:
0
]
=
[
'-g'
]
...
...
Lib/packaging/fancy_getopt.py
View file @
98b65922
...
...
@@ -13,7 +13,6 @@ It is used under the hood by the command classes. Do not use directly.
import
getopt
import
re
import
sys
import
string
import
textwrap
from
packaging.errors
import
PackagingGetoptError
,
PackagingArgError
...
...
@@ -142,20 +141,20 @@ class FancyGetopt:
for
option
in
self
.
option_table
:
if
len
(
option
)
==
3
:
integer
,
short
,
help
=
option
longopt
,
short
,
help
=
option
repeat
=
0
elif
len
(
option
)
==
4
:
integer
,
short
,
help
,
repeat
=
option
longopt
,
short
,
help
,
repeat
=
option
else
:
# the option table is part of the code, so simply
# assert that it is correct
raise
ValueError
(
"invalid option tuple: %r"
%
option
)
# Type- and value-check the option names
if
not
isinstance
(
integer
,
str
)
or
len
(
integer
)
<
2
:
if
not
isinstance
(
longopt
,
str
)
or
len
(
longopt
)
<
2
:
raise
PackagingGetoptError
(
(
"invalid long option '%s': "
"must be a string of length >= 2"
)
%
integer
)
"must be a string of length >= 2"
)
%
longopt
)
if
(
not
((
short
is
None
)
or
(
isinstance
(
short
,
str
)
and
len
(
short
)
==
1
))):
...
...
@@ -163,55 +162,55 @@ class FancyGetopt:
(
"invalid short option '%s': "
"must be a single character or None"
)
%
short
)
self
.
repeat
[
integer
]
=
repeat
self
.
long_opts
.
append
(
integer
)
self
.
repeat
[
longopt
]
=
repeat
self
.
long_opts
.
append
(
longopt
)
if
integer
[
-
1
]
==
'='
:
# option takes an argument?
if
longopt
[
-
1
]
==
'='
:
# option takes an argument?
if
short
:
short
=
short
+
':'
integer
=
integer
[
0
:
-
1
]
self
.
takes_arg
[
integer
]
=
1
longopt
=
longopt
[
0
:
-
1
]
self
.
takes_arg
[
longopt
]
=
1
else
:
# Is option is a "negative alias" for some other option (eg.
# "quiet" == "!verbose")?
alias_to
=
self
.
negative_alias
.
get
(
integer
)
alias_to
=
self
.
negative_alias
.
get
(
longopt
)
if
alias_to
is
not
None
:
if
self
.
takes_arg
[
alias_to
]:
raise
PackagingGetoptError
(
(
"invalid negative alias '%s': "
"aliased option '%s' takes a value"
)
%
\
(
integer
,
alias_to
))
(
longopt
,
alias_to
))
self
.
long_opts
[
-
1
]
=
integer
# XXX redundant?!
self
.
takes_arg
[
integer
]
=
0
self
.
long_opts
[
-
1
]
=
longopt
# XXX redundant?!
self
.
takes_arg
[
longopt
]
=
0
else
:
self
.
takes_arg
[
integer
]
=
0
self
.
takes_arg
[
longopt
]
=
0
# If this is an alias option, make sure its "takes arg" flag is
# the same as the option it's aliased to.
alias_to
=
self
.
alias
.
get
(
integer
)
alias_to
=
self
.
alias
.
get
(
longopt
)
if
alias_to
is
not
None
:
if
self
.
takes_arg
[
integer
]
!=
self
.
takes_arg
[
alias_to
]:
if
self
.
takes_arg
[
longopt
]
!=
self
.
takes_arg
[
alias_to
]:
raise
PackagingGetoptError
(
(
"invalid alias '%s': inconsistent with "
"aliased option '%s' (one of them takes a value, "
"the other doesn't"
)
%
(
integer
,
alias_to
))
"the other doesn't"
)
%
(
longopt
,
alias_to
))
# Now enforce some bondage on the long option name, so we can
# later translate it to an attribute name on some object. Have
# to do this a bit late to make sure we've removed any trailing
# '='.
if
not
longopt_re
.
match
(
integer
):
if
not
longopt_re
.
match
(
longopt
):
raise
PackagingGetoptError
(
(
"invalid long option name '%s' "
+
"(must be letters, numbers, hyphens only"
)
%
integer
)
"(must be letters, numbers, hyphens only"
)
%
longopt
)
self
.
attr_name
[
integer
]
=
integer
.
replace
(
'-'
,
'_'
)
self
.
attr_name
[
longopt
]
=
longopt
.
replace
(
'-'
,
'_'
)
if
short
:
self
.
short_opts
.
append
(
short
)
self
.
short2long
[
short
[
0
]]
=
integer
self
.
short2long
[
short
[
0
]]
=
longopt
def
getopt
(
self
,
args
=
None
,
object
=
None
):
"""Parse command-line options in args. Store as attributes on object.
...
...
@@ -297,10 +296,10 @@ class FancyGetopt:
# First pass: determine maximum length of long option names
max_opt
=
0
for
option
in
self
.
option_table
:
integer
=
option
[
0
]
longopt
=
option
[
0
]
short
=
option
[
1
]
l
=
len
(
integer
)
if
integer
[
-
1
]
==
'='
:
l
=
len
(
longopt
)
if
longopt
[
-
1
]
==
'='
:
l
=
l
-
1
if
short
is
not
None
:
l
=
l
+
5
# " (-x)" where short == 'x'
...
...
@@ -340,20 +339,20 @@ class FancyGetopt:
lines
=
[
'Option summary:'
]
for
option
in
self
.
option_table
:
integer
,
short
,
help
=
option
[:
3
]
longopt
,
short
,
help
=
option
[:
3
]
text
=
textwrap
.
wrap
(
help
,
text_width
)
# Case 1: no short option at all (makes life easy)
if
short
is
None
:
if
text
:
lines
.
append
(
" --%-*s %s"
%
(
max_opt
,
integer
,
text
[
0
]))
lines
.
append
(
" --%-*s %s"
%
(
max_opt
,
longopt
,
text
[
0
]))
else
:
lines
.
append
(
" --%-*s "
%
(
max_opt
,
integer
))
lines
.
append
(
" --%-*s "
%
(
max_opt
,
longopt
))
# Case 2: we have a short option, so we have to include it
# just after the long option
else
:
opt_names
=
"%s (-%s)"
%
(
integer
,
short
)
opt_names
=
"%s (-%s)"
%
(
longopt
,
short
)
if
text
:
lines
.
append
(
" --%-*s %s"
%
(
max_opt
,
opt_names
,
text
[
0
]))
...
...
@@ -378,68 +377,6 @@ def fancy_getopt(options, negative_opt, object, args):
return
parser
.
getopt
(
args
,
object
)
WS_TRANS
=
str
.
maketrans
(
string
.
whitespace
,
' '
*
len
(
string
.
whitespace
))
def
wrap_text
(
text
,
width
):
"""Split *text* into lines of no more than *width* characters each.
*text* is a str and *width* an int. Returns a list of str.
"""
if
text
is
None
:
return
[]
if
len
(
text
)
<=
width
:
return
[
text
]
text
=
text
.
expandtabs
()
text
=
text
.
translate
(
WS_TRANS
)
chunks
=
re
.
split
(
r'( +|-+)'
,
text
)
chunks
=
[
_f
for
_f
in
chunks
if
_f
]
# ' - ' results in empty strings
lines
=
[]
while
chunks
:
cur_line
=
[]
# list of chunks (to-be-joined)
cur_len
=
0
# length of current line
while
chunks
:
l
=
len
(
chunks
[
0
])
if
cur_len
+
l
<=
width
:
# can squeeze (at least) this chunk in
cur_line
.
append
(
chunks
[
0
])
del
chunks
[
0
]
cur_len
=
cur_len
+
l
else
:
# this line is full
# drop last chunk if all space
if
cur_line
and
cur_line
[
-
1
][
0
]
==
' '
:
del
cur_line
[
-
1
]
break
if
chunks
:
# any chunks left to process?
# if the current line is still empty, then we had a single
# chunk that's too big too fit on a line -- so we break
# down and break it up at the line width
if
cur_len
==
0
:
cur_line
.
append
(
chunks
[
0
][
0
:
width
])
chunks
[
0
]
=
chunks
[
0
][
width
:]
# all-whitespace chunks at the end of a line can be discarded
# (and we know from the re.split above that if a chunk has
# *any* whitespace, it is *all* whitespace)
if
chunks
[
0
][
0
]
==
' '
:
del
chunks
[
0
]
# and store this line in the list-of-all-lines -- as a single
# string, of course!
lines
.
append
(
''
.
join
(
cur_line
))
# while chunks
return
lines
class
OptionDummy
:
"""Dummy class just used as a place to hold command-line option
values as instance attributes."""
...
...
Lib/packaging/pypi/simple.py
View file @
98b65922
"""Spider using the screen-scraping "simple" PyPI API.
This module contains the class
SimpleIndex
Crawler, a simple spider that
This module contains the class Crawler, a simple spider that
can be used to find and retrieve distributions from a project index
(like the Python Package Index), using its so-called simple API (see
reference implementation available at http://pypi.python.org/simple/).
...
...
@@ -178,7 +178,7 @@ class Crawler(BaseClient):
def get_releases(self, requirements, prefer_final=None,
force_update=False):
"""Search for releases and return a ReleaseList object containing
"""Search for releases and return a Release
s
List object containing
the results.
"""
predicate = get_version_predicate(requirements)
...
...
Lib/packaging/pypi/xmlrpc.py
View file @
98b65922
...
...
@@ -31,11 +31,11 @@ class Client(BaseClient):
If no server_url is specified, use the default PyPI XML-RPC URL,
defined in the DEFAULT_XMLRPC_INDEX_URL constant::
>>> client =
XMLRPC
Client()
>>> client = Client()
>>> client.server_url == DEFAULT_XMLRPC_INDEX_URL
True
>>> client =
XMLRPC
Client("http://someurl/")
>>> client = Client("http://someurl/")
>>> client.server_url
'http://someurl/'
"""
...
...
@@ -69,7 +69,7 @@ class Client(BaseClient):
informations (eg. make a new XML-RPC call).
::
>>> client =
XMLRPC
Client()
>>> client = Client()
>>> client.get_releases('Foo')
['1.1', '1.2', '1.3']
...
...
@@ -189,7 +189,7 @@ class Client(BaseClient):
If no server proxy is defined yet, creates a new one::
>>> client =
XmlRpc
Client()
>>> client = Client()
>>> client.proxy()
<ServerProxy for python.org/pypi>
...
...
Lib/packaging/tests/test_command_build_ext.py
View file @
98b65922
...
...
@@ -370,7 +370,7 @@ def test_suite():
src
=
_get_source_filename
()
if
not
os
.
path
.
exists
(
src
):
if
verbose
:
print
(
'test
_build_ext: Cannot find source code (test'
print
(
'test_command
_build_ext: Cannot find source code (test'
' must run in python build dir)'
)
return
unittest
.
TestSuite
()
else
:
...
...
Lib/packaging/tests/test_command_sdist.py
View file @
98b65922
...
...
@@ -33,7 +33,6 @@ setup(name='fake')
MANIFEST
=
"""
\
# file GENERATED by packaging, do NOT edit
README
inroot.txt
data%(sep)sdata.dt
scripts%(sep)sscript.py
...
...
@@ -129,7 +128,7 @@ class SDistTestCase(support.TempdirManager,
content
=
zip_file
.
namelist
()
# making sure everything has been pruned correctly
self
.
assertEqual
(
len
(
content
),
3
)
self
.
assertEqual
(
len
(
content
),
2
)
@
requires_zlib
@
unittest
.
skipIf
(
find_executable
(
'tar'
)
is
None
or
...
...
@@ -214,7 +213,7 @@ class SDistTestCase(support.TempdirManager,
# Making sure everything was added. This includes 9 code and data
# files in addition to PKG-INFO.
self
.
assertEqual
(
len
(
content
),
10
)
self
.
assertEqual
(
len
(
content
),
9
)
# Checking the MANIFEST
with
open
(
join
(
self
.
tmp_dir
,
'MANIFEST'
))
as
fp
:
...
...
@@ -331,7 +330,7 @@ class SDistTestCase(support.TempdirManager,
with
open
(
cmd
.
manifest
)
as
f
:
manifest
=
[
line
.
strip
()
for
line
in
f
.
read
().
split
(
'
\
n
'
)
if
line
.
strip
()
!=
''
]
self
.
assertEqual
(
len
(
manifest
),
4
)
self
.
assertEqual
(
len
(
manifest
),
3
)
# Adding a file
self
.
write_file
((
self
.
tmp_dir
,
'somecode'
,
'doc2.txt'
),
'#'
)
...
...
@@ -348,7 +347,7 @@ class SDistTestCase(support.TempdirManager,
if
line
.
strip
()
!=
''
]
# Do we have the new file in MANIFEST?
self
.
assertEqual
(
len
(
manifest2
),
5
)
self
.
assertEqual
(
len
(
manifest2
),
4
)
self
.
assertIn
(
'doc2.txt'
,
manifest2
[
-
1
])
@
requires_zlib
...
...
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