1
0

update_setup_requirements.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # Copyright 2021-2025 Avaiga Private Limited
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  4. # the License. You may obtain a copy of the License at
  5. #
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  9. # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
  10. # specific language governing permissions and limitations under the License.
  11. import os
  12. import sys
  13. from typing import Dict
  14. BASE_PATH = "./tools/packages"
  15. def __build_taipy_package_line(line: str, version: str, publish_on_py_pi: bool) -> str:
  16. _line = line.strip()
  17. if publish_on_py_pi:
  18. return f"{_line}=={version}\n"
  19. tag = f"{version}-{_line.split('-')[1]}"
  20. tar_name = f"{_line}-{version}"
  21. return f"{_line} @ https://github.com/Avaiga/taipy/releases/download/{tag}/{tar_name}.tar.gz\n"
  22. def update_setup_requirements(package: str, versions: Dict, publish_on_py_pi: bool) -> None:
  23. _path = os.path.join(BASE_PATH, package, "setup.requirements.txt")
  24. lines = []
  25. with open(_path, mode="r") as req:
  26. for line in req:
  27. if v := versions.get(line.strip()):
  28. line = __build_taipy_package_line(line, v, publish_on_py_pi)
  29. lines.append(line)
  30. with open(_path, "w") as file:
  31. file.writelines(lines)
  32. if __name__ == "__main__":
  33. _package = sys.argv[1]
  34. _versions = {
  35. "taipy-common": sys.argv[2],
  36. "taipy-core": sys.argv[3],
  37. "taipy-gui": sys.argv[4],
  38. "taipy-rest": sys.argv[5],
  39. "taipy-templates": sys.argv[6],
  40. }
  41. _publish_on_py_pi = True if sys.argv[7] == "true" else False
  42. update_setup_requirements(_package, _versions, _publish_on_py_pi)