ComplianceAsCode / content

Security automation content in SCAP, Bash, Ansible, and other formats
https://complianceascode.readthedocs.io/en/latest/
Other
2.17k stars 685 forks source link

Adopt a dependency management strategy for utility dependencies #7988

Open rhmdnd opened 2 years ago

rhmdnd commented 2 years ago

Description of problem:

The utils/ directory has a bunch of useful python scripts for working with CaC content. Some of the scripts rely on libraries outside the python standard library. To make it easier to use, should we consider adopting a requirements.txt file utility dependencies?

SCAP Security Guide Version:

Operating System Version:

Steps to Reproduce:

  1. Try running any utility script with non-standard library dependency
    $ python utils/duplicated_prodtypes.py -h
    Traceback (most recent call last):
    File "/home/lbragstad/Projects/content/utils/duplicated_prodtypes.py", line 8, in <module>
    import ssg
    ModuleNotFoundError: No module named 'ssg'

Actual Results:

Import failures depending on the scripts you're trying to use.

Expected Results:

Tools work as expected after installing requirements.

Additional Information/Debugging Steps:

We could update the documentation to reference requirements.txt during install process, or use tox to build a virtual environment with all the necessary dependencies for the utility scripts we rely on in CaC.

jharmison-redhat commented 2 years ago

I propose a third alternative which would work well for the use case of the utility scripts: https://github.com/pypa/pipenv

The biggest argument against this, of course, is:

rhmdnd commented 2 years ago

That's a good point. I updated the issue to be more generic about dependency management.

I'm in favor of either approach. In my opinion, I feel like offering something to handle dependencies, even if it does add another tool to the project, makes it easier to use all the utility scripts.

Mab879 commented 1 year ago

10487 has been merged, to help with the Python side.