sarugaku / passa

Resolver implementation and toolset for generating and interacting with Pipfile and Pipfile.lock.
ISC License
53 stars 12 forks source link

Restructure and reorganization #53

Open techalchemy opened 6 years ago

techalchemy commented 6 years ago

Let me know if you have questions or want to change anything here. I tested a bunch of stuff and it seems to work, and (for me anyway) this is starting to make a lot of sense. Happy to work with you to make it clearer, but it's actually a lot easier for me to follow so if it's not too bad for you it'd be super helpful

Here is an example of cli.add:

class Command(BaseCommand):

    name = "add"
    description = "Add packages to project."
    arguments = [package_group]

    def run(self, options):
        if not options.editable_lines and not options.requirement_lines:
            self.parser.error("Must supply either a requirement or --editable")
        return add_packages(
            packages=options.packages,
            editables=options.editables,
            project=options.project,
            dev=options.dev
        )

and the corresponding actions.add

def add_packages(packages=[], editables=[], project=None, dev=False, sync=False, clean=False):
    from passa.models.lockers import PinReuseLocker
    from passa.operations.lock import lock
    ....

This way our core logic isn't tied exclusively to the CLI (and might be accessed by say, pipenv internals someday as a side-benefit)

Here is a new option (from cli.options):

dev_only = Option(
    "--dev", dest="only", action="store_const", const="dev",
    help="only try to modify [dev-packages]",
)

# and an argument group
package_group = ArgumentGroup("packages", options=[packages, editable, dev, no_sync])
techalchemy commented 5 years ago

FYI I am going to add some tests on top of this and merge it if you don't have any issues, since this makes it a lot easier to test as i mentioned somewhere else

uranusjr commented 5 years ago

Sure, I probably won’t have much time working on this for the next week, and if I find some I’ll work on creating a better mock PyPI server first.

techalchemy commented 5 years ago

No worries I don’t think I changed any functionality just moved stuff around. But if you want to release a patch release of master (or I can if you’re ok with it) I can bundle that as the.backup resolver and cut a release of pipenv