Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pip-deps
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SCS
pip-deps
Commits
72995445
Commit
72995445
authored
4 years ago
by
Marek Chrastina
Browse files
Options
Downloads
Patches
Plain Diff
Fix requires-python
parent
c9326b03
No related branches found
No related tags found
No related merge requests found
Pipeline
#13066
failed
4 years ago
Stage: test
Stage: build
Stage: check
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pipdeps/pipdeps.py
+67
-36
67 additions, 36 deletions
pipdeps/pipdeps.py
with
67 additions
and
36 deletions
pipdeps/pipdeps.py
+
67
−
36
View file @
72995445
...
...
@@ -328,53 +328,50 @@ def get_metadata(package, version):
break
return
metadata
def
metadata_version
(
data
):
"""
Return metadata version or None
"""
version
=
None
for
line
in
data
:
if
'
Metadata-Version
'
in
line
.
decode
(
'
utf-8
'
):
version
=
line
.
replace
(
'
Metadata-Version:
'
,
''
).
strip
()
break
return
version
def
validate_pyver
(
metadata
):
"""
Return True if python version satisfies
"""
if
metadata
is
None
:
return
None
mversion
=
metadata_version
(
metadata
)
if
mversion
and
is_in_specifiers
(
mversion
,
[
'
>=2.0
'
]):
py_ver
=
"
,
"
.
join
([
line
.
replace
(
'
Requires-Python:
'
,
''
).
strip
()
\
for
line
in
metadata
if
re
.
search
(
r
'
^Requires-Python:
'
,
line
)])
py_ver
=
py_ver
.
split
(
'
,
'
)
if
py_ver
:
return
is_in_specifiers
(
PY_VER
,
py_ver
)
return
True
def
parse_metadata
(
metadata
,
extra
):
"""
Return dependencies parsed from metadata
"""
if
metadata
is
None
:
return
None
for
line
in
metadata
:
if
'
Metadata-Version
'
in
line
.
decode
(
'
utf-8
'
):
metadata_version
=
line
.
replace
(
'
Metadata-Version:
'
,
''
).
strip
()
break
arr
=
[]
if
metadata_version
and
\
packaging
.
version
.
Version
(
metadata_version
)
>=
packaging
.
version
.
Version
(
'
2.0
'
):
mversion
=
metadata_version
(
metadata
)
if
mversion
and
is_in_specifiers
(
mversion
,
[
'
>=2.0
'
]):
arr
=
[]
lines
=
[
line
.
replace
(
'
Requires-Dist:
'
,
''
).
strip
()
\
for
line
in
metadata
if
re
.
search
(
r
'
^Requires-Dist:
'
,
line
)]
for
line
in
lines
:
data
=
pkginfo
(
str
(
line
),
req_extra
=
extra
,
repair
=
True
)
if
data
:
arr
.
append
(
pkginfo
(
str
(
line
),
req_extra
=
extra
,
repair
=
True
)
)
arr
.
append
(
data
)
return
arr
def
get_pkg_data
():
"""
Return package data
"""
packages_data
=
{}
# pylint: disable=protected-access
for
pkg
in
pip
.
_internal
.
utils
.
misc
.
get_installed_distributions
():
pkg_name
,
pkg_ver
,
_pkg_extra
=
pkginfo
(
str
(
pkg
))
rev
=
{
'
installed_version
'
:
pkg_ver
,
'
requires
'
:
[
pkginfo
(
str
(
dep
),
repair
=
True
)
for
dep
in
pkg
.
requires
()]}
packages_data
[
pkg_name
]
=
rev
packages_data
=
insert_extras
(
packages_data
)
packages_data
=
insert_availables
(
packages_data
)
packages_data
=
insert_news
(
packages_data
)
while
True
:
new_packages_data
=
new_packages
(
packages_data
)
if
not
new_packages_data
:
break
new_packages_data
=
insert_availables
(
new_packages_data
)
new_packages_data
=
insert_news
(
new_packages_data
)
packages_data
=
merge_two_dicts
(
packages_data
,
new_packages_data
)
check_new_extras
(
packages_data
)
return
packages_data
def
pkginfo
(
data
,
req_extra
=
None
,
repair
=
False
):
"""
Return parsed pkginfo
...
...
@@ -418,6 +415,31 @@ def pkginfo(data, req_extra=None, repair=False):
return
None
return
(
pkg_name
.
lower
(),
pkg_ver
,
pkg_extra
)
def
get_pkg_data
():
"""
Return package data
"""
packages_data
=
{}
# pylint: disable=protected-access
for
pkg
in
pip
.
_internal
.
utils
.
misc
.
get_installed_distributions
():
pkg_name
,
pkg_ver
,
_pkg_extra
=
pkginfo
(
str
(
pkg
))
rev
=
{
'
installed_version
'
:
pkg_ver
,
'
requires
'
:
[
pkginfo
(
str
(
dep
),
repair
=
True
)
for
dep
in
pkg
.
requires
()]}
packages_data
[
pkg_name
]
=
rev
packages_data
=
insert_extras
(
packages_data
)
packages_data
=
insert_availables
(
packages_data
)
packages_data
=
insert_news
(
packages_data
)
while
True
:
new_packages_data
=
new_packages
(
packages_data
)
if
not
new_packages_data
:
break
new_packages_data
=
insert_availables
(
new_packages_data
)
new_packages_data
=
insert_news
(
new_packages_data
)
packages_data
=
merge_two_dicts
(
packages_data
,
new_packages_data
)
check_new_extras
(
packages_data
)
return
packages_data
def
insert_extras
(
data
):
"""
Insert extras
...
...
@@ -474,8 +496,8 @@ def get_available_vers(package):
if
requires_python
:
requires_python
=
list
(
set
(
requires_python
))
if
len
(
packagetype
)
==
1
and
packagetype
[
0
]
==
'
bdist_wheel
'
and
len
(
python_version
)
==
1
:
py
t
_ver
=
re
.
search
(
r
"
^py([0-9])
"
,
python_version
[
0
])
if
py
t
_ver
is
not
None
and
not
is_in_specifiers
(
PY_VER
,
[
"
>= %s
"
%
py
t
_ver
.
group
(
1
)]):
py_ver
=
re
.
search
(
r
"
^py([0-9])
"
,
python_version
[
0
])
if
py_ver
is
not
None
and
not
is_in_specifiers
(
PY_VER
,
[
"
>= %s
"
%
py_ver
.
group
(
1
)]):
continue
if
is_version
(
release
)
and
is_in_specifiers
(
PY_VER
,
requires_python
):
versions
.
append
(
release
)
...
...
@@ -505,7 +527,16 @@ def insert_news(data):
if
new_version
:
res
=
{}
for
version
in
new_version
:
content
=
parse_metadata
(
get_metadata
(
pkg
,
version
),
pkg_data
[
'
extras
'
])
metadata
=
get_metadata
(
pkg
,
version
)
pyver_validation
=
validate_pyver
(
metadata
)
if
pyver_validation
is
not
None
and
pyver_validation
is
False
:
print
pkg_data
[
'
available_version
'
]
print
pkg_data
[
'
new_version
'
]
del
pkg_data
[
'
available_version
'
][
str
(
version
)]
del
pkg_data
[
'
new_version
'
][
str
(
version
)]
continue
content
=
parse_metadata
(
metadata
,
pkg_data
[
'
extras
'
])
if
content
is
not
None
:
res
[
version
]
=
content
if
res
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment