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
4b5a5f7b
Kaydet (Commit)
4b5a5f7b
authored
Eki 19, 2011
tarafından
Éric Araujo
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
More fixes for PEP 3147 compliance in packaging (#11254)
üst
8ccd18ff
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
8 deletions
+51
-8
build_py.py
Lib/packaging/command/build_py.py
+4
-2
install_lib.py
Lib/packaging/command/install_lib.py
+4
-2
test_command_build_py.py
Lib/packaging/tests/test_command_build_py.py
+35
-0
test_command_install_dist.py
Lib/packaging/tests/test_command_install_dist.py
+8
-4
No files found.
Lib/packaging/command/build_py.py
Dosyayı görüntüle @
4b5a5f7b
"""Build pure Python modules (just copy to build directory)."""
import
os
import
imp
import
sys
from
glob
import
glob
...
...
@@ -330,9 +331,10 @@ class build_py(Command, Mixin2to3):
outputs
.
append
(
filename
)
if
include_bytecode
:
if
self
.
compile
:
outputs
.
append
(
filename
+
"c"
)
outputs
.
append
(
imp
.
cache_from_source
(
filename
)
)
if
self
.
optimize
>
0
:
outputs
.
append
(
filename
+
"o"
)
outputs
.
append
(
imp
.
cache_from_source
(
filename
,
debug_override
=
False
))
outputs
+=
[
os
.
path
.
join
(
build_dir
,
filename
)
...
...
Lib/packaging/command/install_lib.py
Dosyayı görüntüle @
4b5a5f7b
"""Install all modules (extensions and pure Python)."""
import
os
import
imp
import
sys
import
logging
...
...
@@ -172,9 +173,10 @@ class install_lib(Command):
if
ext
!=
PYTHON_SOURCE_EXTENSION
:
continue
if
self
.
compile
:
bytecode_files
.
append
(
py_file
+
"c"
)
bytecode_files
.
append
(
imp
.
cache_from_source
(
py_file
)
)
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
...
...
Lib/packaging/tests/test_command_build_py.py
Dosyayı görüntüle @
4b5a5f7b
...
...
@@ -102,6 +102,40 @@ class BuildPyTestCase(support.TempdirManager,
os
.
chdir
(
cwd
)
sys
.
stdout
=
old_stdout
@unittest.skipIf
(
sys
.
dont_write_bytecode
,
'byte-compile disabled'
)
def
test_byte_compile
(
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
=
True
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
(
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
=
True
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.pyc'
%
imp
.
get_tag
(),
'boiledeggs.
%
s.pyo'
%
imp
.
get_tag
()])
def
test_dont_write_bytecode
(
self
):
# makes sure byte_compile is not used
pkg_dir
,
dist
=
self
.
create_dist
()
...
...
@@ -118,6 +152,7 @@ class BuildPyTestCase(support.TempdirManager,
self
.
assertIn
(
'byte-compiling is disabled'
,
self
.
get_logs
()[
0
])
def
test_suite
():
return
unittest
.
makeSuite
(
BuildPyTestCase
)
...
...
Lib/packaging/tests/test_command_install_dist.py
Dosyayı görüntüle @
4b5a5f7b
"""Tests for packaging.command.install."""
import
os
import
imp
import
sys
from
sysconfig
import
(
get_scheme_names
,
get_config_vars
,
_SCHEMES
,
get_config_var
,
get_path
)
...
...
@@ -181,9 +182,11 @@ class InstallTestCase(support.TempdirManager,
def
test_old_record
(
self
):
# test pre-PEP 376 --record option (outside dist-info dir)
install_dir
=
self
.
mkdtemp
()
project_dir
,
dist
=
self
.
create_dist
(
scripts
=
[
'hello'
])
project_dir
,
dist
=
self
.
create_dist
(
py_modules
=
[
'hello'
],
scripts
=
[
'sayhi'
])
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
(
dist
)
dist
.
command_obj
[
'install_dist'
]
=
cmd
...
...
@@ -196,8 +199,9 @@ class InstallTestCase(support.TempdirManager,
content
=
f
.
read
()
found
=
[
os
.
path
.
basename
(
line
)
for
line
in
content
.
splitlines
()]
expected
=
[
'hello'
,
'METADATA'
,
'INSTALLER'
,
'REQUESTED'
,
'RECORD'
]
self
.
assertEqual
(
found
,
expected
)
expected
=
[
'hello.py'
,
'hello.
%
s.pyc'
%
imp
.
get_tag
(),
'sayhi'
,
'METADATA'
,
'INSTALLER'
,
'REQUESTED'
,
'RECORD'
]
self
.
assertEqual
(
sorted
(
found
),
sorted
(
expected
))
# XXX test that fancy_getopt is okay with options named
# record and no-record but unrelated
...
...
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