Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eepm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nurlan
eepm
Commits
8f2f68a3
Commit
8f2f68a3
authored
Oct 31, 2020
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
epm-restore: rewrite to more full support of python arrays, add python_dependencies.py support
parent
2f9e6808
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
87 additions
and
65 deletions
+87
-65
epm-restore
bin/epm-restore
+87
-65
No files found.
bin/epm-restore
View file @
8f2f68a3
...
...
@@ -27,11 +27,14 @@ __epm_filter_pip_to_rpm()
{
tr
"A-Z"
"a-z"
|
sed
-e
"s|-|_|g"
-e
"s|^python_||"
\
-e
"s|beautifulsoup4|bs4|"
\
-e
"s|pillow|P
IL
|"
\
-e
"s|pillow|P
illow
|"
\
-e
"s|redis|redis-py|"
\
-e
"s|pyjwt|jwt|"
\
-e
"s|pymonetdb|monetdb|"
\
-e
"s|pyyaml|yaml|"
\
-e
"s|attrs|attr|"
\
-e
"s|twisted|twisted-core|"
\
-e
"s|pymacaroons|pymacaroons-pynacl|"
\
-e
"s|pyasn1_modules|pyasn1-modules|"
\
-e
"s|pygments|Pygments|"
\
-e
"s|patch_ng|patch-ng|"
\
-e
"s|memcached|memcache|"
\
...
...
@@ -49,11 +52,10 @@ fill_sign()
# macro pkg caseline
__epm_pi_sign_to_rpm
()
{
local
reqmacro
=
"
$1
"
local
t
=
"
$2
"
local
l
=
"
$3
"
local
equal
=
"
$4
"
[
-n
"
$equal
"
]
||
equal
=
"="
local
t
=
"
$1
"
local
l
=
"
$2
"
local
equal
=
"
$3
"
[
-n
"
$equal
"
]
||
equal
=
">="
local
pi
=
''
local
sign ll
...
...
@@ -64,28 +66,37 @@ __epm_pi_sign_to_rpm()
[
"
$sign
"
=
"!="
]
&&
sign
=
">="
[
-n
"
$pi
"
]
&&
pi
=
"
$pi
"
pi
=
"
$pi$
reqmacro
$
t
$sign
$ll
"
pi
=
"
$pi$t
$sign
$ll
"
done
[
-n
"
$pi
"
]
||
pi
=
"
$
reqmacro
$
t
"
[
-n
"
$pi
"
]
||
pi
=
"
$t
"
echo
"
$pi
"
}
__epm_
restore_pip
()
__epm_
get_array_name
()
{
local
req_file
=
"
$1
"
if
[
-n
"
$dryrun
"
]
;
then
echo
echo
"# generated by epm --restore --dry-run from
$(
basename
$(
dirname
$(
realpath
$req_file
)))
/
$req_file
"
else
info
"Install requirements from
$req_file
..."
fi
echo
"
$*
"
|
grep
"="
|
head
-n1
|
sed
-e
's| *=.*||'
}
local
ilist
=
''
__epm_lineprint_python_array
()
{
local
a
=
"
$*
"
[
-n
"
$a
"
]
||
return
local
name
=
"
$(
__epm_get_array_name
"
$a
"
)
"
(
echo
"
$a
"
|
sed
-e
's|\].*|]|'
;
echo
"print('
\n
'.join(
$name
))"
)
|
(
a
=
python -
||
a
=
python3
)
}
# translate pip requirement lines to rpm notation
# (compare signs and package names)
__epm_restore_convert_to_rpm_notation
()
{
local
equal
=
"
$1
"
local
l
while
read
l
;
do
local
t
=
"
$(
echo
"
$l
"
|
sed
-e
"s| *[<>!]*=.*||"
-e
"s| *#.*||"
| __epm_filter_pip_to_rpm
)
"
if
echo
"
$l
"
|
grep
-qE
"^ *#"
||
[
-z
"
$l
"
]
;
then
continue
fi
[
-n
"
$t
"
]
||
continue
# until new section
if
echo
"
$l
"
|
grep
-qE
"^
\[
"
;
then
break
...
...
@@ -103,28 +114,37 @@ __epm_restore_pip()
warning
"
$t
is python2 only requirement, skipped"
continue
fi
[
-n
"
$t
"
]
||
continue
if
[
-n
"
$dryrun
"
]
;
then
local
reqmacro
=
"%py3_use"
[
"
$(
basename
"
$req_file
"
)
"
=
"requirements_dev.txt"
]
&&
reqmacro
=
"%py3_buildrequires"
__epm_pi_sign_to_rpm
$reqmacro
$t
$l
continue
else
# TODO: python3-egg-info($t)
local
pi
=
"python3(
$t
)"
echo
"
$l
->
$t
->
$pi
"
fi
ilist
=
"
$ilist
$pi
"
done
<
$req_file
__epm_pi_sign_to_rpm
"
$t
"
"
$l
"
"
$equal
"
done
}
__epm_restore_pip
()
{
local
req_file
=
"
$1
"
local
reqmacro
local
ilist
if
[
-n
"
$dryrun
"
]
;
then
echo
"
$ilist
"
reqmacro
=
"%py3_use"
[
"
$(
basename
"
$req_file
"
)
"
=
"requirements_dev.txt"
]
&&
reqmacro
=
"%py3_buildrequires"
echo
echo
"# generated by epm --restore --dry-run from
$(
basename
$(
dirname
$(
realpath
$req_file
)))
/
$req_file
"
cat
$req_file
| __epm_restore_convert_to_rpm_notation |
sed
-e
"s|^|
$reqmacro
|"
return
else
info
"Install requirements from
$req_file
..."
ilist
=
"
$(
cat
$req_file
| __epm_restore_convert_to_rpm_notation |
cut
-d
' '
-f
1 |
sed
-e
"s|^|python3-module-|"
)
"
fi
ilist
=
"
$(
estrlist list
$ilist
)
"
docmd epm
install
$ilist
}
__eresection
()
{
rhas
"
$1
"
"[[:space:]]*
$2
[[:space:]]*=[[:space:]]*
\[
"
}
__epm_restore_setup_py
()
{
local
req_file
=
"
$1
"
...
...
@@ -132,55 +152,57 @@ __epm_restore_setup_py()
info
"Install requirements from
$req_file
..."
fi
local
ar
=
''
local
ilist
=
''
local
fr fd
local
reqmacro
local
section
=
''
while
read
l
;
do
if
rhas
"
$l
"
"^ *#"
;
then
continue
fi
if
rhas
"
$l
"
"
\]
,"
;
then
fr
=
''
fd
=
''
continue
fi
if
[
-n
"
$fr$fd
"
]
;
then
local
ll
=
"
$(
echo
"
$l
"
|
sed
-e
"s|[[:space:]]*'||"
-e
"s|'.*||"
)
"
local
t
=
"
$(
echo
"
$ll
"
|
sed
-e
"s| *[<>!]*=.*||"
| __epm_filter_pip_to_rpm
)
"
if
[
-n
"
$dryrun
"
]
;
then
__epm_pi_sign_to_rpm
$reqmacro
$t
$ll
">="
else
local
pi
=
"python3-module-
$t
"
ilist
=
"
$ilist
$pi
"
echo
"
$l
->
$t
->
$pi
"
fi
continue
# start of section
if
__eresection
"
$l
"
"REQUIREMENTS"
;
then
reqmacro
=
"%py3_use"
section
=
"
$l
"
fi
if
rhas
"
$l
"
"install_requires=
\[
"
;
then
if
__eresection
"
$l
"
"install_requires
"
;
then
reqmacro
=
"%py3_use"
if
[
-n
"
$dryrun
"
]
;
then
echo
echo
"# generated by epm --restore --dry-run from
$(
basename
$(
dirname
$(
realpath
$req_file
)))
/
$req_file
$l
"
fi
fr
=
1
continue
section
=
"
$l
"
fi
if
rhas
"
$l
"
"tests_require=
\[
"
;
then
if
__eresection
"
$l
"
"setup_requires
"
;
then
reqmacro
=
"%py3_buildrequires"
if
[
-n
"
$dryrun
"
]
;
then
echo
echo
"# generated by epm --restore --dry-run from
$(
basename
$(
dirname
$(
realpath
$req_file
)))
/
$req_file
$l
"
fi
fd
=
1
section
=
"
$l
"
fi
if
__eresection
"
$l
"
"tests_require"
;
then
reqmacro
=
"%py3_buildrequires"
section
=
"
$l
"
fi
if
[
-n
"
$section
"
]
;
then
ar
=
"
$ar
$l
"
fi
# not end of section
if
[
-z
"
$section
"
]
||
!
rhas
"
$l
"
"
\]
,*"
;
then
continue
fi
if
[
-n
"
$dryrun
"
]
;
then
echo
echo
"# generated by epm --restore --dry-run from
$(
basename
$(
dirname
$(
realpath
$req_file
)))
/
$req_file
$(
__epm_get_array_name
"
$section
"
)
"
__epm_lineprint_python_array
"
$ar
"
| __epm_restore_convert_to_rpm_notation
">="
|
sed
-e
"s|^|
$reqmacro
|"
else
ilist
=
"
$ilist
$(
__epm_lineprint_python_array
"
$ar
"
| __epm_restore_convert_to_rpm_notation
">="
|
cut
-d
' '
-f
1 |
sed
-e
"s|^|python3-module-|"
)
"
fi
section
=
''
ar
=
''
done
<
$req_file
if
[
-n
"
$dryrun
"
]
;
then
echo
"
$ilist
"
return
fi
ilist
=
"
$(
estrlist list
$ilist
)
"
docmd epm
install
$ilist
}
...
...
@@ -276,7 +298,7 @@ __epm_restore_by()
requirements.txt|requirements_dev.txt|requires.txt
)
[
-s
"
$req_file
"
]
&&
__epm_restore_pip
"
$req_file
"
;;
setup.py
)
setup.py
|python_dependencies.py
)
[
-s
"
$req_file
"
]
&&
__epm_restore_setup_py
"
$req_file
"
;;
package.json
)
...
...
@@ -308,7 +330,7 @@ epm_restore()
# TODO: nowhere works: python3 setup.py --requires
# if run with empty args
for
i
in
requirements.txt requirements_dev.txt Gemfile requires.txt package.json setup.py
;
do
for
i
in
requirements.txt requirements_dev.txt Gemfile requires.txt package.json setup.py
python_dependencies.py
;
do
__epm_restore_by
$i
done
...
...
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