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
e6405217
Kaydet (Commit)
e6405217
authored
Kas 03, 2011
tarafından
Éric Araujo
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge follow-up for #11254 and other changes from 3.2
üst
88080150
c465b2f8
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
134 additions
and
89 deletions
+134
-89
cmdline.rst
Doc/using/cmdline.rst
+2
-1
_pyio.py
Lib/_pyio.py
+1
-1
build_py.py
Lib/distutils/command/build_py.py
+6
-3
install_lib.py
Lib/distutils/command/install_lib.py
+5
-2
test_bdist_dumb.py
Lib/distutils/tests/test_bdist_dumb.py
+17
-6
test_build_py.py
Lib/distutils/tests/test_build_py.py
+46
-26
test_install.py
Lib/distutils/tests/test_install.py
+19
-22
test_install_lib.py
Lib/distutils/tests/test_install_lib.py
+30
-22
test_sdist.py
Lib/distutils/tests/test_sdist.py
+4
-4
import.c
Python/import.c
+4
-2
No files found.
Doc/using/cmdline.rst
Dosyayı görüntüle @
e6405217
...
@@ -455,7 +455,8 @@ These environment variables influence Python's behavior.
...
@@ -455,7 +455,8 @@ These environment variables influence Python's behavior.
.. envvar:: PYTHONDONTWRITEBYTECODE
.. envvar:: PYTHONDONTWRITEBYTECODE
If this is set, Python won't try to write ``.pyc`` or ``.pyo`` files on the
If this is set, Python won't try to write ``.pyc`` or ``.pyo`` files on the
import of source modules.
import of source modules. This is equivalent to specifying the :option:`-B`
option.
.. envvar:: PYTHONIOENCODING
.. envvar:: PYTHONIOENCODING
...
...
Lib/_pyio.py
Dosyayı görüntüle @
e6405217
...
@@ -1455,7 +1455,7 @@ class TextIOWrapper(TextIOBase):
...
@@ -1455,7 +1455,7 @@ class TextIOWrapper(TextIOBase):
enabled. With this enabled, on input, the lines endings '\n', '\r',
enabled. With this enabled, on input, the lines endings '\n', '\r',
or '\r\n' are translated to '\n' before being returned to the
or '\r\n' are translated to '\n' before being returned to the
caller. Conversely, on output, '\n' is translated to the system
caller. Conversely, on output, '\n' is translated to the system
default line sep
e
rator, os.linesep. If newline is any other of its
default line sep
a
rator, os.linesep. If newline is any other of its
legal values, that newline becomes the newline when the file is read
legal values, that newline becomes the newline when the file is read
and it is returned untranslated. On output, '\n' is converted to the
and it is returned untranslated. On output, '\n' is converted to the
newline.
newline.
...
...
Lib/distutils/command/build_py.py
Dosyayı görüntüle @
e6405217
...
@@ -2,7 +2,8 @@
...
@@ -2,7 +2,8 @@
Implements the Distutils 'build_py' command."""
Implements the Distutils 'build_py' command."""
import
sys
,
os
import
os
import
imp
import
sys
import
sys
from
glob
import
glob
from
glob
import
glob
...
@@ -311,9 +312,11 @@ class build_py (Command):
...
@@ -311,9 +312,11 @@ class build_py (Command):
outputs
.
append
(
filename
)
outputs
.
append
(
filename
)
if
include_bytecode
:
if
include_bytecode
:
if
self
.
compile
:
if
self
.
compile
:
outputs
.
append
(
filename
+
"c"
)
outputs
.
append
(
imp
.
cache_from_source
(
filename
,
debug_override
=
True
))
if
self
.
optimize
>
0
:
if
self
.
optimize
>
0
:
outputs
.
append
(
filename
+
"o"
)
outputs
.
append
(
imp
.
cache_from_source
(
filename
,
debug_override
=
False
))
outputs
+=
[
outputs
+=
[
os
.
path
.
join
(
build_dir
,
filename
)
os
.
path
.
join
(
build_dir
,
filename
)
...
...
Lib/distutils/command/install_lib.py
Dosyayı görüntüle @
e6405217
...
@@ -4,6 +4,7 @@ Implements the Distutils 'install_lib' command
...
@@ -4,6 +4,7 @@ Implements the Distutils 'install_lib' command
(install all Python modules)."""
(install all Python modules)."""
import
os
import
os
import
imp
import
sys
import
sys
from
distutils.core
import
Command
from
distutils.core
import
Command
...
@@ -164,9 +165,11 @@ class install_lib(Command):
...
@@ -164,9 +165,11 @@ class install_lib(Command):
if
ext
!=
PYTHON_SOURCE_EXTENSION
:
if
ext
!=
PYTHON_SOURCE_EXTENSION
:
continue
continue
if
self
.
compile
:
if
self
.
compile
:
bytecode_files
.
append
(
py_file
+
"c"
)
bytecode_files
.
append
(
imp
.
cache_from_source
(
py_file
,
debug_override
=
True
))
if
self
.
optimize
>
0
:
if
self
.
optimize
>
0
:
bytecode_files
.
append
(
py_file
+
"o"
)
bytecode_files
.
append
(
imp
.
cache_from_source
(
py_file
,
debug_override
=
False
))
return
bytecode_files
return
bytecode_files
...
...
Lib/distutils/tests/test_bdist_dumb.py
Dosyayı görüntüle @
e6405217
"""Tests for distutils.command.bdist_dumb."""
"""Tests for distutils.command.bdist_dumb."""
import
unittest
import
sys
import
os
import
os
import
imp
import
sys
import
zipfile
import
unittest
from
test.support
import
run_unittest
from
test.support
import
run_unittest
from
distutils.core
import
Distribution
from
distutils.core
import
Distribution
...
@@ -72,15 +74,24 @@ class BuildDumbTestCase(support.TempdirManager,
...
@@ -72,15 +74,24 @@ class BuildDumbTestCase(support.TempdirManager,
# see what we have
# see what we have
dist_created
=
os
.
listdir
(
os
.
path
.
join
(
pkg_dir
,
'dist'
))
dist_created
=
os
.
listdir
(
os
.
path
.
join
(
pkg_dir
,
'dist'
))
base
=
"
%
s.
%
s"
%
(
dist
.
get_fullname
(),
cmd
.
plat_name
)
base
=
"
%
s.
%
s
.zip
"
%
(
dist
.
get_fullname
(),
cmd
.
plat_name
)
if
os
.
name
==
'os2'
:
if
os
.
name
==
'os2'
:
base
=
base
.
replace
(
':'
,
'-'
)
base
=
base
.
replace
(
':'
,
'-'
)
wanted
=
[
'
%
s.zip'
%
base
]
self
.
assertEqual
(
dist_created
,
[
base
])
self
.
assertEqual
(
dist_created
,
wanted
)
# now let's check what we have in the zip file
# now let's check what we have in the zip file
# XXX to be done
fp
=
zipfile
.
ZipFile
(
os
.
path
.
join
(
'dist'
,
base
))
try
:
contents
=
fp
.
namelist
()
finally
:
fp
.
close
()
contents
=
sorted
(
os
.
path
.
basename
(
fn
)
for
fn
in
contents
)
wanted
=
[
'foo-0.1-py
%
s.
%
s.egg-info'
%
sys
.
version_info
[:
2
],
'foo.
%
s.pyc'
%
imp
.
get_tag
(),
'foo.py'
]
self
.
assertEqual
(
contents
,
sorted
(
wanted
))
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
BuildDumbTestCase
)
return
unittest
.
makeSuite
(
BuildDumbTestCase
)
...
...
Lib/distutils/tests/test_build_py.py
Dosyayı görüntüle @
e6405217
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
import
os
import
os
import
sys
import
sys
import
io
import
imp
import
imp
import
unittest
import
unittest
...
@@ -54,7 +53,6 @@ class BuildPyTestCase(support.TempdirManager,
...
@@ -54,7 +53,6 @@ class BuildPyTestCase(support.TempdirManager,
# This makes sure the list of outputs includes byte-compiled
# This makes sure the list of outputs includes byte-compiled
# files for Python modules but not for package data files
# files for Python modules but not for package data files
# (there shouldn't *be* byte-code files for those!).
# (there shouldn't *be* byte-code files for those!).
#
self
.
assertEqual
(
len
(
cmd
.
get_outputs
()),
3
)
self
.
assertEqual
(
len
(
cmd
.
get_outputs
()),
3
)
pkgdest
=
os
.
path
.
join
(
destination
,
"pkg"
)
pkgdest
=
os
.
path
.
join
(
destination
,
"pkg"
)
files
=
os
.
listdir
(
pkgdest
)
files
=
os
.
listdir
(
pkgdest
)
...
@@ -64,15 +62,11 @@ class BuildPyTestCase(support.TempdirManager,
...
@@ -64,15 +62,11 @@ class BuildPyTestCase(support.TempdirManager,
if
sys
.
dont_write_bytecode
:
if
sys
.
dont_write_bytecode
:
self
.
assertFalse
(
os
.
path
.
exists
(
pycache_dir
))
self
.
assertFalse
(
os
.
path
.
exists
(
pycache_dir
))
else
:
else
:
# XXX even with -O, distutils writes pyc, not pyo; bug?
pyc_files
=
os
.
listdir
(
pycache_dir
)
pyc_files
=
os
.
listdir
(
pycache_dir
)
self
.
assertIn
(
"__init__.
%
s.pyc"
%
imp
.
get_tag
(),
pyc_files
)
self
.
assertIn
(
"__init__.
%
s.pyc"
%
imp
.
get_tag
(),
pyc_files
)
def
test_empty_package_dir
(
self
):
def
test_empty_package_dir
(
self
):
# See SF 1668596/1720897.
# See bugs #1668596/#1720897
cwd
=
os
.
getcwd
()
# create the distribution files.
sources
=
self
.
mkdtemp
()
sources
=
self
.
mkdtemp
()
open
(
os
.
path
.
join
(
sources
,
"__init__.py"
),
"w"
)
.
close
()
open
(
os
.
path
.
join
(
sources
,
"__init__.py"
),
"w"
)
.
close
()
...
@@ -81,30 +75,55 @@ class BuildPyTestCase(support.TempdirManager,
...
@@ -81,30 +75,55 @@ class BuildPyTestCase(support.TempdirManager,
open
(
os
.
path
.
join
(
testdir
,
"testfile"
),
"w"
)
.
close
()
open
(
os
.
path
.
join
(
testdir
,
"testfile"
),
"w"
)
.
close
()
os
.
chdir
(
sources
)
os
.
chdir
(
sources
)
old_stdout
=
sys
.
stdout
dist
=
Distribution
({
"packages"
:
[
"pkg"
],
sys
.
stdout
=
io
.
StringIO
()
"package_dir"
:
{
"pkg"
:
""
},
"package_data"
:
{
"pkg"
:
[
"doc/*"
]}})
# script_name need not exist, it just need to be initialized
dist
.
script_name
=
os
.
path
.
join
(
sources
,
"setup.py"
)
dist
.
script_args
=
[
"build"
]
dist
.
parse_command_line
()
try
:
try
:
dist
=
Distribution
({
"packages"
:
[
"pkg"
],
dist
.
run_commands
()
"package_dir"
:
{
"pkg"
:
""
},
except
DistutilsFileError
:
"package_data"
:
{
"pkg"
:
[
"doc/*"
]}})
self
.
fail
(
"failed package_data test when package_dir is ''"
)
# script_name need not exist, it just need to be initialized
dist
.
script_name
=
os
.
path
.
join
(
sources
,
"setup.py"
)
@unittest.skipIf
(
sys
.
dont_write_bytecode
,
'byte-compile disabled'
)
dist
.
script_args
=
[
"build"
]
def
test_byte_compile
(
self
):
dist
.
parse_command_line
()
project_dir
,
dist
=
self
.
create_dist
(
py_modules
=
[
'boiledeggs'
])
os
.
chdir
(
project_dir
)
try
:
self
.
write_file
(
'boiledeggs.py'
,
'import antigravity'
)
dist
.
run_commands
()
cmd
=
build_py
(
dist
)
except
DistutilsFileError
:
cmd
.
compile
=
1
self
.
fail
(
"failed package_data test when package_dir is ''"
)
cmd
.
build_lib
=
'here'
finally
:
cmd
.
finalize_options
()
# Restore state.
cmd
.
run
()
os
.
chdir
(
cwd
)
sys
.
stdout
=
old_stdout
found
=
os
.
listdir
(
cmd
.
build_lib
)
self
.
assertEqual
(
sorted
(
found
),
[
'__pycache__'
,
'boiledeggs.py'
])
found
=
os
.
listdir
(
os
.
path
.
join
(
cmd
.
build_lib
,
'__pycache__'
))
self
.
assertEqual
(
found
,
[
'boiledeggs.
%
s.pyc'
%
imp
.
get_tag
()])
@unittest.skipIf
(
sys
.
dont_write_bytecode
,
'byte-compile disabled'
)
def
test_byte_compile_optimized
(
self
):
project_dir
,
dist
=
self
.
create_dist
(
py_modules
=
[
'boiledeggs'
])
os
.
chdir
(
project_dir
)
self
.
write_file
(
'boiledeggs.py'
,
'import antigravity'
)
cmd
=
build_py
(
dist
)
cmd
.
compile
=
0
cmd
.
optimize
=
1
cmd
.
build_lib
=
'here'
cmd
.
finalize_options
()
cmd
.
run
()
found
=
os
.
listdir
(
cmd
.
build_lib
)
self
.
assertEqual
(
sorted
(
found
),
[
'__pycache__'
,
'boiledeggs.py'
])
found
=
os
.
listdir
(
os
.
path
.
join
(
cmd
.
build_lib
,
'__pycache__'
))
self
.
assertEqual
(
sorted
(
found
),
[
'boiledeggs.
%
s.pyo'
%
imp
.
get_tag
()])
def
test_dont_write_bytecode
(
self
):
def
test_dont_write_bytecode
(
self
):
# makes sure byte_compile is not used
# makes sure byte_compile is not used
pkg_dir
,
dist
=
self
.
create_dist
()
dist
=
self
.
create_dist
()[
1
]
cmd
=
build_py
(
dist
)
cmd
=
build_py
(
dist
)
cmd
.
compile
=
1
cmd
.
compile
=
1
cmd
.
optimize
=
1
cmd
.
optimize
=
1
...
@@ -118,6 +137,7 @@ class BuildPyTestCase(support.TempdirManager,
...
@@ -118,6 +137,7 @@ class BuildPyTestCase(support.TempdirManager,
self
.
assertIn
(
'byte-compiling is disabled'
,
self
.
logs
[
0
][
1
])
self
.
assertIn
(
'byte-compiling is disabled'
,
self
.
logs
[
0
][
1
])
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
BuildPyTestCase
)
return
unittest
.
makeSuite
(
BuildPyTestCase
)
...
...
Lib/distutils/tests/test_install.py
Dosyayı görüntüle @
e6405217
"""Tests for distutils.command.install."""
"""Tests for distutils.command.install."""
import
os
import
os
import
imp
import
sys
import
sys
import
unittest
import
unittest
import
site
import
site
...
@@ -67,10 +68,7 @@ class InstallTestCase(support.TempdirManager,
...
@@ -67,10 +68,7 @@ class InstallTestCase(support.TempdirManager,
check_path
(
cmd
.
install_data
,
destination
)
check_path
(
cmd
.
install_data
,
destination
)
def
test_user_site
(
self
):
def
test_user_site
(
self
):
# site.USER_SITE was introduced in 2.6
# test install with --user
if
sys
.
version
<
'2.6'
:
return
# preparing the environment for the test
# preparing the environment for the test
self
.
old_user_base
=
site
.
USER_BASE
self
.
old_user_base
=
site
.
USER_BASE
self
.
old_user_site
=
site
.
USER_SITE
self
.
old_user_site
=
site
.
USER_SITE
...
@@ -87,19 +85,17 @@ class InstallTestCase(support.TempdirManager,
...
@@ -87,19 +85,17 @@ class InstallTestCase(support.TempdirManager,
self
.
old_expand
=
os
.
path
.
expanduser
self
.
old_expand
=
os
.
path
.
expanduser
os
.
path
.
expanduser
=
_expanduser
os
.
path
.
expanduser
=
_expanduser
try
:
def
cleanup
():
# this is the actual test
self
.
_test_user_site
()
finally
:
site
.
USER_BASE
=
self
.
old_user_base
site
.
USER_BASE
=
self
.
old_user_base
site
.
USER_SITE
=
self
.
old_user_site
site
.
USER_SITE
=
self
.
old_user_site
install_module
.
USER_BASE
=
self
.
old_user_base
install_module
.
USER_BASE
=
self
.
old_user_base
install_module
.
USER_SITE
=
self
.
old_user_site
install_module
.
USER_SITE
=
self
.
old_user_site
os
.
path
.
expanduser
=
self
.
old_expand
os
.
path
.
expanduser
=
self
.
old_expand
def
_test_user_site
(
self
):
self
.
addCleanup
(
cleanup
)
for
key
in
(
'nt_user'
,
'unix_user'
,
'os2_home'
):
for
key
in
(
'nt_user'
,
'unix_user'
,
'os2_home'
):
self
.
assert
True
(
key
in
INSTALL_SCHEMES
)
self
.
assert
In
(
key
,
INSTALL_SCHEMES
)
dist
=
Distribution
({
'name'
:
'xx'
})
dist
=
Distribution
({
'name'
:
'xx'
})
cmd
=
install
(
dist
)
cmd
=
install
(
dist
)
...
@@ -107,14 +103,14 @@ class InstallTestCase(support.TempdirManager,
...
@@ -107,14 +103,14 @@ class InstallTestCase(support.TempdirManager,
# making sure the user option is there
# making sure the user option is there
options
=
[
name
for
name
,
short
,
lable
in
options
=
[
name
for
name
,
short
,
lable
in
cmd
.
user_options
]
cmd
.
user_options
]
self
.
assert
True
(
'user'
in
options
)
self
.
assert
In
(
'user'
,
options
)
# setting a value
# setting a value
cmd
.
user
=
1
cmd
.
user
=
1
# user base and site shouldn't be created yet
# user base and site shouldn't be created yet
self
.
assert
True
(
not
os
.
path
.
exists
(
self
.
user_base
))
self
.
assert
False
(
os
.
path
.
exists
(
self
.
user_base
))
self
.
assert
True
(
not
os
.
path
.
exists
(
self
.
user_site
))
self
.
assert
False
(
os
.
path
.
exists
(
self
.
user_site
))
# let's run finalize
# let's run finalize
cmd
.
ensure_finalized
()
cmd
.
ensure_finalized
()
...
@@ -123,8 +119,8 @@ class InstallTestCase(support.TempdirManager,
...
@@ -123,8 +119,8 @@ class InstallTestCase(support.TempdirManager,
self
.
assertTrue
(
os
.
path
.
exists
(
self
.
user_base
))
self
.
assertTrue
(
os
.
path
.
exists
(
self
.
user_base
))
self
.
assertTrue
(
os
.
path
.
exists
(
self
.
user_site
))
self
.
assertTrue
(
os
.
path
.
exists
(
self
.
user_site
))
self
.
assert
True
(
'userbase'
in
cmd
.
config_vars
)
self
.
assert
In
(
'userbase'
,
cmd
.
config_vars
)
self
.
assert
True
(
'usersite'
in
cmd
.
config_vars
)
self
.
assert
In
(
'usersite'
,
cmd
.
config_vars
)
def
test_handle_extra_path
(
self
):
def
test_handle_extra_path
(
self
):
dist
=
Distribution
({
'name'
:
'xx'
,
'extra_path'
:
'path,dirs'
})
dist
=
Distribution
({
'name'
:
'xx'
,
'extra_path'
:
'path,dirs'
})
...
@@ -177,15 +173,16 @@ class InstallTestCase(support.TempdirManager,
...
@@ -177,15 +173,16 @@ class InstallTestCase(support.TempdirManager,
def
test_record
(
self
):
def
test_record
(
self
):
install_dir
=
self
.
mkdtemp
()
install_dir
=
self
.
mkdtemp
()
project_dir
,
dist
=
self
.
create_dist
(
scripts
=
[
'hello'
])
project_dir
,
dist
=
self
.
create_dist
(
py_modules
=
[
'hello'
],
self
.
addCleanup
(
os
.
chdir
,
os
.
getcwd
()
)
scripts
=
[
'sayhi'
]
)
os
.
chdir
(
project_dir
)
os
.
chdir
(
project_dir
)
self
.
write_file
(
'hello'
,
"print('o hai')"
)
self
.
write_file
(
'hello.py'
,
"def main(): print('o hai')"
)
self
.
write_file
(
'sayhi'
,
'from hello import main; main()'
)
cmd
=
install
(
dist
)
cmd
=
install
(
dist
)
dist
.
command_obj
[
'install'
]
=
cmd
dist
.
command_obj
[
'install'
]
=
cmd
cmd
.
root
=
install_dir
cmd
.
root
=
install_dir
cmd
.
record
=
os
.
path
.
join
(
project_dir
,
'
RECORD
'
)
cmd
.
record
=
os
.
path
.
join
(
project_dir
,
'
filelist
'
)
cmd
.
ensure_finalized
()
cmd
.
ensure_finalized
()
cmd
.
run
()
cmd
.
run
()
...
@@ -196,7 +193,7 @@ class InstallTestCase(support.TempdirManager,
...
@@ -196,7 +193,7 @@ class InstallTestCase(support.TempdirManager,
f
.
close
()
f
.
close
()
found
=
[
os
.
path
.
basename
(
line
)
for
line
in
content
.
splitlines
()]
found
=
[
os
.
path
.
basename
(
line
)
for
line
in
content
.
splitlines
()]
expected
=
[
'hello'
,
expected
=
[
'hello
.py'
,
'hello.
%
s.pyc'
%
imp
.
get_tag
(),
'sayhi
'
,
'UNKNOWN-0.0.0-py
%
s.
%
s.egg-info'
%
sys
.
version_info
[:
2
]]
'UNKNOWN-0.0.0-py
%
s.
%
s.egg-info'
%
sys
.
version_info
[:
2
]]
self
.
assertEqual
(
found
,
expected
)
self
.
assertEqual
(
found
,
expected
)
...
@@ -204,7 +201,6 @@ class InstallTestCase(support.TempdirManager,
...
@@ -204,7 +201,6 @@ class InstallTestCase(support.TempdirManager,
install_dir
=
self
.
mkdtemp
()
install_dir
=
self
.
mkdtemp
()
project_dir
,
dist
=
self
.
create_dist
(
ext_modules
=
[
project_dir
,
dist
=
self
.
create_dist
(
ext_modules
=
[
Extension
(
'xx'
,
[
'xxmodule.c'
])])
Extension
(
'xx'
,
[
'xxmodule.c'
])])
self
.
addCleanup
(
os
.
chdir
,
os
.
getcwd
())
os
.
chdir
(
project_dir
)
os
.
chdir
(
project_dir
)
support
.
copy_xxmodule_c
(
project_dir
)
support
.
copy_xxmodule_c
(
project_dir
)
...
@@ -216,7 +212,7 @@ class InstallTestCase(support.TempdirManager,
...
@@ -216,7 +212,7 @@ class InstallTestCase(support.TempdirManager,
dist
.
command_obj
[
'install'
]
=
cmd
dist
.
command_obj
[
'install'
]
=
cmd
dist
.
command_obj
[
'build_ext'
]
=
buildextcmd
dist
.
command_obj
[
'build_ext'
]
=
buildextcmd
cmd
.
root
=
install_dir
cmd
.
root
=
install_dir
cmd
.
record
=
os
.
path
.
join
(
project_dir
,
'
RECORD
'
)
cmd
.
record
=
os
.
path
.
join
(
project_dir
,
'
filelist
'
)
cmd
.
ensure_finalized
()
cmd
.
ensure_finalized
()
cmd
.
run
()
cmd
.
run
()
...
@@ -242,6 +238,7 @@ class InstallTestCase(support.TempdirManager,
...
@@ -242,6 +238,7 @@ class InstallTestCase(support.TempdirManager,
install_module
.
DEBUG
=
False
install_module
.
DEBUG
=
False
self
.
assertTrue
(
len
(
self
.
logs
)
>
old_logs_len
)
self
.
assertTrue
(
len
(
self
.
logs
)
>
old_logs_len
)
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
InstallTestCase
)
return
unittest
.
makeSuite
(
InstallTestCase
)
...
...
Lib/distutils/tests/test_install_lib.py
Dosyayı görüntüle @
e6405217
...
@@ -10,13 +10,14 @@ from distutils.tests import support
...
@@ -10,13 +10,14 @@ from distutils.tests import support
from
distutils.errors
import
DistutilsOptionError
from
distutils.errors
import
DistutilsOptionError
from
test.support
import
run_unittest
from
test.support
import
run_unittest
class
InstallLibTestCase
(
support
.
TempdirManager
,
class
InstallLibTestCase
(
support
.
TempdirManager
,
support
.
LoggingSilencer
,
support
.
LoggingSilencer
,
support
.
EnvironGuard
,
support
.
EnvironGuard
,
unittest
.
TestCase
):
unittest
.
TestCase
):
def
test_finalize_options
(
self
):
def
test_finalize_options
(
self
):
pkg_dir
,
dist
=
self
.
create_dist
()
dist
=
self
.
create_dist
()[
1
]
cmd
=
install_lib
(
dist
)
cmd
=
install_lib
(
dist
)
cmd
.
finalize_options
()
cmd
.
finalize_options
()
...
@@ -35,56 +36,62 @@ class InstallLibTestCase(support.TempdirManager,
...
@@ -35,56 +36,62 @@ class InstallLibTestCase(support.TempdirManager,
@unittest.skipIf
(
sys
.
dont_write_bytecode
,
'byte-compile disabled'
)
@unittest.skipIf
(
sys
.
dont_write_bytecode
,
'byte-compile disabled'
)
def
test_byte_compile
(
self
):
def
test_byte_compile
(
self
):
p
kg
_dir
,
dist
=
self
.
create_dist
()
p
roject
_dir
,
dist
=
self
.
create_dist
()
os
.
chdir
(
p
kg
_dir
)
os
.
chdir
(
p
roject
_dir
)
cmd
=
install_lib
(
dist
)
cmd
=
install_lib
(
dist
)
cmd
.
compile
=
cmd
.
optimize
=
1
cmd
.
compile
=
cmd
.
optimize
=
1
f
=
os
.
path
.
join
(
p
kg
_dir
,
'foo.py'
)
f
=
os
.
path
.
join
(
p
roject
_dir
,
'foo.py'
)
self
.
write_file
(
f
,
'# python file'
)
self
.
write_file
(
f
,
'# python file'
)
cmd
.
byte_compile
([
f
])
cmd
.
byte_compile
([
f
])
pyc_file
=
imp
.
cache_from_source
(
'foo.py'
)
pyc_file
=
imp
.
cache_from_source
(
'foo.py'
,
debug_override
=
True
)
pyo_file
=
imp
.
cache_from_source
(
'foo.py'
,
debug_override
=
False
)
pyo_file
=
imp
.
cache_from_source
(
'foo.py'
,
debug_override
=
False
)
self
.
assertTrue
(
os
.
path
.
exists
(
pyc_file
))
self
.
assertTrue
(
os
.
path
.
exists
(
pyc_file
))
self
.
assertTrue
(
os
.
path
.
exists
(
pyo_file
))
self
.
assertTrue
(
os
.
path
.
exists
(
pyo_file
))
def
test_get_outputs
(
self
):
def
test_get_outputs
(
self
):
pkg_dir
,
dist
=
self
.
create_dist
()
project_dir
,
dist
=
self
.
create_dist
()
os
.
chdir
(
project_dir
)
os
.
mkdir
(
'spam'
)
cmd
=
install_lib
(
dist
)
cmd
=
install_lib
(
dist
)
# setting up a dist environment
# setting up a dist environment
cmd
.
compile
=
cmd
.
optimize
=
1
cmd
.
compile
=
cmd
.
optimize
=
1
cmd
.
install_dir
=
pkg_dir
cmd
.
install_dir
=
self
.
mkdtemp
()
f
=
os
.
path
.
join
(
pkg_dir
,
'foo.py'
)
f
=
os
.
path
.
join
(
project_dir
,
'spam'
,
'__init__.py'
)
self
.
write_file
(
f
,
'# python file'
)
self
.
write_file
(
f
,
'# python package'
)
cmd
.
distribution
.
py_modules
=
[
pkg_dir
]
cmd
.
distribution
.
ext_modules
=
[
Extension
(
'foo'
,
[
'xxx'
])]
cmd
.
distribution
.
ext_modules
=
[
Extension
(
'foo'
,
[
'xxx'
])]
cmd
.
distribution
.
packages
=
[
pkg_dir
]
cmd
.
distribution
.
packages
=
[
'spam'
]
cmd
.
distribution
.
script_name
=
'setup.py'
cmd
.
distribution
.
script_name
=
'setup.py'
# get_output should return 4 elements
# get_outputs should return 4 elements: spam/__init__.py, .pyc and
self
.
assertTrue
(
len
(
cmd
.
get_outputs
())
>=
2
)
# .pyo, foo.import-tag-abiflags.so / foo.pyd
outputs
=
cmd
.
get_outputs
()
self
.
assertEqual
(
len
(
outputs
),
4
,
outputs
)
def
test_get_inputs
(
self
):
def
test_get_inputs
(
self
):
pkg_dir
,
dist
=
self
.
create_dist
()
project_dir
,
dist
=
self
.
create_dist
()
os
.
chdir
(
project_dir
)
os
.
mkdir
(
'spam'
)
cmd
=
install_lib
(
dist
)
cmd
=
install_lib
(
dist
)
# setting up a dist environment
# setting up a dist environment
cmd
.
compile
=
cmd
.
optimize
=
1
cmd
.
compile
=
cmd
.
optimize
=
1
cmd
.
install_dir
=
pkg_dir
cmd
.
install_dir
=
self
.
mkdtemp
()
f
=
os
.
path
.
join
(
pkg_dir
,
'foo.py'
)
f
=
os
.
path
.
join
(
project_dir
,
'spam'
,
'__init__.py'
)
self
.
write_file
(
f
,
'# python file'
)
self
.
write_file
(
f
,
'# python package'
)
cmd
.
distribution
.
py_modules
=
[
pkg_dir
]
cmd
.
distribution
.
ext_modules
=
[
Extension
(
'foo'
,
[
'xxx'
])]
cmd
.
distribution
.
ext_modules
=
[
Extension
(
'foo'
,
[
'xxx'
])]
cmd
.
distribution
.
packages
=
[
pkg_dir
]
cmd
.
distribution
.
packages
=
[
'spam'
]
cmd
.
distribution
.
script_name
=
'setup.py'
cmd
.
distribution
.
script_name
=
'setup.py'
# get_input should return 2 elements
# get_inputs should return 2 elements: spam/__init__.py and
self
.
assertEqual
(
len
(
cmd
.
get_inputs
()),
2
)
# foo.import-tag-abiflags.so / foo.pyd
inputs
=
cmd
.
get_inputs
()
self
.
assertEqual
(
len
(
inputs
),
2
,
inputs
)
def
test_dont_write_bytecode
(
self
):
def
test_dont_write_bytecode
(
self
):
# makes sure byte_compile is not used
# makes sure byte_compile is not used
pkg_dir
,
dist
=
self
.
create_dist
()
dist
=
self
.
create_dist
()[
1
]
cmd
=
install_lib
(
dist
)
cmd
=
install_lib
(
dist
)
cmd
.
compile
=
1
cmd
.
compile
=
1
cmd
.
optimize
=
1
cmd
.
optimize
=
1
...
@@ -98,6 +105,7 @@ class InstallLibTestCase(support.TempdirManager,
...
@@ -98,6 +105,7 @@ class InstallLibTestCase(support.TempdirManager,
self
.
assertTrue
(
'byte-compiling is disabled'
in
self
.
logs
[
0
][
1
])
self
.
assertTrue
(
'byte-compiling is disabled'
in
self
.
logs
[
0
][
1
])
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
InstallLibTestCase
)
return
unittest
.
makeSuite
(
InstallLibTestCase
)
...
...
Lib/distutils/tests/test_sdist.py
Dosyayı görüntüle @
e6405217
...
@@ -288,7 +288,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
...
@@ -288,7 +288,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
# the following tests make sure there is a nice error message instead
# the following tests make sure there is a nice error message instead
# of a traceback when parsing an invalid manifest template
# of a traceback when parsing an invalid manifest template
def
_
test
_template
(
self
,
content
):
def
_
check
_template
(
self
,
content
):
dist
,
cmd
=
self
.
get_cmd
()
dist
,
cmd
=
self
.
get_cmd
()
os
.
chdir
(
self
.
tmp_dir
)
os
.
chdir
(
self
.
tmp_dir
)
self
.
write_file
(
'MANIFEST.in'
,
content
)
self
.
write_file
(
'MANIFEST.in'
,
content
)
...
@@ -299,17 +299,17 @@ class SDistTestCase(PyPIRCCommandTestCase):
...
@@ -299,17 +299,17 @@ class SDistTestCase(PyPIRCCommandTestCase):
self
.
assertEqual
(
len
(
warnings
),
1
)
self
.
assertEqual
(
len
(
warnings
),
1
)
def
test_invalid_template_unknown_command
(
self
):
def
test_invalid_template_unknown_command
(
self
):
self
.
_
test
_template
(
'taunt knights *'
)
self
.
_
check
_template
(
'taunt knights *'
)
def
test_invalid_template_wrong_arguments
(
self
):
def
test_invalid_template_wrong_arguments
(
self
):
# this manifest command takes one argument
# this manifest command takes one argument
self
.
_
test
_template
(
'prune'
)
self
.
_
check
_template
(
'prune'
)
@unittest.skipIf
(
os
.
name
!=
'nt'
,
'test relevant for Windows only'
)
@unittest.skipIf
(
os
.
name
!=
'nt'
,
'test relevant for Windows only'
)
def
test_invalid_template_wrong_path
(
self
):
def
test_invalid_template_wrong_path
(
self
):
# on Windows, trailing slashes are not allowed
# on Windows, trailing slashes are not allowed
# this used to crash instead of raising a warning: #8286
# this used to crash instead of raising a warning: #8286
self
.
_
test
_template
(
'include examples/'
)
self
.
_
check
_template
(
'include examples/'
)
@unittest.skipUnless
(
ZLIB_SUPPORT
,
'Need zlib support to run'
)
@unittest.skipUnless
(
ZLIB_SUPPORT
,
'Need zlib support to run'
)
def
test_get_file_list
(
self
):
def
test_get_file_list
(
self
):
...
...
Python/import.c
Dosyayı görüntüle @
e6405217
...
@@ -3908,7 +3908,8 @@ imp_cache_from_source(PyObject *self, PyObject *args, PyObject *kws)
...
@@ -3908,7 +3908,8 @@ imp_cache_from_source(PyObject *self, PyObject *args, PyObject *kws)
}
}
PyDoc_STRVAR
(
doc_cache_from_source
,
PyDoc_STRVAR
(
doc_cache_from_source
,
"Given the path to a .py file, return the path to its .pyc/.pyo file.
\n
\
"cache_from_source(path, [debug_override]) -> path
\n
\
Given the path to a .py file, return the path to its .pyc/.pyo file.
\n
\
\n
\
\n
\
The .py file does not need to exist; this simply returns the path to the
\n
\
The .py file does not need to exist; this simply returns the path to the
\n
\
.pyc/.pyo file calculated as if the .py file were imported. The extension
\n
\
.pyc/.pyo file calculated as if the .py file were imported. The extension
\n
\
...
@@ -3940,7 +3941,8 @@ imp_source_from_cache(PyObject *self, PyObject *args, PyObject *kws)
...
@@ -3940,7 +3941,8 @@ imp_source_from_cache(PyObject *self, PyObject *args, PyObject *kws)
}
}
PyDoc_STRVAR
(
doc_source_from_cache
,
PyDoc_STRVAR
(
doc_source_from_cache
,
"Given the path to a .pyc./.pyo file, return the path to its .py file.
\n
\
"source_from_cache(path) -> path
\n
\
Given the path to a .pyc./.pyo file, return the path to its .py file.
\n
\
\n
\
\n
\
The .pyc/.pyo file does not need to exist; this simply returns the path to
\n
\
The .pyc/.pyo file does not need to exist; this simply returns the path to
\n
\
the .py file calculated to correspond to the .pyc/.pyo file. If path
\n
\
the .py file calculated to correspond to the .pyc/.pyo file. If path
\n
\
...
...
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