Exemplo n.º 1
0
    def handle(self, project: Project, options: argparse.Namespace) -> None:
        if project.pyproject_file.exists():
            stream.echo("{}".format(
                stream.cyan("pyproject.toml already exists, update it now.")))
        else:
            stream.echo("{}".format(
                stream.cyan("Creating a pyproject.toml for PDM...")))
        python = click.prompt("Please enter the Python interpreter to use",
                              default="",
                              show_default=False)
        actions.do_use(project, python)
        name = click.prompt("Project name", default=project.root.name)
        version = click.prompt("Project version", default="0.0.0")
        license = click.prompt("License(SPDX name)", default="MIT")

        git_user, git_email = get_user_email_from_git()
        author = click.prompt("Author name", default=git_user)
        email = click.prompt("Author email", default=git_email)
        python_version = ".".join(
            map(str,
                get_python_version(project.environment.python_executable)[:2]))
        python_requires = click.prompt("Python requires('*' to allow any)",
                                       default=f">={python_version}")

        actions.do_init(project, name, version, license, author, email,
                        python_requires)
        actions.ask_for_import(project)
Exemplo n.º 2
0
    def handle(self, project: Project, options: argparse.Namespace) -> None:
        if not project.meta and click._compat.isatty(sys.stdout):
            actions.ask_for_import(project)

        if options.lock:
            if not project.lockfile_file.exists():
                project.core.ui.echo(
                    "Lock file does not exist, trying to generate one...")
                actions.do_lock(project, strategy="all")
            elif not project.is_lockfile_compatible():
                project.core.ui.echo(
                    "Lock file version is not compatible with PDM, regenerate..."
                )
                actions.do_lock(project, strategy="all")
            elif not project.is_lockfile_hash_match():
                project.core.ui.echo(
                    "Lock file hash doesn't match pyproject.toml, regenerating..."
                )
                actions.do_lock(project, strategy="reuse")
        actions.do_sync(
            project,
            sections=options.sections,
            dev=options.dev,
            default=options.default,
            no_editable=options.no_editable,
            no_self=options.no_self,
        )
Exemplo n.º 3
0
    def handle(self, project: Project, options: argparse.Namespace) -> None:
        if not project.meta and click._compat.isatty(sys.stdout):
            actions.ask_for_import(project)

        strategy = actions.check_lockfile(project, False)
        if strategy:
            if options.check:
                project.core.ui.echo(
                    "Please run `pdm lock` to update the lock file", err=True)
                sys.exit(1)
            if options.lock:
                project.core.ui.echo("Updating the lock file...",
                                     fg="green",
                                     err=True)
                actions.do_lock(project,
                                strategy=strategy,
                                dry_run=options.dry_run)

        actions.do_sync(
            project,
            groups=options.groups,
            dev=options.dev,
            default=options.default,
            no_editable=options.no_editable,
            no_self=options.no_self,
            dry_run=options.dry_run,
        )
Exemplo n.º 4
0
Arquivo: init.py Projeto: xareelee/pdm
    def handle(self, project: Project, options: argparse.Namespace) -> None:
        if project.pyproject_file.exists():
            project.core.ui.echo("{}".format(
                termui.cyan("pyproject.toml already exists, update it now.")))
        else:
            project.core.ui.echo("{}".format(
                termui.cyan("Creating a pyproject.toml for PDM...")))
        non_interactive = options.non_interactive
        if non_interactive:
            actions.do_use(project, "3", True)
        else:
            actions.do_use(project)
        is_library = (False if non_interactive else click.confirm(
            "Is the project a library that will be upload to PyPI?", ))
        if is_library:
            name = self.ask("Project name", project.root.name, non_interactive)
            version = self.ask("Project version", "0.1.0", non_interactive)
        else:
            name, version = "", ""
        license = self.ask("License(SPDX name)", "MIT", non_interactive)

        git_user, git_email = get_user_email_from_git()
        author = self.ask("Author name", git_user, non_interactive)
        email = self.ask("Author email", git_email, non_interactive)
        python_version = f"{project.python.major}.{project.python.minor}"
        python_requires = self.ask("Python requires('*' to allow any)",
                                   f">={python_version}", non_interactive)

        actions.do_init(project, name, version, license, author, email,
                        python_requires)
        if not non_interactive:
            actions.ask_for_import(project)
Exemplo n.º 5
0
Arquivo: init.py Projeto: ulwlu/pdm
    def handle(self, project: Project, options: argparse.Namespace) -> None:
        if project.pyproject_file.exists():
            project.core.ui.echo("{}".format(
                termui.cyan("pyproject.toml already exists, update it now.")))
        else:
            project.core.ui.echo("{}".format(
                termui.cyan("Creating a pyproject.toml for PDM...")))
        actions.do_use(project)
        is_library = click.confirm(
            "Is the project a library that will be upload to PyPI?", )
        if is_library:
            name = click.prompt("Project name", default=project.root.name)
            version = click.prompt("Project version", default="0.1.0")
        else:
            name, version = "", ""
        license = click.prompt("License(SPDX name)", default="MIT")

        git_user, git_email = get_user_email_from_git()
        author = click.prompt("Author name", default=git_user)
        email = click.prompt("Author email", default=git_email)
        python_version, _ = get_python_version(project.python_executable, True,
                                               2)
        python_requires = click.prompt("Python requires('*' to allow any)",
                                       default=f">={python_version}")

        actions.do_init(project, name, version, license, author, email,
                        python_requires)
        actions.ask_for_import(project)
Exemplo n.º 6
0
    def handle(self, project: Project, options: argparse.Namespace) -> None:
        if not project.meta and click._compat.isatty(sys.stdout):
            actions.ask_for_import(project)

        if options.lock:
            if not project.lockfile_file.exists():
                stream.echo(
                    "Lock file does not exist, trying to generate one...")
                actions.do_lock(project, strategy="all")
            elif not project.is_lockfile_hash_match():
                stream.echo(
                    "Lock file hash doesn't match pyproject.toml, regenerating..."
                )
                actions.do_lock(project, strategy="reuse")
        actions.do_sync(project, options.sections, options.dev,
                        options.default, False, False)
Exemplo n.º 7
0
    def handle(self, project: Project, options: argparse.Namespace) -> None:
        if project.pyproject_file.exists():
            stream.echo(
                "{}".format(
                    stream.cyan("pyproject.toml already exists, update it now.")
                )
            )
        else:
            stream.echo(
                "{}".format(stream.cyan("Creating a pyproject.toml for PDM..."))
            )
        python = click.prompt(
            "Please enter the Python interpreter to use", default="", show_default=False
        )
        actions.do_use(project, python)
        is_library = (
            click.prompt(
                "Is the project a library that will be upload to PyPI?(y/n)",
                default="n",
            ).lower()
            == "y"
        )
        if is_library:
            name = click.prompt("Project name", default=project.root.name)
            version = click.prompt("Project version", default="0.1.0")
        else:
            name, version = "", ""
        license = click.prompt("License(SPDX name)", default="MIT")

        git_user, git_email = get_user_email_from_git()
        author = click.prompt("Author name", default=git_user)
        email = click.prompt("Author email", default=git_email)
        python_version, _ = get_python_version(
            project.environment.python_executable, True, 2
        )
        python_requires = click.prompt(
            "Python requires('*' to allow any)", default=f">={python_version}"
        )

        actions.do_init(project, name, version, license, author, email, python_requires)
        actions.ask_for_import(project)