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
a262947e
Commit
a262947e
authored
Dec 10, 2016
by
idle sign
Committed by
Jason R. Coombs
Dec 10, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented find() configuration support for `packages`.
parent
b73891f8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
86 additions
and
5 deletions
+86
-5
docs/setuptools.txt
docs/setuptools.txt
+17
-3
setuptools/config.py
setuptools/config.py
+31
-2
setuptools/tests/test_config.py
setuptools/tests/test_config.py
+38
-0
No files found.
docs/setuptools.txt
View file @
a262947e
...
...
@@ -2448,6 +2448,11 @@ boilerplate code in some cases.
pdf = ReportLab>=1.2; RXP
rest = docutils>=0.3; pack ==1.1, ==1.3
[options.packages.find]
exclude =
src.subpackage1
src.subpackage2
Metadata and options could be set in sections with the same names.
...
...
@@ -2486,13 +2491,13 @@ Type names used below:
* ``list-semi`` - dangling list or semicolon-separated values string
* ``bool`` - ``True`` is 1, yes, true
* ``dict`` - list-comma where keys from values are separated by =
* ``section`` - values could be read from a dedicated (sub)section
Special directives:
* ``attr:`` - value could be read from module attribute
* ``file:`` - value could be read from a file
* ``section:`` - values could be read from a dedicated (sub)section
.. note::
...
...
@@ -2529,8 +2534,10 @@ requires list-comma
obsoletes list-comma
================= ================= =====
**version** - ``attr:`` supports callables; supports iterables;
unsupported types are casted using ``str()``.
.. note::
**version** - ``attr:`` supports callables; supports iterables;
unsupported types are casted using ``str()``.
Options
...
...
@@ -2560,6 +2567,13 @@ exclude_package_data section
namespace_packages list-comma
======================= =====
.. note::
**packages** - ``find:`` directive can be further configured
in a dedicated subsection `options.packages.find`. This subsection
accepts the same keys as `setuptools.find` function:
`where`, `include`, `exclude`.
Configuration API
=================
...
...
setuptools/config.py
View file @
a262947e
...
...
@@ -361,7 +361,10 @@ class ConfigHandler(object):
method_postfix
=
'_%s'
%
section_name
section_parser_method
=
getattr
(
self
,
'parse_section%s'
%
method_postfix
,
None
)
self
,
# Dots in section names are tranlsated into dunderscores.
(
'parse_section%s'
%
method_postfix
).
replace
(
'.'
,
'__'
),
None
)
if
section_parser_method
is
None
:
raise
DistutilsOptionError
(
...
...
@@ -481,8 +484,34 @@ class ConfigOptionsHandler(ConfigHandler):
if
not
value
.
startswith
(
find_directive
):
return
self
.
_parse_list
(
value
)
# Read function arguments from a dedicated section.
find_kwargs
=
self
.
parse_section_packages__find
(
self
.
sections
.
get
(
'packages.find'
,
{}))
from
setuptools
import
find_packages
return
find_packages
()
return
find_packages
(
**
find_kwargs
)
def
parse_section_packages__find
(
self
,
section_options
):
"""Parses `packages.find` configuration file section.
To be used in conjunction with _parse_packages().
:param dict section_options:
"""
section_data
=
self
.
_parse_section_to_dict
(
section_options
,
self
.
_parse_list
)
valid_keys
=
[
'where'
,
'include'
,
'exclude'
]
find_kwargs
=
dict
(
[(
k
,
v
)
for
k
,
v
in
section_data
.
items
()
if
k
in
valid_keys
and
v
])
where
=
find_kwargs
.
get
(
'where'
)
if
where
is
not
None
:
find_kwargs
[
'where'
]
=
where
[
0
]
# cast list to single val
return
find_kwargs
def
parse_section_entry_points
(
self
,
section_options
):
"""Parses `entry_points` configuration file section.
...
...
setuptools/tests/test_config.py
View file @
a262947e
...
...
@@ -446,6 +446,44 @@ class TestOptions:
with
get_dist
(
tmpdir
)
as
dist
:
assert
dist
.
packages
==
[
'fake_package'
]
def
test_find_directive
(
self
,
tmpdir
):
dir_package
,
config
=
fake_env
(
tmpdir
,
'[options]
\
n
'
'packages = find:
\
n
'
)
dir_sub_one
,
_
=
make_package_dir
(
'sub_one'
,
dir_package
)
dir_sub_two
,
_
=
make_package_dir
(
'sub_two'
,
dir_package
)
with
get_dist
(
tmpdir
)
as
dist
:
assert
dist
.
packages
==
[
'fake_package'
,
'fake_package.sub_two'
,
'fake_package.sub_one'
]
config
.
write
(
'[options]
\
n
'
'packages = find:
\
n
'
'
\
n
'
'[options.packages.find]
\
n
'
'where = .
\
n
'
'include =
\
n
'
' fake_package.sub_one
\
n
'
' two
\
n
'
)
with
get_dist
(
tmpdir
)
as
dist
:
assert
dist
.
packages
==
[
'fake_package.sub_one'
]
config
.
write
(
'[options]
\
n
'
'packages = find:
\
n
'
'
\
n
'
'[options.packages.find]
\
n
'
'exclude =
\
n
'
' fake_package.sub_one
\
n
'
)
with
get_dist
(
tmpdir
)
as
dist
:
assert
dist
.
packages
==
[
'fake_package'
,
'fake_package.sub_two'
]
def
test_extras_require
(
self
,
tmpdir
):
fake_env
(
tmpdir
,
...
...
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