Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.buildout
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
6
Merge Requests
6
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
slapos.buildout
Commits
f1ecdf62
Commit
f1ecdf62
authored
Sep 17, 2020
by
Holger Brunn
Committed by
Godefroid Chapelle
Mar 02, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Evaluate environment markers for requirement strings
parent
c0241921
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
1 deletion
+43
-1
doc/getting-started.rst
doc/getting-started.rst
+33
-0
news/pep496.feature
news/pep496.feature
+1
-0
src/zc/buildout/easy_install.py
src/zc/buildout/easy_install.py
+9
-1
No files found.
doc/getting-started.rst
View file @
f1ecdf62
...
...
@@ -439,6 +439,39 @@ where you list them, as in:
In
this
example
,
we
've requested a version of bobo less than 5.0.
You can also add `environment markers <https://python.org/dev/peps/pep-0496>`_
to restrict some requirements to i.e. a certain platform or python version:
.. code-block:: ini
[bobo]
recipe = zc.recipe.egg
eggs =
bobo ==2.2.0; python_version < '
3.0
'
bobo ==2.3.0; python_version >= '
3.0
'
.. -> src
>>> prefix = """
... [buildout]
... parts = bobo
... """
>>> with open('
buildout
.
cfg
', '
w
') as f:
... _ = f.write(prefix)
... _ = f.write(src)
>>> import shutil
>>> import sys
>>> v = sys.version_info
>>> shutil.rmtree('
eggs
')
>>> run_buildout('
buildout
show
-
picked
-
versions
=
true
')
>>> yup([n for n in ls('
eggs
') if n.startswith('
bobo
-
2.3.0
-
')])\
... if v.major >= 3 else\
... yup([n for n in ls('
eggs
') if n.startswith('
bobo
-
2.2.0
-
')])
>>> yup('
bobo
==
2.3.0
' in read('
out
'))\
... if v.major >= 3 else\
... yup('
bobo
==
2.2.0
' in read('
out
'))
The more common way to pin a version is using a ``versions`` section:
.. code-block:: ini
...
...
news/pep496.feature
0 → 100644
View file @
f1ecdf62
add
support
for
PEP496
environment
markers
src/zc/buildout/easy_install.py
View file @
f1ecdf62
...
...
@@ -678,9 +678,15 @@ class Installer(object):
for_buildout_run
=
bool
(
working_set
)
requirements
=
[
self
.
_constrain
(
pkg_resources
.
Requirement
.
parse
(
spec
)
)
requirements
=
[
pkg_resources
.
Requirement
.
parse
(
spec
)
for
spec
in
specs
]
requirements
=
[
self
.
_constrain
(
requirement
)
for
requirement
in
requirements
if
not
requirement
.
marker
or
requirement
.
marker
.
evaluate
()
]
if
working_set
is
None
:
ws
=
pkg_resources
.
WorkingSet
([])
else
:
...
...
@@ -1168,6 +1174,8 @@ def scripts(reqs, working_set, executable, dest=None,
for
req
in
reqs
:
if
isinstance
(
req
,
str
):
req
=
pkg_resources
.
Requirement
.
parse
(
req
)
if
req
.
marker
and
not
req
.
marker
.
evaluate
():
continue
dist
=
working_set
.
find
(
req
)
# regular console_scripts entry points
for
name
in
pkg_resources
.
get_entry_map
(
dist
,
'console_scripts'
):
...
...
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