[FIX] support real version from requirements.txt with poetry

- Add ignore requirements to exclude pip installation
- Rename dependancy to dependency
This commit is contained in:
Mathieu Benoit 2020-08-06 03:09:49 -04:00
parent e74ba1f31e
commit f4b1687bfc
5 changed files with 878 additions and 533 deletions

1
ignore_requirements.txt Normal file
View file

@ -0,0 +1 @@
mercurial

1234
poetry.lock generated

File diff suppressed because it is too large Load diff

View file

@ -11,116 +11,121 @@ authors = [ "Mathieu Benoit <mathben@technolibre.ca>", "Alexandre Ferreira Benev
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.7" python = "^3.7"
Babel = "^2.3.4" Babel = "2.3.4"
GitPython = "^3.1.7" GitPython = "^3.1.7"
Jinja2 = "^2.10.1" Jinja2 = "2.10.1"
Mako = "^1.0.4" Mako = "1.0.4"
MarkupSafe = "^0.23" MarkupSafe = "0.23"
Pillow = "^6.1.0" Pillow = "6.1.0"
PyJWT = "^1.7.1" PyJWT = "1.7.1"
PyPDF2 = "^1.26.0" PyPDF2 = "1.26.0"
PyYAML = "^4.2b4" PyYAML = "4.2b4"
SOAPpy = "^0.12.22" SOAPpy = "^0.12.22"
Voicent-Python = "^1.0" Voicent-Python = "^1.0"
Werkzeug = "^0.11.15" Werkzeug = "0.11.15"
XlsxWriter = "^0.9.3" XlsxWriter = "0.9.3"
agithub = "^2.2.2" agithub = "^2.2.2"
altair = "^4.1.0" altair = "^4.1.0"
bokeh = "^1.1.0" bokeh = "1.1.0"
boto3 = "^1.9.102" boto = "^2.49.0"
boto3 = "1.9.102"
cerberus = "^1.3.2" cerberus = "^1.3.2"
chardet = "^3.0.4" chardet = "3.0.4"
cryptography = "^2.6.1" cryptography = "2.6.1"
cython = "^0.29.21" cython = "^0.29.21"
ddt = "^1.2.0" ddt = "1.2.0"
decorator = "^4.0.10" decorator = "4.0.10"
docutils = "^0.12" docutils = "0.12"
ebaysdk = "^2.1.5" ebaysdk = "2.1.5"
email_validator = "^1.1.1" email_validator = "^1.1.1"
extract-msg = "^0.24.4" extract-msg = "^0.25.3"
factur-x = "^1.12" factur-x = "^1.12"
feedparser = "^5.2.1" feedparser = "5.2.1"
freezegun = "^0.3.11" freezegun = "0.3.11"
geojson = "^2.4.1" geojson = "2.4.1"
gevent = "^1.3.4" gevent = "1.3.4"
gitpython = "^3.1.7" gitpython = "^3.1.7"
giturlparse = "^0.9.2" giturlparse = "^0.9.2"
greenlet = "^0.4.13" greenlet = "0.4.13"
html2text = "^2016.9.19" html2text = "2016.9.19"
invoice2data = "^0.3.5" invoice2data = "^0.3.5"
iscompatible = "^0.1.1" iscompatible = "^0.1.1"
jira = "^2.0.0" jira = "2.0.0"
keystoneauth1 = "^3.14.0" keystoneauth1 = "3.14.0"
lasso = "^0.0.5" lasso = "^0.0.5"
libsass = "^0.12.3" libsass = "0.12.3"
lxml = "^4.2.3" lxml = "4.2.3"
matplotlib = ">=2.0.0" matplotlib = ">=2.0.0"
mock = "^2.0.0" mock = "2.0.0"
mpld3 = "^0.3" mpld3 = "0.3"
mysqlclient = "^2.0.1" mysqlclient = "^2.0.1"
num2words = "^0.5.6" num2words = "0.5.6"
numpy = "^1.19.1" numpy = "^1.19.1"
oauthlib = "^2.1.0" oauthlib = "2.1.0"
"oca.decorators" = "^0.0.1" "oca.decorators" = "^0.0.1"
ofxparse = "^0.16" ofxparse = "0.16"
openpyxl = "^3.0.4" openpyxl = "^3.0.4"
openupgradelib = "^2.0.0" openupgradelib = "^2.0.0"
paramiko = "^2.7.1" paramiko = "^2.7.1"
passlib = "^1.6.5" passlib = "1.6.5"
pdf2image = "^1.13.1" pdf2image = "^1.13.1"
phonenumbers = "^8.12.7" phonenumbers = "^8.12.7"
plotly = "^4.1.0" plotly = "4.1.0"
premailer = "^3.7.0" premailer = "^3.7.0"
psutil = "^4.3.1" psutil = "4.3.1"
psycopg2 = "^2.7.3.1" psycopg2 = "2.7.3.1"
py-Asterisk = "^0.5.18" py-Asterisk = "^0.5.18"
"py3o.formats" = "^0.3" "py3o.formats" = "^0.3"
"py3o.template" = "^0.10.0" "py3o.template" = "^0.10.0"
pycountry = "^20.7.3" pycountry = "^20.7.3"
pydot = "^1.2.3" pydot = "1.2.3"
pygount = "<1.2.0" pygount = "<1.2.0"
pyldap = "^2.4.28" pyldap = "2.4.28"
pymssql = "^2.1.4" pymssql = "^2.1.4"
pyotp = "^2.3.0" pyotp = "^2.4.0"
pyparsing = "^2.1.10" pyparsing = "2.1.10"
pyserial = "^3.1.1" pyserial = "3.1.1"
pysftp = "^0.2.9" pysftp = "^0.2.9"
python-dateutil = "^2.5.3" python-chess = "<0.24"
python-json-logger = "^0.1.5" python-dateutil = "2.5.3"
python-keystoneclient = "^3.22.0" python-json-logger = "0.1.5"
python-keystoneclient = "3.22.0"
python-slugify = ">=3.0.2" python-slugify = ">=3.0.2"
python-swiftclient = "^3.9.0" python-swiftclient = "3.9.0"
python-u2flib-server = "^5.0.0" python-u2flib-server = "^5.0.0"
pytz = "^2016.7" pytz = "2016.7"
pyusb = "^1.0.0" pyusb = "1.0.0"
pyzbar = "^0.1.8" pyzbar = "^0.1.8"
qrcode = "^5.3" qrcode = "5.3"
raven = "^6.10.0" raven = "^6.10.0"
redis = "^2.10.5" redis = "2.10.5"
reportlab = "^3.3.0" reportlab = "3.3.0"
requests = "^2.20.0" requests = "2.20.0"
requests-mock = "^1.8.0" requests-mock = "^1.8.0"
requests-oauthlib = "^1.1.0" requests-oauthlib = "1.1.0"
requests-toolbelt = "^0.9.1" requests-toolbelt = "0.9.1"
retrying = "^1.3.3" retrying = "^1.3.3"
shapely = "^1.6.4.post2" rotate_backups_s3 = "^0.3"
shapely = "1.6.4.post2"
simplejson = "^3.17.2"
sphinx = ">=1.6.7" sphinx = ">=1.6.7"
sphinx-patchqueue = ">=1.0" sphinx-patchqueue = ">=1.0"
sqlalchemy = "^1.3.18" sqlalchemy = "^1.3.18"
statsd = "^3.2.1" statsd = "3.2.1"
suds-jurko = "^0.6" suds-jurko = "0.6"
toml = "^0.10.1" toml = "^0.10.1"
unidecode = "^1.0.22" unidecode = "1.0.22"
vatnumber = "^1.2" vatnumber = "1.2"
vcrpy = ">=2.1.1" vcrpy = ">=2.1.1"
vcrpy-unittest = "^0.1.7" vcrpy-unittest = "^0.1.7"
vobject = "^0.9.3" vobject = "0.9.3"
webcolors = "^1.10" webcolors = "1.10"
websocket-client = "^0.57.0" websocket-client = "^0.57.0"
wheel = "^0.34.2" wheel = "^0.34.2"
xlrd = "^1.0.0" xlrd = "1.0.0"
xlwt = "^1.3" xlwt = "1.3"
xmltodict = "^0.12.0" xmltodict = "^0.12.0"
zeep = "^3.4.0"
zxcvbn = "^4.4.28" zxcvbn = "^4.4.28"
[tool.poetry.dev-dependencies] [tool.poetry.dev-dependencies]

View file

@ -0,0 +1,3 @@
#!/usr/bin/env bash
source $HOME/.poetry/env
poetry add -vv $(grep -v ";" ./.venv/build_dependency.txt | grep -v "*" )

View file

@ -27,7 +27,7 @@ def get_config():
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawDescriptionHelpFormatter,
description='''\ description='''\
Update pip dependancy in Poetry, clear pyproject.toml, search all dependancies Update pip dependency in Poetry, clear pyproject.toml, search all dependencies
from requirements.txt, search conflict version and generate a new list. from requirements.txt, search conflict version and generate a new list.
Launch Poetry installation. Launch Poetry installation.
''', ''',
@ -36,6 +36,8 @@ def get_config():
) )
parser.add_argument('-d', '--dir', dest="dir", default="./", parser.add_argument('-d', '--dir', dest="dir", default="./",
help="Path of repo to change remote, including submodule.") help="Path of repo to change remote, including submodule.")
parser.add_argument('-f', '--force', action="store_true",
help="Force create new list of dependency, ignore poetry.lock.")
parser.add_argument('-v', '--verbose', action="store_true", parser.add_argument('-v', '--verbose', action="store_true",
help="More information in execution, show stats.") help="More information in execution, show stats.")
args = parser.parse_args() args = parser.parse_args()
@ -50,7 +52,7 @@ def combine_requirements(config):
""" """
Search all module and version in all requirements.txt file in this project. Search all module and version in all requirements.txt file in this project.
For each version, check compatibility and show warning with provenance file For each version, check compatibility and show warning with provenance file
Generate requirements.txt to "./.venv/build_dependancy.txt" Generate requirements.txt to "./.venv/build_dependency.txt"
:param config: :param config:
:return: :return:
""" """
@ -174,11 +176,21 @@ def combine_requirements(config):
else: else:
print(f"Internal error, missing result for {lst_requis}.") print(f"Internal error, missing result for {lst_requis}.")
with open("./.venv/build_dependancy.txt", 'w') as f: # Support ignored requirements
lst_ignore = get_list_ignored()
lst_ignored_key = []
for key in dct_requirements.keys():
for ignored in lst_ignore:
if ignored == key:
lst_ignored_key.append(key)
for key in lst_ignored_key:
del dct_requirements[key]
with open("./.venv/build_dependency.txt", 'w') as f:
f.writelines([f"{list(a)[0]}\n" for a in dct_requirements.values()]) f.writelines([f"{list(a)[0]}\n" for a in dct_requirements.values()])
def sorted_dependancy_poetry(pyproject_filename): def sorted_dependency_poetry(pyproject_filename):
# Open pyproject.toml # Open pyproject.toml
with open(pyproject_filename, 'r') as f: with open(pyproject_filename, 'r') as f:
dct_pyproject = toml.load(f) dct_pyproject = toml.load(f)
@ -200,7 +212,7 @@ def sorted_dependancy_poetry(pyproject_filename):
toml.dump(dct_pyproject, f) toml.dump(dct_pyproject, f)
def delete_dependancy_poetry(pyproject_filename): def delete_dependency_poetry(pyproject_filename):
# Open pyproject.toml # Open pyproject.toml
with open(pyproject_filename, 'r') as f: with open(pyproject_filename, 'r') as f:
dct_pyproject = toml.load(f) dct_pyproject = toml.load(f)
@ -220,8 +232,14 @@ def delete_dependancy_poetry(pyproject_filename):
toml.dump(dct_pyproject, f) toml.dump(dct_pyproject, f)
def call_poetry_add_build_dependancy(): def call_poetry_add_build_dependency():
os.system("./script/poetry_add_build_dependancy.sh") os.system("./script/poetry_add_build_dependency.sh")
def get_list_ignored():
with open("./ignore_requirements.txt", 'r') as f:
lst_ignore_requirements = [a.strip() for a in f.readlines()]
return lst_ignore_requirements
def main(): def main():
@ -230,10 +248,12 @@ def main():
config = get_config() config = get_config()
pyproject_toml_filename = f'{config.dir}pyproject.toml' pyproject_toml_filename = f'{config.dir}pyproject.toml'
delete_dependancy_poetry(pyproject_toml_filename) delete_dependency_poetry(pyproject_toml_filename)
combine_requirements(config) combine_requirements(config)
call_poetry_add_build_dependancy() if config.force:
sorted_dependancy_poetry(pyproject_toml_filename) os.remove("./poetry.lock")
call_poetry_add_build_dependency()
sorted_dependency_poetry(pyproject_toml_filename)
if __name__ == '__main__': if __name__ == '__main__':