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
b339b2aa
Kaydet (Commit)
b339b2aa
authored
Eyl 03, 2008
tarafından
Marc-André Lemburg
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
non-ascii characters and Unicode in setup.py meta-data.
üst
6a2fd813
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
14 deletions
+64
-14
dist.py
Lib/distutils/dist.py
+25
-13
test_dist.py
Lib/distutils/tests/test_dist.py
+35
-0
NEWS
Misc/NEWS
+4
-1
No files found.
Lib/distutils/dist.py
Dosyayı görüntüle @
b339b2aa
...
@@ -23,6 +23,9 @@ from distutils.util import check_environ, strtobool, rfc822_escape
...
@@ -23,6 +23,9 @@ from distutils.util import check_environ, strtobool, rfc822_escape
from
distutils
import
log
from
distutils
import
log
from
distutils.debug
import
DEBUG
from
distutils.debug
import
DEBUG
# Encoding used for the PKG-INFO files
PKG_INFO_ENCODING
=
'utf-8'
# Regex to define acceptable Distutils command names. This is not *quite*
# Regex to define acceptable Distutils command names. This is not *quite*
# 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
...
@@ -1084,23 +1087,23 @@ class DistributionMetadata:
...
@@ -1084,23 +1087,23 @@ class DistributionMetadata:
if
self
.
provides
or
self
.
requires
or
self
.
obsoletes
:
if
self
.
provides
or
self
.
requires
or
self
.
obsoletes
:
version
=
'1.1'
version
=
'1.1'
file
.
write
(
'Metadata-Version:
%
s
\n
'
%
version
)
self
.
_write_field
(
file
,
'Metadata-Version'
,
version
)
file
.
write
(
'Name:
%
s
\n
'
%
self
.
get_name
()
)
self
.
_write_field
(
file
,
'Name'
,
self
.
get_name
()
)
file
.
write
(
'Version:
%
s
\n
'
%
self
.
get_version
()
)
self
.
_write_field
(
file
,
'Version'
,
self
.
get_version
()
)
file
.
write
(
'Summary:
%
s
\n
'
%
self
.
get_description
()
)
self
.
_write_field
(
file
,
'Summary'
,
self
.
get_description
()
)
file
.
write
(
'Home-page:
%
s
\n
'
%
self
.
get_url
()
)
self
.
_write_field
(
file
,
'Home-page'
,
self
.
get_url
()
)
file
.
write
(
'Author:
%
s
\n
'
%
self
.
get_contact
()
)
self
.
_write_field
(
file
,
'Author'
,
self
.
get_contact
()
)
file
.
write
(
'Author-email:
%
s
\n
'
%
self
.
get_contact_email
()
)
self
.
_write_field
(
file
,
'Author-email'
,
self
.
get_contact_email
()
)
file
.
write
(
'License:
%
s
\n
'
%
self
.
get_license
()
)
self
.
_write_field
(
file
,
'License'
,
self
.
get_license
()
)
if
self
.
download_url
:
if
self
.
download_url
:
file
.
write
(
'Download-URL:
%
s
\n
'
%
self
.
download_url
)
self
.
_write_field
(
file
,
'Download-URL'
,
self
.
download_url
)
long_desc
=
rfc822_escape
(
self
.
get_long_description
()
)
long_desc
=
rfc822_escape
(
self
.
get_long_description
())
file
.
write
(
'Description:
%
s
\n
'
%
long_desc
)
self
.
_write_field
(
file
,
'Description'
,
long_desc
)
keywords
=
string
.
join
(
self
.
get_keywords
(),
','
)
keywords
=
string
.
join
(
self
.
get_keywords
(),
','
)
if
keywords
:
if
keywords
:
file
.
write
(
'Keywords:
%
s
\n
'
%
keywords
)
self
.
_write_field
(
file
,
'Keywords'
,
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
())
...
@@ -1110,9 +1113,18 @@ class DistributionMetadata:
...
@@ -1110,9 +1113,18 @@ class DistributionMetadata:
self
.
_write_list
(
file
,
'Provides'
,
self
.
get_provides
())
self
.
_write_list
(
file
,
'Provides'
,
self
.
get_provides
())
self
.
_write_list
(
file
,
'Obsoletes'
,
self
.
get_obsoletes
())
self
.
_write_list
(
file
,
'Obsoletes'
,
self
.
get_obsoletes
())
def
_write_field
(
self
,
file
,
name
,
value
):
if
isinstance
(
value
,
unicode
):
value
=
value
.
encode
(
PKG_INFO_ENCODING
)
else
:
value
=
str
(
value
)
file
.
write
(
'
%
s:
%
s
\n
'
%
(
name
,
value
))
def
_write_list
(
self
,
file
,
name
,
values
):
def
_write_list
(
self
,
file
,
name
,
values
):
for
value
in
values
:
for
value
in
values
:
file
.
write
(
'
%
s:
%
s
\n
'
%
(
name
,
value
)
)
self
.
_write_field
(
file
,
name
,
value
)
# -- Metadata query methods ----------------------------------------
# -- Metadata query methods ----------------------------------------
...
...
Lib/distutils/tests/test_dist.py
Dosyayı görüntüle @
b339b2aa
# -*- coding: latin-1 -*-
"""Tests for distutils.dist."""
"""Tests for distutils.dist."""
import
distutils.cmd
import
distutils.cmd
...
@@ -95,6 +97,39 @@ class DistributionTestCase(unittest.TestCase):
...
@@ -95,6 +97,39 @@ class DistributionTestCase(unittest.TestCase):
finally
:
finally
:
os
.
unlink
(
TESTFN
)
os
.
unlink
(
TESTFN
)
def
test_write_pkg_file
(
self
):
# Check DistributionMetadata handling of Unicode fields
my_file
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'f'
)
klass
=
distutils
.
dist
.
Distribution
dist
=
klass
(
attrs
=
{
'author'
:
u'Mister Caf'
,
'name'
:
'my.package'
,
'maintainer'
:
u'Caf Junior'
,
'description'
:
u'Caf torrfi'
,
'long_description'
:
u'Hhh'
})
# let's make sure the file can be written
# with Unicode fields. they are encoded with
# PKG_INFO_ENCODING
try
:
dist
.
metadata
.
write_pkg_file
(
open
(
my_file
,
'w'
))
finally
:
if
os
.
path
.
exists
(
my_file
):
os
.
remove
(
my_file
)
# regular ascii is of course always usable
dist
=
klass
(
attrs
=
{
'author'
:
'Mister Cafe'
,
'name'
:
'my.package'
,
'maintainer'
:
'Cafe Junior'
,
'description'
:
'Cafe torrefie'
,
'long_description'
:
'Hehehe'
})
try
:
dist
.
metadata
.
write_pkg_file
(
open
(
my_file
,
'w'
))
finally
:
if
os
.
path
.
exists
(
my_file
):
os
.
remove
(
my_file
)
class
MetadataTestCase
(
unittest
.
TestCase
):
class
MetadataTestCase
(
unittest
.
TestCase
):
...
...
Misc/NEWS
Dosyayı görüntüle @
b339b2aa
...
@@ -56,7 +56,10 @@ C-API
...
@@ -56,7 +56,10 @@ C-API
Library
Library
-------
-------
- Issue #3726: Allowed spaces in separators in logging configuration files.
- Issue #2562: Fix distutils PKG-INFO writing logic to allow having
non-ascii characters and Unicode in setup.py meta-data.
- Issue #3726: Allow spaces in separators in logging configuration files.
- Issue #3719: platform.architecture() fails if there are spaces in the
- Issue #3719: platform.architecture() fails if there are spaces in the
path to the Python binary.
path to the Python binary.
...
...
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