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
3e425ac6
Kaydet (Commit)
3e425ac6
authored
Haz 19, 2011
tarafından
Éric Araujo
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
packaging: Add the project directory to sys.path to support local setup hooks.
Original patch by Vinay Sajip on #11637.
üst
e043b6ba
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
11 deletions
+39
-11
config.py
Lib/packaging/config.py
+14
-9
test_config.py
Lib/packaging/tests/test_config.py
+21
-1
NEWS
Misc/NEWS
+4
-1
No files found.
Lib/packaging/config.py
Dosyayı görüntüle @
3e425ac6
...
...
@@ -134,15 +134,20 @@ class Config:
if
'setup_hooks'
in
content
[
'global'
]:
setup_hooks
=
split_multiline
(
content
[
'global'
][
'setup_hooks'
])
for
line
in
setup_hooks
:
try
:
hook
=
resolve_name
(
line
)
except
ImportError
as
e
:
logger
.
warning
(
'cannot find setup hook:
%
s'
,
e
.
args
[
0
])
else
:
self
.
setup_hooks
.
append
(
hook
)
self
.
run_hooks
(
content
)
# add project directory to sys.path, to allow hooks to be
# distributed with the project
sys
.
path
.
insert
(
0
,
cfg_directory
)
try
:
for
line
in
setup_hooks
:
try
:
hook
=
resolve_name
(
line
)
except
ImportError
as
e
:
logger
.
warning
(
'cannot find setup hook:
%
s'
,
e
.
args
[
0
])
else
:
self
.
setup_hooks
.
append
(
hook
)
self
.
run_hooks
(
content
)
finally
:
sys
.
path
.
pop
(
0
)
metadata
=
self
.
dist
.
metadata
...
...
Lib/packaging/tests/test_config.py
Dosyayı görüntüle @
3e425ac6
...
...
@@ -126,6 +126,15 @@ language = cxx
"""
HOOKS_MODULE
=
"""
import logging
logger = logging.getLogger('packaging')
def logging_hook(config):
logger.warning('logging_hook called')
"""
class
DCompiler
:
name
=
'd'
...
...
@@ -326,10 +335,21 @@ class ConfigTestCase(support.TempdirManager,
self
.
assertEqual
(
ext
.
extra_compile_args
,
cargs
)
self
.
assertEqual
(
ext
.
language
,
'cxx'
)
def
test_project_setup_hook_works
(
self
):
# Bug #11637: ensure the project directory is on sys.path to allow
# project-specific hooks
self
.
write_setup
({
'setup-hooks'
:
'hooks.logging_hook'
})
self
.
write_file
(
'README'
,
'yeah'
)
self
.
write_file
(
'hooks.py'
,
HOOKS_MODULE
)
self
.
get_dist
()
logs
=
self
.
get_logs
(
logging
.
WARNING
)
self
.
assertEqual
([
'logging_hook called'
],
logs
)
self
.
assertIn
(
'hooks'
,
sys
.
modules
)
def
test_missing_setup_hook_warns
(
self
):
self
.
write_setup
({
'setup-hooks'
:
'this.does._not.exist'
})
self
.
write_file
(
'README'
,
'yeah'
)
dist
=
self
.
get_dist
()
self
.
get_dist
()
logs
=
self
.
get_logs
(
logging
.
WARNING
)
self
.
assertEqual
(
1
,
len
(
logs
))
self
.
assertIn
(
'cannot find setup hook'
,
logs
[
0
])
...
...
Misc/NEWS
Dosyayı görüntüle @
3e425ac6
...
...
@@ -193,7 +193,10 @@ Core and Builtins
Library
-------
- Issue #6771: moved the curses.wrapper function from the single-function
- Issue #11637: Fix support for importing packaging setup hooks from the
project directory.
- Issue #6771: Moved the curses.wrapper function from the single-function
wrapper module into __init__, eliminating the module. Since __init__ was
already importing the function to curses.wrapper, there is no API change.
...
...
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