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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SCS
pip-deps
Commits
48e183bb
Commit
48e183bb
authored
Sep 2, 2020
by
Marek Chrastina
Browse files
Options
Downloads
Plain Diff
Merge branch 'dev' into 'master'
Fix requires-python See merge request
!9
parents
c9326b03
01ffb28e
No related branches found
No related tags found
1 merge request
!9
Fix requires-python
Pipeline
#13079
passed
Sep 2, 2020
Stage: test
Stage: build
Stage: check
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
pipdeps/pipdeps.py
+62
-36
62 additions, 36 deletions
pipdeps/pipdeps.py
with
62 additions
and
36 deletions
pipdeps/pipdeps.py
+
62
−
36
View file @
48e183bb
...
@@ -328,53 +328,49 @@ def get_metadata(package, version):
...
@@ -328,53 +328,49 @@ def get_metadata(package, version):
break
break
return
metadata
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
):
def
parse_metadata
(
metadata
,
extra
):
"""
"""
Return dependencies parsed from metadata
Return dependencies parsed from metadata
"""
"""
if
metadata
is
None
:
if
metadata
is
None
:
return
None
return
None
for
line
in
metadata
:
mversion
=
metadata_version
(
metadata
)
if
'
Metadata-Version
'
in
line
.
decode
(
'
utf-8
'
):
if
mversion
and
is_in_specifiers
(
mversion
,
[
'
>=2.0
'
]):
metadata_version
=
line
.
replace
(
'
Metadata-Version:
'
,
''
).
strip
()
break
arr
=
[]
if
metadata_version
and
\
packaging
.
version
.
Version
(
metadata_version
)
>=
packaging
.
version
.
Version
(
'
2.0
'
):
arr
=
[]
arr
=
[]
lines
=
[
line
.
replace
(
'
Requires-Dist:
'
,
''
).
strip
()
\
lines
=
[
line
.
replace
(
'
Requires-Dist:
'
,
''
).
strip
()
\
for
line
in
metadata
if
re
.
search
(
r
'
^Requires-Dist:
'
,
line
)]
for
line
in
metadata
if
re
.
search
(
r
'
^Requires-Dist:
'
,
line
)]
for
line
in
lines
:
for
line
in
lines
:
data
=
pkginfo
(
str
(
line
),
req_extra
=
extra
,
repair
=
True
)
data
=
pkginfo
(
str
(
line
),
req_extra
=
extra
,
repair
=
True
)
if
data
:
if
data
:
arr
.
append
(
pkginfo
(
str
(
line
),
req_extra
=
extra
,
repair
=
True
)
)
arr
.
append
(
data
)
return
arr
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
):
def
pkginfo
(
data
,
req_extra
=
None
,
repair
=
False
):
"""
"""
Return parsed pkginfo
Return parsed pkginfo
...
@@ -418,6 +414,31 @@ def pkginfo(data, req_extra=None, repair=False):
...
@@ -418,6 +414,31 @@ def pkginfo(data, req_extra=None, repair=False):
return
None
return
None
return
(
pkg_name
.
lower
(),
pkg_ver
,
pkg_extra
)
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
):
def
insert_extras
(
data
):
"""
"""
Insert extras
Insert extras
...
@@ -474,8 +495,8 @@ def get_available_vers(package):
...
@@ -474,8 +495,8 @@ def get_available_vers(package):
if
requires_python
:
if
requires_python
:
requires_python
=
list
(
set
(
requires_python
))
requires_python
=
list
(
set
(
requires_python
))
if
len
(
packagetype
)
==
1
and
packagetype
[
0
]
==
'
bdist_wheel
'
and
len
(
python_version
)
==
1
:
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
])
py_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
)]):
if
py_ver
is
not
None
and
not
is_in_specifiers
(
PY_VER
,
[
"
>= %s
"
%
py_ver
.
group
(
1
)]):
continue
continue
if
is_version
(
release
)
and
is_in_specifiers
(
PY_VER
,
requires_python
):
if
is_version
(
release
)
and
is_in_specifiers
(
PY_VER
,
requires_python
):
versions
.
append
(
release
)
versions
.
append
(
release
)
...
@@ -505,7 +526,12 @@ def insert_news(data):
...
@@ -505,7 +526,12 @@ def insert_news(data):
if
new_version
:
if
new_version
:
res
=
{}
res
=
{}
for
version
in
new_version
:
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
:
pkg_data
[
'
available_version
'
].
remove
(
version
)
continue
content
=
parse_metadata
(
metadata
,
pkg_data
[
'
extras
'
])
if
content
is
not
None
:
if
content
is
not
None
:
res
[
version
]
=
content
res
[
version
]
=
content
if
res
:
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
sign in
to comment