示例#1
0
    def handle(self):
        from poetry.installation import Installer

        installer = Installer(
            self.output,
            self.venv,
            self.poetry.package,
            self.poetry.locker,
            self.poetry.pool,
        )

        extras = []
        for extra in self.option("extras"):
            if " " in extra:
                extras += [e.strip() for e in extra.split(" ")]
            else:
                extras.append(extra)

        installer.extras(extras)
        installer.dev_mode(not self.option("no-dev"))
        installer.develop(self.option("develop"))
        installer.dry_run(self.option("dry-run"))
        installer.verbose(self.option("verbose"))

        return installer.run()
示例#2
0
    def handle(self):
        installer = Installer(self.output, self.poetry.package,
                              self.poetry.locker, self.poetry.pool)

        installer.extras(self.option('extras'))
        installer.dev_mode(not self.option('no-dev'))
        installer.dry_run(self.option('dry-run'))

        return installer.run()
示例#3
0
文件: install.py 项目: K900/poetry
    def handle(self):
        from poetry.installation import Installer
        from poetry.io import NullIO
        from poetry.masonry.builders import EditableBuilder
        from poetry.masonry.utils.module import ModuleOrPackageNotFound

        installer = Installer(
            self.output,
            self.env,
            self.poetry.package,
            self.poetry.locker,
            self.poetry.pool,
        )

        extras = []
        for extra in self.option("extras"):
            if " " in extra:
                extras += [e.strip() for e in extra.split(" ")]
            else:
                extras.append(extra)

        installer.extras(extras)
        installer.dev_mode(not self.option("no-dev"))
        installer.develop(self.option("develop"))
        installer.dry_run(self.option("dry-run"))
        installer.verbose(self.option("verbose"))

        return_code = installer.run()

        if return_code != 0:
            return return_code

        if self.option("no-root"):
            return 0

        try:
            builder = EditableBuilder(self.poetry, self._env, NullIO())
        except ModuleOrPackageNotFound:
            # This is likely due to the fact that the project is an application
            # not following the structure expected by Poetry
            # If this is a true error it will be picked up later by build anyway.
            return 0

        self.line(
            "  - Installing <info>{}</info> (<comment>{}</comment>)".format(
                self.poetry.package.pretty_name,
                self.poetry.package.pretty_version))

        if self.option("dry-run"):
            return 0

        builder.build()

        return 0
示例#4
0
    def handle(self):
        from poetry.installation import Installer
        from poetry.io import NullIO
        from poetry.masonry.builders import SdistBuilder
        from poetry.utils._compat import decode
        from poetry.utils.env import NullEnv

        installer = Installer(
            self.output,
            self.env,
            self.poetry.package,
            self.poetry.locker,
            self.poetry.pool,
        )

        extras = []
        for extra in self.option("extras"):
            if " " in extra:
                extras += [e.strip() for e in extra.split(" ")]
            else:
                extras.append(extra)

        installer.extras(extras)
        installer.dev_mode(not self.option("no-dev"))
        installer.develop(self.option("develop"))
        installer.dry_run(self.option("dry-run"))
        installer.verbose(self.option("verbose"))

        return_code = installer.run()

        if return_code != 0:
            return return_code

        setup = self.poetry.file.parent / "setup.py"
        has_setup = setup.exists()

        if has_setup:
            self.line(
                "<warning>A setup.py file already exists. Using it.</warning>")
        else:
            builder = SdistBuilder(self.poetry, NullEnv(), NullIO())

            with setup.open("w") as f:
                f.write(decode(builder.build_setup()))

        self.line("Installing <info>{}</info> (<comment>{}</comment>)".format(
            self.poetry.package.pretty_name,
            self.poetry.package.pretty_version))
        try:
            self.env.run("pip", "install", "-e", str(setup.parent),
                         "--no-deps")
        finally:
            if not has_setup:
                os.remove(str(setup))
示例#5
0
文件: install.py 项目: undu/poetry
    def handle(self):
        from poetry.installation import Installer

        installer = Installer(self.output, self.venv, self.poetry.package,
                              self.poetry.locker, self.poetry.pool)

        installer.extras(self.option('extras'))
        installer.dev_mode(not self.option('no-dev'))
        installer.dry_run(self.option('dry-run'))
        installer.verbose(self.option('verbose'))

        return installer.run()
示例#6
0
文件: install.py 项目: ofek/poetry
    def handle(self):
        from poetry.installation import Installer

        installer = Installer(self.output, self.venv, self.poetry.package,
                              self.poetry.locker, self.poetry.pool)

        extras = []
        for extra in self.option('extras'):
            if ' ' in extra:
                extras += [e.strip() for e in extra.split(' ')]
            else:
                extras.append(extra)

        installer.extras(extras)
        installer.dev_mode(not self.option('no-dev'))
        installer.develop(self.option('develop'))
        installer.dry_run(self.option('dry-run'))
        installer.verbose(self.option('verbose'))

        return installer.run()
示例#7
0
    def handle(self):
        from poetry.installation import Installer
        from poetry.io import NullIO
        from poetry.masonry.builders import SdistBuilder
        from poetry.masonry.utils.module import ModuleOrPackageNotFound
        from poetry.utils._compat import decode
        from poetry.utils.env import NullEnv

        installer = Installer(
            self.output,
            self.env,
            self.poetry.package,
            self.poetry.locker,
            self.poetry.pool,
        )

        extras = []
        for extra in self.option("extras"):
            if " " in extra:
                extras += [e.strip() for e in extra.split(" ")]
            else:
                extras.append(extra)

        installer.extras(extras)
        installer.dev_mode(not self.option("no-dev"))
        installer.develop(self.option("develop"))
        installer.dry_run(self.option("dry-run"))
        installer.verbose(self.option("verbose"))

        return_code = installer.run()

        if return_code != 0:
            return return_code

        try:
            builder = SdistBuilder(self.poetry, NullEnv(), NullIO())
        except ModuleOrPackageNotFound:
            # This is likely due to the fact that the project is an application
            # not following the structure expected by Poetry
            # If this is a true error it will be picked up later by build anyway.
            return 0

        self.line(
            "  - Installing <info>{}</info> (<comment>{}</comment>)".format(
                self.poetry.package.pretty_name, self.poetry.package.pretty_version
            )
        )

        if self.option("dry-run"):
            return 0

        setup = self.poetry.file.parent / "setup.py"
        has_setup = setup.exists()

        if has_setup:
            self.line("<warning>A setup.py file already exists. Using it.</warning>")
        else:
            with setup.open("w", encoding="utf-8") as f:
                f.write(decode(builder.build_setup()))

        try:
            self.env.run("pip", "install", "-e", str(setup.parent), "--no-deps")
        finally:
            if not has_setup:
                os.remove(str(setup))