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
b2f50d5d
Commit
b2f50d5d
authored
Jul 20, 2016
by
Jason R. Coombs
Committed by
GitHub
Jul 20, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #631 from xavfernandez/xfernandez/python_requires
Add python_requires keywords to setup
parents
18f760aa
020771f5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
0 deletions
+57
-0
docs/setuptools.txt
docs/setuptools.txt
+4
-0
setup.py
setup.py
+1
-0
setuptools/dist.py
setuptools/dist.py
+28
-0
setuptools/tests/test_egg_info.py
setuptools/tests/test_egg_info.py
+24
-0
No files found.
docs/setuptools.txt
View file @
b2f50d5d
...
...
@@ -302,6 +302,10 @@ unless you need the associated ``setuptools`` feature.
installed to support those features. See the section below on `Declaring
Dependencies`_ for details and examples of the format of this argument.
``python_requires``
A string corresponding to a version specifier (as defined in PEP 440) for
the Python version, used to specify the Requires-Python defined in PEP 345.
``setup_requires``
A string or list of strings specifying what other distributions need to
be present in order for the *setup script* to run. ``setuptools`` will
...
...
setup.py
View file @
b2f50d5d
...
...
@@ -100,6 +100,7 @@ setup_params = dict(
"install_requires = setuptools.dist:check_requirements"
,
"tests_require = setuptools.dist:check_requirements"
,
"setup_requires = setuptools.dist:check_requirements"
,
"python_requires = setuptools.dist:check_specifier"
,
"entry_points = setuptools.dist:check_entry_points"
,
"test_suite = setuptools.dist:check_test_suite"
,
"zip_safe = setuptools.dist:assert_bool"
,
...
...
setuptools/dist.py
View file @
b2f50d5d
...
...
@@ -39,6 +39,20 @@ def _get_unpatched(cls):
_Distribution
=
_get_unpatched
(
_Distribution
)
def
_patch_distribution_metadata_write_pkg_file
():
"""Patch write_pkg_file to also write Requires-Python/Requires-External"""
original_write
=
distutils
.
dist
.
DistributionMetadata
.
write_pkg_file
def
write_pkg_file
(
self
,
file
):
"""Write the PKG-INFO format data to a file object.
"""
original_write
(
self
,
file
)
if
hasattr
(
self
,
'python_requires'
):
file
.
write
(
'Requires-Python: %s
\
n
'
%
self
.
python_requires
)
distutils
.
dist
.
DistributionMetadata
.
write_pkg_file
=
write_pkg_file
_patch_distribution_metadata_write_pkg_file
()
def
_patch_distribution_metadata_write_pkg_info
():
"""
Workaround issue #197 - Python 3 prior to 3.2.2 uses an environment-local
...
...
@@ -138,6 +152,18 @@ def check_requirements(dist, attr, value):
raise
DistutilsSetupError
(
tmpl
.
format
(
attr
=
attr
,
error
=
error
))
def
check_specifier
(
dist
,
attr
,
value
):
"""Verify that value is a valid version specifier"""
try
:
packaging
.
specifiers
.
SpecifierSet
(
value
)
except
packaging
.
specifiers
.
InvalidSpecifier
as
error
:
tmpl
=
(
"{attr!r} must be a string or list of strings "
"containing valid version specifiers; {error}"
)
raise
DistutilsSetupError
(
tmpl
.
format
(
attr
=
attr
,
error
=
error
))
def
check_entry_points
(
dist
,
attr
,
value
):
"""Verify that entry_points map is parseable"""
try
:
...
...
@@ -305,6 +331,8 @@ class Distribution(_Distribution):
"setuptools, pip, and PyPI. Please see PEP 440 for more "
"details." % self.metadata.version
)
if getattr(self, '
python_requires
', None):
self.metadata.python_requires = self.python_requires
def parse_command_line(self):
"""Process features after parsing command line options"""
...
...
setuptools/tests/test_egg_info.py
View file @
b2f50d5d
...
...
@@ -210,6 +210,30 @@ class TestEggInfo(object):
self
.
_run_install_command
(
tmpdir_cwd
,
env
)
assert
glob
.
glob
(
os
.
path
.
join
(
env
.
paths
[
'lib'
],
'barbazquux*'
))
==
[]
def
test_python_requires_egg_info
(
self
,
tmpdir_cwd
,
env
):
self
.
_setup_script_with_requires
(
"""python_requires='>=2.7.12',"""
)
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'
)
pkginfo
=
os
.
path
.
join
(
egg_info_dir
,
'PKG-INFO'
)
assert
'Requires-Python: >=2.7.12'
in
open
(
pkginfo
).
read
().
split
(
'
\
n
'
)
def
test_python_requires_install
(
self
,
tmpdir_cwd
,
env
):
self
.
_setup_script_with_requires
(
"""python_requires='>=1.2.3',"""
)
self
.
_run_install_command
(
tmpdir_cwd
,
env
)
egg_info_dir
=
self
.
_find_egg_info_files
(
env
.
paths
[
'lib'
]).
base
pkginfo
=
os
.
path
.
join
(
egg_info_dir
,
'PKG-INFO'
)
assert
'Requires-Python: >=1.2.3'
in
open
(
pkginfo
).
read
().
split
(
'
\
n
'
)
def
_run_install_command
(
self
,
tmpdir_cwd
,
env
,
cmd
=
None
,
output
=
None
):
environ
=
os
.
environ
.
copy
().
update
(
HOME
=
env
.
paths
[
'home'
],
...
...
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