Beispiel #1
0
def init(project):
    """Initialize a pyproject.toml for PDM."""
    python = click.prompt("Please enter the Python interpreter to use")
    actions.do_use(project, python)

    if project.pyproject_file.exists():
        context.io.echo("{}".format(
            context.io.cyan("pyproject.toml already exists, update it now.")))
    else:
        context.io.echo("{}".format(
            context.io.cyan("Creating a pyproject.toml for PDM...")))
    name = click.prompt(f"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(f"Author name", default=git_user)
    email = click.prompt(f"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)
Beispiel #2
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)
Beispiel #3
0
    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)
Beispiel #4
0
Datei: init.py Projekt: 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)
Beispiel #5
0
def init(project):
    if project.pyproject_file.exists():
        context.io.echo("{}".format(
            context.io.cyan("pyproject.toml already exists, update it now.")))
    else:
        context.io.echo("{}".format(
            context.io.cyan("Creating a pyproject.toml for PDM...")))
    name = click.prompt(f"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(f"Author name", default=git_user)
    email = click.prompt(f"Author email", default=git_email)
    actions.do_init(project, name, version, license, author, email)
Beispiel #6
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)