lint-requirements 822 B

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/env python
  2. import sys
  3. import requirements
  4. def main():
  5. """
  6. We cannot have non-specifier requirements if we want to publish to PyPI
  7. due to security concerns. This check ensures we don't have/add any URL/VCS
  8. dependencies in the base requirements file.
  9. """
  10. with open("requirements-base.txt") as reqs_file:
  11. if any(not req.specifier for req in requirements.parse(reqs_file)):
  12. print(
  13. "\n".join(
  14. [
  15. "You cannot use dependencies that are not on PyPI directly.",
  16. "See PEP440: https://www.python.org/dev/peps/pep-0440/#direct-references",
  17. ]
  18. ),
  19. file=sys.stderr,
  20. )
  21. sys.exit(1)
  22. if __name__ == "__main__":
  23. main()