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
af321fc6
Commit
af321fc6
authored
Dec 05, 2016
by
idle sign
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
`file:` directive sandboxed.
parent
a5dadcf0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletion
+23
-1
setuptools/config.py
setuptools/config.py
+11
-1
setuptools/tests/test_config.py
setuptools/tests/test_config.py
+12
-0
No files found.
setuptools/config.py
View file @
af321fc6
...
@@ -128,7 +128,10 @@ class ConfigHandler(object):
...
@@ -128,7 +128,10 @@ class ConfigHandler(object):
@
classmethod
@
classmethod
def
_parse_file
(
cls
,
value
):
def
_parse_file
(
cls
,
value
):
"""Represents value as a string, allowing including text
"""Represents value as a string, allowing including text
from nearest files using include().
from nearest files using `file:` directive.
Directive is sandboxed and won't reach anything outside
directory with setup.py.
Examples:
Examples:
include: LICENSE
include: LICENSE
...
@@ -144,7 +147,14 @@ class ConfigHandler(object):
...
@@ -144,7 +147,14 @@ class ConfigHandler(object):
if
not
value
.
startswith
(
include_directive
):
if
not
value
.
startswith
(
include_directive
):
return
value
return
value
current_directory
=
os
.
getcwd
()
filepath
=
value
.
replace
(
include_directive
,
''
).
strip
()
filepath
=
value
.
replace
(
include_directive
,
''
).
strip
()
filepath
=
os
.
path
.
abspath
(
filepath
)
if
not
filepath
.
startswith
(
current_directory
):
raise
DistutilsOptionError
(
'`file:` directive can not access %s'
%
filepath
)
if
os
.
path
.
isfile
(
filepath
):
if
os
.
path
.
isfile
(
filepath
):
with
io
.
open
(
filepath
,
encoding
=
'utf-8'
)
as
f
:
with
io
.
open
(
filepath
,
encoding
=
'utf-8'
)
as
f
:
...
...
setuptools/tests/test_config.py
View file @
af321fc6
...
@@ -86,6 +86,18 @@ class TestMetadata:
...
@@ -86,6 +86,18 @@ class TestMetadata:
assert
metadata
.
name
==
'fake_name'
assert
metadata
.
name
==
'fake_name'
assert
metadata
.
keywords
==
[
'one'
,
'two'
]
assert
metadata
.
keywords
==
[
'one'
,
'two'
]
def
test_file_sandboxed
(
self
,
tmpdir
):
fake_env
(
tmpdir
,
'[metadata]
\
n
'
'long_description = file: ../../README
\
n
'
)
with
get_dist
(
tmpdir
,
parse
=
False
)
as
dist
:
with
pytest
.
raises
(
DistutilsOptionError
):
dist
.
parse_config_files
()
# file: out of sandbox
def
test_aliases
(
self
,
tmpdir
):
def
test_aliases
(
self
,
tmpdir
):
fake_env
(
fake_env
(
...
...
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