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
etersoft
eepm
Commits
2f9e6808
Commit
2f9e6808
authored
Oct 31, 2020
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
epm-restore: add support for setup.py
parent
433de5e9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
93 additions
and
16 deletions
+93
-16
epm-restore
bin/epm-restore
+93
-16
No files found.
bin/epm-restore
View file @
2f9e6808
...
...
@@ -21,11 +21,14 @@ load_helper epm-sh-altlinux
load_helper epm-assure
# FIXME: python modules are packaged into python packages, but we have only module names and rpm package names instead of python packages
# enable python3dest(PEP-503 normalized name) provides
# https://bugzilla.altlinux.org/show_bug.cgi?id=39003
__epm_filter_pip_to_rpm
()
{
tr
"A-Z"
"a-z"
|
sed
-e
"s|-|_|g"
-e
"s|^python_||"
\
-e
"s|beautifulsoup4|bs4|"
\
-e
"s|pillow|PIL|"
\
-e
"s|redis|redis-py|"
\
-e
"s|pyjwt|jwt|"
\
-e
"s|pyyaml|yaml|"
\
-e
"s|attrs|attr|"
\
...
...
@@ -43,6 +46,30 @@ 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
pi
=
''
local
sign ll
for
sign
in
"<="
"<"
">="
">"
"=="
"!="
;
do
ll
=
$(
fill_sign
"
$sign
"
"
$l
"
)
[
-n
"
$ll
"
]
||
continue
[
"
$sign
"
=
"=="
]
&&
sign
=
"
$equal
"
[
"
$sign
"
=
"!="
]
&&
sign
=
">="
[
-n
"
$pi
"
]
&&
pi
=
"
$pi
"
pi
=
"
$pi$reqmacro
$t
$sign
$ll
"
done
[
-n
"
$pi
"
]
||
pi
=
"
$reqmacro
$t
"
echo
"
$pi
"
}
__epm_restore_pip
()
{
local
req_file
=
"
$1
"
...
...
@@ -76,36 +103,83 @@ __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"
local
pi
=
''
local
sign ll
for
sign
in
"<="
"<"
">="
">"
"=="
"!="
;
do
ll
=
$(
fill_sign
"
$sign
"
"
$l
"
)
[
-n
"
$ll
"
]
||
continue
[
"
$sign
"
=
"=="
]
&&
sign
=
">="
[
"
$sign
"
=
"!="
]
&&
sign
=
">="
[
-n
"
$pi
"
]
&&
pi
=
"
$pi
"
pi
=
"
$pi$reqmacro
$t
$sign
$ll
"
done
[
-n
"
$pi
"
]
||
pi
=
"
$reqmacro
$t
"
echo
"
$pi
"
__epm_pi_sign_to_rpm
$reqmacro
$t
$l
continue
else
# TODO: python3-egg-info($t)
local
pi
=
"python3(
$t
)"
echo
"
$l
->
$t
->
$pi
"
fi
[
-n
"
$t
"
]
||
continue
ilist
=
"
$ilist
$pi
"
done
<
$req_file
if
[
-n
"
$dryrun
"
]
;
then
echo
"
$ilist
"
return
fi
fi
docmd epm
install
$ilist
}
__epm_restore_setup_py
()
{
local
req_file
=
"
$1
"
if
[
-z
"
$dryrun
"
]
;
then
info
"Install requirements from
$req_file
..."
fi
local
ilist
=
''
local
fr fd
local
reqmacro
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
fi
if
rhas
"
$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
fi
if
rhas
"
$l
"
"tests_require=
\[
"
;
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
continue
fi
done
<
$req_file
if
[
-n
"
$dryrun
"
]
;
then
echo
"
$ilist
"
return
fi
docmd epm
install
$ilist
}
...
...
@@ -202,6 +276,9 @@ __epm_restore_by()
requirements.txt|requirements_dev.txt|requires.txt
)
[
-s
"
$req_file
"
]
&&
__epm_restore_pip
"
$req_file
"
;;
setup.py
)
[
-s
"
$req_file
"
]
&&
__epm_restore_setup_py
"
$req_file
"
;;
package.json
)
[
-s
"
$req_file
"
]
&&
__epm_restore_npm
"
$req_file
"
;;
...
...
@@ -231,7 +308,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
;
do
for
i
in
requirements.txt requirements_dev.txt Gemfile requires.txt package.json
setup.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