Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
d10a1bb4
Commit
d10a1bb4
authored
Jan 04, 2018
by
Jason R. Coombs
Committed by
GitHub
Jan 04, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1210 from fungi/master
Support PEP 345 Project-URL metadata
parents
85747b8c
82c7b798
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
70 additions
and
1 deletion
+70
-1
docs/setuptools.txt
docs/setuptools.txt
+11
-0
setup.py
setup.py
+3
-0
setuptools/config.py
setuptools/config.py
+2
-0
setuptools/dist.py
setuptools/dist.py
+8
-1
setuptools/tests/test_config.py
setuptools/tests/test_config.py
+16
-0
setuptools/tests/test_egg_info.py
setuptools/tests/test_egg_info.py
+30
-0
No files found.
docs/setuptools.txt
View file @
d10a1bb4
...
...
@@ -145,6 +145,11 @@ dependencies, and perhaps some data files and scripts::
license="PSF",
keywords="hello world example examples",
url="http://example.com/HelloWorld/", # project home page, if any
project_urls={
"Bug Tracker": "https://bugs.example.com/HelloWorld/",
"Documentation": "https://docs.example.com/HelloWorld/",
"Source Code": "https://code.example.com/HelloWorld/",
}
# could also include long_description, download_url, classifiers, etc.
)
...
...
@@ -408,6 +413,11 @@ unless you need the associated ``setuptools`` feature.
A list of modules to search for additional fixers to be used during
the 2to3 conversion. See :doc:`python3` for more details.
``project_urls``
An arbitrary map of URL names to hyperlinks, allowing more extensible
documentation of where various resources can be found than the simple
``url`` and ``download_url`` options provide.
Using ``find_packages()``
-------------------------
...
...
@@ -2406,6 +2416,7 @@ name str
version attr:, str
url home-page str
download_url download-url str
project_urls dict
author str
author_email author-email str
maintainer str
...
...
setup.py
View file @
d10a1bb4
...
...
@@ -98,6 +98,9 @@ setup_params = dict(
long_description_content_type
=
'text/x-rst; charset=UTF-8'
,
keywords
=
"CPAN PyPI distutils eggs package management"
,
url
=
"https://github.com/pypa/setuptools"
,
project_urls
=
{
"Documentation"
:
"https://setuptools.readthedocs.io/"
,
},
src_root
=
None
,
packages
=
setuptools
.
find_packages
(
exclude
=
[
'*.tests'
]),
package_data
=
package_data
,
...
...
setuptools/config.py
View file @
d10a1bb4
...
...
@@ -404,6 +404,7 @@ class ConfigMetadataHandler(ConfigHandler):
"""Metadata item name to parser function mapping."""
parse_list
=
self
.
_parse_list
parse_file
=
self
.
_parse_file
parse_dict
=
self
.
_parse_dict
return
{
'platforms'
:
parse_list
,
...
...
@@ -416,6 +417,7 @@ class ConfigMetadataHandler(ConfigHandler):
'description'
:
parse_file
,
'long_description'
:
parse_file
,
'version'
:
self
.
_parse_version
,
'project_urls'
:
parse_dict
,
}
def
_parse_version
(
self
,
value
):
...
...
setuptools/dist.py
View file @
d10a1bb4
...
...
@@ -44,7 +44,7 @@ def write_pkg_file(self, file):
self
.
classifiers
or
self
.
download_url
):
version
=
'1.1'
# Setuptools specific for PEP 345
if
hasattr
(
self
,
'python_requires'
):
if
hasattr
(
self
,
'python_requires'
)
or
self
.
project_urls
:
version
=
'1.2'
file
.
write
(
'Metadata-Version: %s
\
n
'
%
version
)
...
...
@@ -57,6 +57,8 @@ def write_pkg_file(self, file):
file
.
write
(
'License: %s
\
n
'
%
self
.
get_license
())
if
self
.
download_url
:
file
.
write
(
'Download-URL: %s
\
n
'
%
self
.
download_url
)
for
project_url
in
self
.
project_urls
.
items
():
file
.
write
(
'Project-URL: %s, %s
\
n
'
%
project_url
)
long_desc_content_type
=
\
self
.
long_description_content_type
or
'UNKNOWN'
...
...
@@ -323,12 +325,17 @@ class Distribution(Distribution_parse_config_files, _Distribution):
self.dist_files = []
self.src_root = attrs.pop("src_root", None)
self.patch_missing_pkg_info(attrs)
self.project_urls = attrs.get('
project_urls
', {})
self.dependency_links = attrs.pop('
dependency_links
', [])
self.setup_requires = attrs.pop('
setup_requires
', [])
for ep in pkg_resources.iter_entry_points('
distutils
.
setup_keywords
'):
vars(self).setdefault(ep.name, None)
_Distribution.__init__(self, attrs)
# The project_urls attribute may not be supported in distutils, so
# prime it here from our value if not automatically set
self.metadata.project_urls = getattr(
self.metadata, '
project_urls
', self.project_urls)
self.metadata.long_description_content_type = attrs.get(
'
long_description_content_type
'
)
...
...
setuptools/tests/test_config.py
View file @
d10a1bb4
...
...
@@ -217,6 +217,22 @@ class TestMetadata:
'Programming Language :: Python :: 3.5'
,
]
def
test_dict
(
self
,
tmpdir
):
fake_env
(
tmpdir
,
'[metadata]
\
n
'
'project_urls =
\
n
'
' Link One = https://example.com/one/
\
n
'
' Link Two = https://example.com/two/
\
n
'
)
with
get_dist
(
tmpdir
)
as
dist
:
metadata
=
dist
.
metadata
assert
metadata
.
project_urls
==
{
'Link One'
:
'https://example.com/one/'
,
'Link Two'
:
'https://example.com/two/'
,
}
def
test_version
(
self
,
tmpdir
):
_
,
config
=
fake_env
(
...
...
setuptools/tests/test_egg_info.py
View file @
d10a1bb4
...
...
@@ -445,6 +445,36 @@ class TestEggInfo(object):
expected_line
=
'Description-Content-Type: text/markdown'
assert
expected_line
in
pkg_info_lines
def
test_project_urls
(
self
,
tmpdir_cwd
,
env
):
# Test that specifying a `project_urls` dict to the `setup`
# function results in writing multiple `Project-URL` lines to
# the `PKG-INFO` file in the `<distribution>.egg-info`
# directory.
# `Project-URL` is described at https://packaging.python.org
# /specifications/core-metadata/#project-url-multiple-use
self
.
_setup_script_with_requires
(
"""project_urls={
'Link One': 'https://example.com/one/',
'Link Two': 'https://example.com/two/',
},"""
)
environ
=
os
.
environ
.
copy
().
update
(
HOME
=
env
.
paths
[
'home'
],
)
code
,
data
=
environment
.
run_setup_py
(
cmd
=
[
'egg_info'
],
pypath
=
os
.
pathsep
.
join
([
env
.
paths
[
'lib'
],
str
(
tmpdir_cwd
)]),
data_stream
=
1
,
env
=
environ
,
)
egg_info_dir
=
os
.
path
.
join
(
'.'
,
'foo.egg-info'
)
with
open
(
os
.
path
.
join
(
egg_info_dir
,
'PKG-INFO'
))
as
pkginfo_file
:
pkg_info_lines
=
pkginfo_file
.
read
().
split
(
'
\
n
'
)
expected_line
=
'Project-URL: Link One, https://example.com/one/'
assert
expected_line
in
pkg_info_lines
expected_line
=
'Project-URL: Link Two, https://example.com/two/'
assert
expected_line
in
pkg_info_lines
def
test_python_requires_egg_info
(
self
,
tmpdir_cwd
,
env
):
self
.
_setup_script_with_requires
(
"""python_requires='>=2.7.12',"""
)
...
...
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