Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PoC] extract build logic from the Command class #10075

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Refactor build command

7941c14
Select commit
Loading
Failed to load commit list.
Draft

[PoC] extract build logic from the Command class #10075

Refactor build command
7941c14
Select commit
Loading
Failed to load commit list.
Cirrus CI / Tests / FreeBSD (Python 3.10) / pytest failed Jan 18, 2025 in 3m 12s

Task Summary

Instruction pytest failed in 01:49

Details

ℹ️ Scheduling was delayed due to a concurrency limit on community tasks

✅ 00:05 clone
✅ 01:00 bootstrap_poetry
✅ 00:13 setup_environment
❌ 01:49 pytest

    ) -> int:
        from poetry.masonry.builders import BUILD_FORMATS
    
        if not poetry.is_package_mode:
            io.write_error_line(
                "Building a package is not possible in non-package mode."
            )
            return 1
    
        with build_environment(poetry=poetry, env=env, io=io) as env:
            dist_dir = Path(output)
            package = poetry.package
            io.write_line(
                f"Building <c1>{package.pretty_name}</c1> (<c2>{package.version}</c2>)"
            )
    
            if not dist_dir.is_absolute():
                dist_dir = poetry.pyproject_path.parent / dist_dir
    
            if clean:
                remove_directory(path=dist_dir, force=True)
    
            if format in BUILD_FORMATS:
                builders = [BUILD_FORMATS[format]]
            elif format == "all":
                builders = list(BUILD_FORMATS.values())
            else:
>               raise ValueError(f"Invalid build format: {format}")
E               ValueError: Invalid build format: None

/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:101: ValueError
-------------- generated xml file: /tmp/cirrus-ci-build/junit.xml --------------
=========================== short test summary info ============================
SKIPPED [1] tests/console/commands/test_run.py:88: Poetry only installs CMD script files for console scripts of editable dependencies on Windows
SKIPPED [1] tests/installation/test_executor.py:305: https://github.com/python-poetry/poetry/issues/7983
SKIPPED [1] tests/utils/env/test_env_manager.py:1299: requires darwin
SKIPPED [1] tests/utils/test_python_manager.py:98: Windows only
SKIPPED [1] tests/console/commands/test_sync.py:26: Only relevant for `poetry install`
SKIPPED [3] tests/console/commands/env/test_activate.py:52: Only Windows shells
SKIPPED [1] tests/integration/test_utils_vcs_git.py:316: HTTP authentication credentials not available
SKIPPED [1] tests/console/commands/self/test_sync.py:26: Only relevant for `poetry self install`
FAILED tests/console/commands/test_build.py::test_build_relative_directory_src_layout - FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_relative_directory_0/project/dist'
FAILED tests/console/commands/test_build.py::test_build_output_option[../dist] - ValueError: Invalid build format: None
FAILED tests/console/commands/test_build.py::test_build_with_local_version_label - ValueError: Invalid build format: None
FAILED tests/console/commands/test_build.py::test_build_output_option[dist] - ValueError: Invalid build format: None
FAILED tests/console/commands/test_build.py::test_build_format_is_not_valid - AssertionError: Regex pattern did not match.
 Regex: 'Invalid format.*'
 Input: 'Invalid build format: not_valid'
FAILED tests/console/commands/test_build.py::test_build_with_clean_non_existing_output - ValueError: Invalid build format: None
FAILED tests/console/commands/test_build.py::test_build_output_option[test/dir] - ValueError: Invalid build format: None
FAILED tests/console/commands/test_build.py::test_build_with_clean[False] - ValueError: Invalid build format: None
FAILED tests/console/commands/test_build.py::test_build_output_option[absolute] - ValueError: Invalid build format: None
FAILED tests/console/commands/test_build.py::test_build_with_multiple_readme_files - ValueError: Invalid build format: None
FAILED tests/console/commands/test_build.py::test_build_with_clean[True] - ValueError: Invalid build format: None
FAILED tests/console/commands/test_build.py::test_build_output_option[None] - ValueError: Invalid build format: None
=========== 12 failed, 2347 passed, 10 skipped in 107.32s (0:01:47) ============

Annotations

Check failure on line 213 in tests/console/commands/test_build.py

See this annotation in the file changed.

@cirrus-ci cirrus-ci / Tests / FreeBSD (Python 3.10) / pytest

tests/console/commands/test_build.py#L213

tests.console.commands.test_build.test_build_relative_directory_src_layout
Raw output
tmp_path = PosixPath('/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_relative_directory_0')
fixture_dir = <function fixture_dir.<locals>._fixture_dir at 0x192ae69d3880>

    def test_build_relative_directory_src_layout(
        tmp_path: Path, fixture_dir: FixtureDirGetter
    ) -> None:
        tmp_project_path = tmp_path / "project"
        with with_working_directory(fixture_dir("simple_project"), tmp_project_path):
            shutil.rmtree(tmp_project_path / "dist")
            (tmp_project_path / "src").mkdir()
            (tmp_project_path / "simple_project").rename(
                tmp_project_path / "src" / "simple_project"
            )
    
            # We have to use ApplicationTester because CommandTester
            # initializes Poetry before passing the directory.
            app = Application()
            tester = ApplicationTester(app)
            tester.execute("build --project .")
    
            build_dir = tmp_project_path / "dist"
    
>           assert len(list(build_dir.iterdir())) == 2

/tmp/cirrus-ci-build/tests/console/commands/test_build.py:213: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = PosixPath('/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_relative_directory_0/project/dist')

    def iterdir(self):
        """Iterate over the files in this directory.  Does not yield any
        result for the special paths '.' and '..'.
        """
>       for name in self._accessor.listdir(self):
E       FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_relative_directory_0/project/dist'

/usr/local/lib/python3.10/pathlib.py:1017: FileNotFoundError

Check failure on line 186 in tests/console/commands/test_build.py

See this annotation in the file changed.

@cirrus-ci cirrus-ci / Tests / FreeBSD (Python 3.10) / pytest

tests/console/commands/test_build.py#L186

tests.console.commands.test_build.test_build_output_option[../dist]
Raw output
tmp_tester = <cleo.testers.command_tester.CommandTester object at 0x192aededbe50>
tmp_project_path = PosixPath('/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_output_option____di0/project')
tmp_poetry = <poetry.poetry.Poetry object at 0x192aece2b580>
output_dir = '../dist'

    @pytest.mark.parametrize(
        "output_dir", [None, "dist", "test/dir", "../dist", "absolute"]
    )
    def test_build_output_option(
        tmp_tester: CommandTester,
        tmp_project_path: Path,
        tmp_poetry: Poetry,
        output_dir: str,
    ) -> None:
        shutil.rmtree(tmp_project_path / "dist")
        if output_dir is None:
            tmp_tester.execute()
            build_dir = tmp_project_path / "dist"
        elif output_dir == "absolute":
            tmp_tester.execute(f"--output {tmp_project_path / 'tmp/dist'}")
            build_dir = tmp_project_path / "tmp/dist"
        else:
>           tmp_tester.execute(f"--output {output_dir}")

/tmp/cirrus-ci-build/tests/console/commands/test_build.py:186: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/testers/command_tester.py:88: in execute
    self._status_code = self._command.run(self._io)
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/commands/base_command.py:117: in run
    return self.execute(io) or 0
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/commands/command.py:61: in execute
    return self.handle()
/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:55: in handle
    return self.build(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

poetry = <poetry.poetry.Poetry object at 0x192aece2b580>
env = MockEnv("/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_output_option____di0/.venv")
io = <cleo.io.buffered_io.BufferedIO object at 0x192aeded9ab0>, format = None
clean = False, local_version_label = None, output = '../dist'

    @staticmethod
    def build(
        poetry: Poetry,
        env: Env,
        io: IO,
        format: str = "all",
        clean: bool = True,
        local_version_label: str | None = None,
        output: str = "dist",
    ) -> int:
        from poetry.masonry.builders import BUILD_FORMATS
    
        if not poetry.is_package_mode:
            io.write_error_line(
                "Building a package is not possible in non-package mode."
            )
            return 1
    
        with build_environment(poetry=poetry, env=env, io=io) as env:
            dist_dir = Path(output)
            package = poetry.package
            io.write_line(
                f"Building <c1>{package.pretty_name}</c1> (<c2>{package.version}</c2>)"
            )
    
            if not dist_dir.is_absolute():
                dist_dir = poetry.pyproject_path.parent / dist_dir
    
            if clean:
                remove_directory(path=dist_dir, force=True)
    
            if format in BUILD_FORMATS:
                builders = [BUILD_FORMATS[format]]
            elif format == "all":
                builders = list(BUILD_FORMATS.values())
            else:
>               raise ValueError(f"Invalid build format: {format}")
E               ValueError: Invalid build format: None

/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:101: ValueError

Check failure on line 81 in tests/console/commands/test_build.py

See this annotation in the file changed.

@cirrus-ci cirrus-ci / Tests / FreeBSD (Python 3.10) / pytest

tests/console/commands/test_build.py#L81

tests.console.commands.test_build.test_build_with_local_version_label
Raw output
tmp_tester = <cleo.testers.command_tester.CommandTester object at 0x192ae80fd120>
tmp_project_path = PosixPath('/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_with_local_version_0/project')
tmp_poetry = <poetry.poetry.Poetry object at 0x192ae8384b80>

    def test_build_with_local_version_label(
        tmp_tester: CommandTester, tmp_project_path: Path, tmp_poetry: Poetry
    ) -> None:
        shutil.rmtree(tmp_project_path / "dist")
        local_version_label = "local-version"
>       tmp_tester.execute(f"--local-version {local_version_label}")

/tmp/cirrus-ci-build/tests/console/commands/test_build.py:81: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/testers/command_tester.py:88: in execute
    self._status_code = self._command.run(self._io)
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/commands/base_command.py:117: in run
    return self.execute(io) or 0
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/commands/command.py:61: in execute
    return self.handle()
/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:55: in handle
    return self.build(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

poetry = <poetry.poetry.Poetry object at 0x192ae8384b80>
env = MockEnv("/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_with_local_version_0/.venv")
io = <cleo.io.buffered_io.BufferedIO object at 0x192ae80fd000>, format = None
clean = False, local_version_label = 'local-version', output = 'dist'

    @staticmethod
    def build(
        poetry: Poetry,
        env: Env,
        io: IO,
        format: str = "all",
        clean: bool = True,
        local_version_label: str | None = None,
        output: str = "dist",
    ) -> int:
        from poetry.masonry.builders import BUILD_FORMATS
    
        if not poetry.is_package_mode:
            io.write_error_line(
                "Building a package is not possible in non-package mode."
            )
            return 1
    
        with build_environment(poetry=poetry, env=env, io=io) as env:
            dist_dir = Path(output)
            package = poetry.package
            io.write_line(
                f"Building <c1>{package.pretty_name}</c1> (<c2>{package.version}</c2>)"
            )
    
            if not dist_dir.is_absolute():
                dist_dir = poetry.pyproject_path.parent / dist_dir
    
            if clean:
                remove_directory(path=dist_dir, force=True)
    
            if format in BUILD_FORMATS:
                builders = [BUILD_FORMATS[format]]
            elif format == "all":
                builders = list(BUILD_FORMATS.values())
            else:
>               raise ValueError(f"Invalid build format: {format}")
E               ValueError: Invalid build format: None

/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:101: ValueError

Check failure on line 186 in tests/console/commands/test_build.py

See this annotation in the file changed.

@cirrus-ci cirrus-ci / Tests / FreeBSD (Python 3.10) / pytest

tests/console/commands/test_build.py#L186

tests.console.commands.test_build.test_build_output_option[dist]
Raw output
tmp_tester = <cleo.testers.command_tester.CommandTester object at 0x192aea668100>
tmp_project_path = PosixPath('/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_output_option_dist_0/project')
tmp_poetry = <poetry.poetry.Poetry object at 0x192aea410130>
output_dir = 'dist'

    @pytest.mark.parametrize(
        "output_dir", [None, "dist", "test/dir", "../dist", "absolute"]
    )
    def test_build_output_option(
        tmp_tester: CommandTester,
        tmp_project_path: Path,
        tmp_poetry: Poetry,
        output_dir: str,
    ) -> None:
        shutil.rmtree(tmp_project_path / "dist")
        if output_dir is None:
            tmp_tester.execute()
            build_dir = tmp_project_path / "dist"
        elif output_dir == "absolute":
            tmp_tester.execute(f"--output {tmp_project_path / 'tmp/dist'}")
            build_dir = tmp_project_path / "tmp/dist"
        else:
>           tmp_tester.execute(f"--output {output_dir}")

/tmp/cirrus-ci-build/tests/console/commands/test_build.py:186: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/testers/command_tester.py:88: in execute
    self._status_code = self._command.run(self._io)
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/commands/base_command.py:117: in run
    return self.execute(io) or 0
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/commands/command.py:61: in execute
    return self.handle()
/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:55: in handle
    return self.build(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

poetry = <poetry.poetry.Poetry object at 0x192aea410130>
env = MockEnv("/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_output_option_dist_0/.venv")
io = <cleo.io.buffered_io.BufferedIO object at 0x192aea6688b0>, format = None
clean = False, local_version_label = None, output = 'dist'

    @staticmethod
    def build(
        poetry: Poetry,
        env: Env,
        io: IO,
        format: str = "all",
        clean: bool = True,
        local_version_label: str | None = None,
        output: str = "dist",
    ) -> int:
        from poetry.masonry.builders import BUILD_FORMATS
    
        if not poetry.is_package_mode:
            io.write_error_line(
                "Building a package is not possible in non-package mode."
            )
            return 1
    
        with build_environment(poetry=poetry, env=env, io=io) as env:
            dist_dir = Path(output)
            package = poetry.package
            io.write_line(
                f"Building <c1>{package.pretty_name}</c1> (<c2>{package.version}</c2>)"
            )
    
            if not dist_dir.is_absolute():
                dist_dir = poetry.pyproject_path.parent / dist_dir
    
            if clean:
                remove_directory(path=dist_dir, force=True)
    
            if format in BUILD_FORMATS:
                builders = [BUILD_FORMATS[format]]
            elif format == "all":
                builders = list(BUILD_FORMATS.values())
            else:
>               raise ValueError(f"Invalid build format: {format}")
E               ValueError: Invalid build format: None

/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:101: ValueError

Check failure on line 60 in tests/console/commands/test_build.py

See this annotation in the file changed.

@cirrus-ci cirrus-ci / Tests / FreeBSD (Python 3.10) / pytest

tests/console/commands/test_build.py#L60

tests.console.commands.test_build.test_build_format_is_not_valid
Raw output
tmp_tester = <cleo.testers.command_tester.CommandTester object at 0x192ae8022920>

    def test_build_format_is_not_valid(tmp_tester: CommandTester) -> None:
        with pytest.raises(ValueError, match=r"Invalid format.*"):
>           tmp_tester.execute("--format not_valid")

/tmp/cirrus-ci-build/tests/console/commands/test_build.py:60: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/testers/command_tester.py:88: in execute
    self._status_code = self._command.run(self._io)
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/commands/base_command.py:117: in run
    return self.execute(io) or 0
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/commands/command.py:61: in execute
    return self.handle()
/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:55: in handle
    return self.build(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

poetry = <poetry.poetry.Poetry object at 0x192aea5b9d80>
env = MockEnv("/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_format_is_not_valid0/.venv")
io = <cleo.io.buffered_io.BufferedIO object at 0x192ae80217b0>
format = 'not_valid', clean = False, local_version_label = None, output = 'dist'

    @staticmethod
    def build(
        poetry: Poetry,
        env: Env,
        io: IO,
        format: str = "all",
        clean: bool = True,
        local_version_label: str | None = None,
        output: str = "dist",
    ) -> int:
        from poetry.masonry.builders import BUILD_FORMATS
    
        if not poetry.is_package_mode:
            io.write_error_line(
                "Building a package is not possible in non-package mode."
            )
            return 1
    
        with build_environment(poetry=poetry, env=env, io=io) as env:
            dist_dir = Path(output)
            package = poetry.package
            io.write_line(
                f"Building <c1>{package.pretty_name}</c1> (<c2>{package.version}</c2>)"
            )
    
            if not dist_dir.is_absolute():
                dist_dir = poetry.pyproject_path.parent / dist_dir
    
            if clean:
                remove_directory(path=dist_dir, force=True)
    
            if format in BUILD_FORMATS:
                builders = [BUILD_FORMATS[format]]
            elif format == "all":
                builders = list(BUILD_FORMATS.values())
            else:
>               raise ValueError(f"Invalid build format: {format}")
E               ValueError: Invalid build format: not_valid

/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:101: ValueError

During handling of the above exception, another exception occurred:

tmp_tester = <cleo.testers.command_tester.CommandTester object at 0x192ae8022920>

    def test_build_format_is_not_valid(tmp_tester: CommandTester) -> None:
>       with pytest.raises(ValueError, match=r"Invalid format.*"):
E       AssertionError: Regex pattern did not match.
E        Regex: 'Invalid format.*'
E        Input: 'Invalid build format: not_valid'

/tmp/cirrus-ci-build/tests/console/commands/test_build.py:59: AssertionError

Check failure on line 114 in tests/console/commands/test_build.py

See this annotation in the file changed.

@cirrus-ci cirrus-ci / Tests / FreeBSD (Python 3.10) / pytest

tests/console/commands/test_build.py#L114

tests.console.commands.test_build.test_build_with_clean_non_existing_output
Raw output
tmp_tester = <cleo.testers.command_tester.CommandTester object at 0x192aebb77cd0>
tmp_project_path = PosixPath('/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_with_clean_non_exis0/project')
tmp_poetry = <poetry.poetry.Poetry object at 0x192aea38d780>

    def test_build_with_clean_non_existing_output(
        tmp_tester: CommandTester, tmp_project_path: Path, tmp_poetry: Poetry
    ) -> None:
        dist_dir = tmp_project_path.joinpath("dist")
    
        remove_directory(dist_dir, force=True)
        assert not dist_dir.exists()
    
>       tmp_tester.execute("--clean")

/tmp/cirrus-ci-build/tests/console/commands/test_build.py:114: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/testers/command_tester.py:88: in execute
    self._status_code = self._command.run(self._io)
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/commands/base_command.py:117: in run
    return self.execute(io) or 0
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/commands/command.py:61: in execute
    return self.handle()
/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:55: in handle
    return self.build(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

poetry = <poetry.poetry.Poetry object at 0x192aea38d780>
env = MockEnv("/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_with_clean_non_exis0/.venv")
io = <cleo.io.buffered_io.BufferedIO object at 0x192aebb775b0>, format = None
clean = True, local_version_label = None, output = 'dist'

    @staticmethod
    def build(
        poetry: Poetry,
        env: Env,
        io: IO,
        format: str = "all",
        clean: bool = True,
        local_version_label: str | None = None,
        output: str = "dist",
    ) -> int:
        from poetry.masonry.builders import BUILD_FORMATS
    
        if not poetry.is_package_mode:
            io.write_error_line(
                "Building a package is not possible in non-package mode."
            )
            return 1
    
        with build_environment(poetry=poetry, env=env, io=io) as env:
            dist_dir = Path(output)
            package = poetry.package
            io.write_line(
                f"Building <c1>{package.pretty_name}</c1> (<c2>{package.version}</c2>)"
            )
    
            if not dist_dir.is_absolute():
                dist_dir = poetry.pyproject_path.parent / dist_dir
    
            if clean:
                remove_directory(path=dist_dir, force=True)
    
            if format in BUILD_FORMATS:
                builders = [BUILD_FORMATS[format]]
            elif format == "all":
                builders = list(BUILD_FORMATS.values())
            else:
>               raise ValueError(f"Invalid build format: {format}")
E               ValueError: Invalid build format: None

/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:101: ValueError

Check failure on line 186 in tests/console/commands/test_build.py

See this annotation in the file changed.

@cirrus-ci cirrus-ci / Tests / FreeBSD (Python 3.10) / pytest

tests/console/commands/test_build.py#L186

tests.console.commands.test_build.test_build_output_option[test/dir]
Raw output
tmp_tester = <cleo.testers.command_tester.CommandTester object at 0x192aedca0820>
tmp_project_path = PosixPath('/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_output_option_test_0/project')
tmp_poetry = <poetry.poetry.Poetry object at 0x192aebc9e260>
output_dir = 'test/dir'

    @pytest.mark.parametrize(
        "output_dir", [None, "dist", "test/dir", "../dist", "absolute"]
    )
    def test_build_output_option(
        tmp_tester: CommandTester,
        tmp_project_path: Path,
        tmp_poetry: Poetry,
        output_dir: str,
    ) -> None:
        shutil.rmtree(tmp_project_path / "dist")
        if output_dir is None:
            tmp_tester.execute()
            build_dir = tmp_project_path / "dist"
        elif output_dir == "absolute":
            tmp_tester.execute(f"--output {tmp_project_path / 'tmp/dist'}")
            build_dir = tmp_project_path / "tmp/dist"
        else:
>           tmp_tester.execute(f"--output {output_dir}")

/tmp/cirrus-ci-build/tests/console/commands/test_build.py:186: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/testers/command_tester.py:88: in execute
    self._status_code = self._command.run(self._io)
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/commands/base_command.py:117: in run
    return self.execute(io) or 0
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/commands/command.py:61: in execute
    return self.handle()
/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:55: in handle
    return self.build(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

poetry = <poetry.poetry.Poetry object at 0x192aebc9e260>
env = MockEnv("/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_output_option_test_0/.venv")
io = <cleo.io.buffered_io.BufferedIO object at 0x192aedca0940>, format = None
clean = False, local_version_label = None, output = 'test/dir'

    @staticmethod
    def build(
        poetry: Poetry,
        env: Env,
        io: IO,
        format: str = "all",
        clean: bool = True,
        local_version_label: str | None = None,
        output: str = "dist",
    ) -> int:
        from poetry.masonry.builders import BUILD_FORMATS
    
        if not poetry.is_package_mode:
            io.write_error_line(
                "Building a package is not possible in non-package mode."
            )
            return 1
    
        with build_environment(poetry=poetry, env=env, io=io) as env:
            dist_dir = Path(output)
            package = poetry.package
            io.write_line(
                f"Building <c1>{package.pretty_name}</c1> (<c2>{package.version}</c2>)"
            )
    
            if not dist_dir.is_absolute():
                dist_dir = poetry.pyproject_path.parent / dist_dir
    
            if clean:
                remove_directory(path=dist_dir, force=True)
    
            if format in BUILD_FORMATS:
                builders = [BUILD_FORMATS[format]]
            elif format == "all":
                builders = list(BUILD_FORMATS.values())
            else:
>               raise ValueError(f"Invalid build format: {format}")
E               ValueError: Invalid build format: None

/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:101: ValueError

Check failure on line 99 in tests/console/commands/test_build.py

See this annotation in the file changed.

@cirrus-ci cirrus-ci / Tests / FreeBSD (Python 3.10) / pytest

tests/console/commands/test_build.py#L99

tests.console.commands.test_build.test_build_with_clean[False]
Raw output
tmp_tester = <cleo.testers.command_tester.CommandTester object at 0x192aeb9971f0>
tmp_project_path = PosixPath('/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_with_clean_False_0/project')
tmp_poetry = <poetry.poetry.Poetry object at 0x192aebb63e50>, clean = False

    @pytest.mark.parametrize("clean", [True, False])
    def test_build_with_clean(
        tmp_tester: CommandTester, tmp_project_path: Path, tmp_poetry: Poetry, clean: bool
    ) -> None:
        dist_dir = tmp_project_path.joinpath("dist")
        dist_dir.joinpath("hello").touch(exist_ok=True)
    
>       tmp_tester.execute("--clean" if clean else "")

/tmp/cirrus-ci-build/tests/console/commands/test_build.py:99: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/testers/command_tester.py:88: in execute
    self._status_code = self._command.run(self._io)
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/commands/base_command.py:117: in run
    return self.execute(io) or 0
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/commands/command.py:61: in execute
    return self.handle()
/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:55: in handle
    return self.build(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

poetry = <poetry.poetry.Poetry object at 0x192aebb63e50>
env = MockEnv("/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_with_clean_False_0/.venv")
io = <cleo.io.buffered_io.BufferedIO object at 0x192aeb997340>, format = None
clean = False, local_version_label = None, output = 'dist'

    @staticmethod
    def build(
        poetry: Poetry,
        env: Env,
        io: IO,
        format: str = "all",
        clean: bool = True,
        local_version_label: str | None = None,
        output: str = "dist",
    ) -> int:
        from poetry.masonry.builders import BUILD_FORMATS
    
        if not poetry.is_package_mode:
            io.write_error_line(
                "Building a package is not possible in non-package mode."
            )
            return 1
    
        with build_environment(poetry=poetry, env=env, io=io) as env:
            dist_dir = Path(output)
            package = poetry.package
            io.write_line(
                f"Building <c1>{package.pretty_name}</c1> (<c2>{package.version}</c2>)"
            )
    
            if not dist_dir.is_absolute():
                dist_dir = poetry.pyproject_path.parent / dist_dir
    
            if clean:
                remove_directory(path=dist_dir, force=True)
    
            if format in BUILD_FORMATS:
                builders = [BUILD_FORMATS[format]]
            elif format == "all":
                builders = list(BUILD_FORMATS.values())
            else:
>               raise ValueError(f"Invalid build format: {format}")
E               ValueError: Invalid build format: None

/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:101: ValueError

Check failure on line 183 in tests/console/commands/test_build.py

See this annotation in the file changed.

@cirrus-ci cirrus-ci / Tests / FreeBSD (Python 3.10) / pytest

tests/console/commands/test_build.py#L183

tests.console.commands.test_build.test_build_output_option[absolute]
Raw output
tmp_tester = <cleo.testers.command_tester.CommandTester object at 0x192aebc58c40>
tmp_project_path = PosixPath('/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_output_option_absol0/project')
tmp_poetry = <poetry.poetry.Poetry object at 0x192aebc5b460>
output_dir = 'absolute'

    @pytest.mark.parametrize(
        "output_dir", [None, "dist", "test/dir", "../dist", "absolute"]
    )
    def test_build_output_option(
        tmp_tester: CommandTester,
        tmp_project_path: Path,
        tmp_poetry: Poetry,
        output_dir: str,
    ) -> None:
        shutil.rmtree(tmp_project_path / "dist")
        if output_dir is None:
            tmp_tester.execute()
            build_dir = tmp_project_path / "dist"
        elif output_dir == "absolute":
>           tmp_tester.execute(f"--output {tmp_project_path / 'tmp/dist'}")

/tmp/cirrus-ci-build/tests/console/commands/test_build.py:183: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/testers/command_tester.py:88: in execute
    self._status_code = self._command.run(self._io)
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/commands/base_command.py:117: in run
    return self.execute(io) or 0
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/commands/command.py:61: in execute
    return self.handle()
/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:55: in handle
    return self.build(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

poetry = <poetry.poetry.Poetry object at 0x192aebc5b460>
env = MockEnv("/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_output_option_absol0/.venv")
io = <cleo.io.buffered_io.BufferedIO object at 0x192aebc5b190>, format = None
clean = False, local_version_label = None
output = '/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_output_option_absol0/project/tmp/dist'

    @staticmethod
    def build(
        poetry: Poetry,
        env: Env,
        io: IO,
        format: str = "all",
        clean: bool = True,
        local_version_label: str | None = None,
        output: str = "dist",
    ) -> int:
        from poetry.masonry.builders import BUILD_FORMATS
    
        if not poetry.is_package_mode:
            io.write_error_line(
                "Building a package is not possible in non-package mode."
            )
            return 1
    
        with build_environment(poetry=poetry, env=env, io=io) as env:
            dist_dir = Path(output)
            package = poetry.package
            io.write_line(
                f"Building <c1>{package.pretty_name}</c1> (<c2>{package.version}</c2>)"
            )
    
            if not dist_dir.is_absolute():
                dist_dir = poetry.pyproject_path.parent / dist_dir
    
            if clean:
                remove_directory(path=dist_dir, force=True)
    
            if format in BUILD_FORMATS:
                builders = [BUILD_FORMATS[format]]
            elif format == "all":
                builders = list(BUILD_FORMATS.values())
            else:
>               raise ValueError(f"Invalid build format: {format}")
E               ValueError: Invalid build format: None

/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:101: ValueError

Check failure on line 149 in tests/console/commands/test_build.py

See this annotation in the file changed.

@cirrus-ci cirrus-ci / Tests / FreeBSD (Python 3.10) / pytest

tests/console/commands/test_build.py#L149

tests.console.commands.test_build.test_build_with_multiple_readme_files
Raw output
fixture_dir = <function fixture_dir.<locals>._fixture_dir at 0x192ae69d3880>
tmp_path = PosixPath('/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_with_multiple_readm0')
tmp_venv = VirtualEnv("/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_with_multiple_readm0/venv")
command_tester_factory = <function command_tester_factory.<locals>._tester at 0x192aedb71750>

    def test_build_with_multiple_readme_files(
        fixture_dir: FixtureDirGetter,
        tmp_path: Path,
        tmp_venv: VirtualEnv,
        command_tester_factory: CommandTesterFactory,
    ) -> None:
        source_dir = fixture_dir("with_multiple_readme_files")
        target_dir = tmp_path / "project"
        shutil.copytree(str(source_dir), str(target_dir))
    
        poetry = Factory().create_poetry(target_dir)
        tester = command_tester_factory("build", poetry, environment=tmp_venv)
>       tester.execute()

/tmp/cirrus-ci-build/tests/console/commands/test_build.py:149: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/testers/command_tester.py:88: in execute
    self._status_code = self._command.run(self._io)
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/commands/base_command.py:117: in run
    return self.execute(io) or 0
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/commands/command.py:61: in execute
    return self.handle()
/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:55: in handle
    return self.build(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

poetry = <poetry.poetry.Poetry object at 0x192aed546aa0>
env = VirtualEnv("/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_with_multiple_readm0/venv")
io = <cleo.io.buffered_io.BufferedIO object at 0x192aed546b30>, format = None
clean = False, local_version_label = None, output = 'dist'

    @staticmethod
    def build(
        poetry: Poetry,
        env: Env,
        io: IO,
        format: str = "all",
        clean: bool = True,
        local_version_label: str | None = None,
        output: str = "dist",
    ) -> int:
        from poetry.masonry.builders import BUILD_FORMATS
    
        if not poetry.is_package_mode:
            io.write_error_line(
                "Building a package is not possible in non-package mode."
            )
            return 1
    
        with build_environment(poetry=poetry, env=env, io=io) as env:
            dist_dir = Path(output)
            package = poetry.package
            io.write_line(
                f"Building <c1>{package.pretty_name}</c1> (<c2>{package.version}</c2>)"
            )
    
            if not dist_dir.is_absolute():
                dist_dir = poetry.pyproject_path.parent / dist_dir
    
            if clean:
                remove_directory(path=dist_dir, force=True)
    
            if format in BUILD_FORMATS:
                builders = [BUILD_FORMATS[format]]
            elif format == "all":
                builders = list(BUILD_FORMATS.values())
            else:
>               raise ValueError(f"Invalid build format: {format}")
E               ValueError: Invalid build format: None

/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:101: ValueError

Check failure on line 99 in tests/console/commands/test_build.py

See this annotation in the file changed.

@cirrus-ci cirrus-ci / Tests / FreeBSD (Python 3.10) / pytest

tests/console/commands/test_build.py#L99

tests.console.commands.test_build.test_build_with_clean[True]
Raw output
tmp_tester = <cleo.testers.command_tester.CommandTester object at 0x192aece14b80>
tmp_project_path = PosixPath('/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_with_clean_True_0/project')
tmp_poetry = <poetry.poetry.Poetry object at 0x192aeda83190>, clean = True

    @pytest.mark.parametrize("clean", [True, False])
    def test_build_with_clean(
        tmp_tester: CommandTester, tmp_project_path: Path, tmp_poetry: Poetry, clean: bool
    ) -> None:
        dist_dir = tmp_project_path.joinpath("dist")
        dist_dir.joinpath("hello").touch(exist_ok=True)
    
>       tmp_tester.execute("--clean" if clean else "")

/tmp/cirrus-ci-build/tests/console/commands/test_build.py:99: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/testers/command_tester.py:88: in execute
    self._status_code = self._command.run(self._io)
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/commands/base_command.py:117: in run
    return self.execute(io) or 0
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/commands/command.py:61: in execute
    return self.handle()
/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:55: in handle
    return self.build(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

poetry = <poetry.poetry.Poetry object at 0x192aeda83190>
env = MockEnv("/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_with_clean_True_0/.venv")
io = <cleo.io.buffered_io.BufferedIO object at 0x192aece15e10>, format = None
clean = True, local_version_label = None, output = 'dist'

    @staticmethod
    def build(
        poetry: Poetry,
        env: Env,
        io: IO,
        format: str = "all",
        clean: bool = True,
        local_version_label: str | None = None,
        output: str = "dist",
    ) -> int:
        from poetry.masonry.builders import BUILD_FORMATS
    
        if not poetry.is_package_mode:
            io.write_error_line(
                "Building a package is not possible in non-package mode."
            )
            return 1
    
        with build_environment(poetry=poetry, env=env, io=io) as env:
            dist_dir = Path(output)
            package = poetry.package
            io.write_line(
                f"Building <c1>{package.pretty_name}</c1> (<c2>{package.version}</c2>)"
            )
    
            if not dist_dir.is_absolute():
                dist_dir = poetry.pyproject_path.parent / dist_dir
    
            if clean:
                remove_directory(path=dist_dir, force=True)
    
            if format in BUILD_FORMATS:
                builders = [BUILD_FORMATS[format]]
            elif format == "all":
                builders = list(BUILD_FORMATS.values())
            else:
>               raise ValueError(f"Invalid build format: {format}")
E               ValueError: Invalid build format: None

/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:101: ValueError

Check failure on line 180 in tests/console/commands/test_build.py

See this annotation in the file changed.

@cirrus-ci cirrus-ci / Tests / FreeBSD (Python 3.10) / pytest

tests/console/commands/test_build.py#L180

tests.console.commands.test_build.test_build_output_option[None]
Raw output
tmp_tester = <cleo.testers.command_tester.CommandTester object at 0x192aece967a0>
tmp_project_path = PosixPath('/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_output_option_None_0/project')
tmp_poetry = <poetry.poetry.Poetry object at 0x192aece973d0>, output_dir = None

    @pytest.mark.parametrize(
        "output_dir", [None, "dist", "test/dir", "../dist", "absolute"]
    )
    def test_build_output_option(
        tmp_tester: CommandTester,
        tmp_project_path: Path,
        tmp_poetry: Poetry,
        output_dir: str,
    ) -> None:
        shutil.rmtree(tmp_project_path / "dist")
        if output_dir is None:
>           tmp_tester.execute()

/tmp/cirrus-ci-build/tests/console/commands/test_build.py:180: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/testers/command_tester.py:88: in execute
    self._status_code = self._command.run(self._io)
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/commands/base_command.py:117: in run
    return self.execute(io) or 0
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.10/lib/python3.10/site-packages/cleo/commands/command.py:61: in execute
    return self.handle()
/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:55: in handle
    return self.build(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

poetry = <poetry.poetry.Poetry object at 0x192aece973d0>
env = MockEnv("/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_output_option_None_0/.venv")
io = <cleo.io.buffered_io.BufferedIO object at 0x192aece97580>, format = None
clean = False, local_version_label = None, output = 'dist'

    @staticmethod
    def build(
        poetry: Poetry,
        env: Env,
        io: IO,
        format: str = "all",
        clean: bool = True,
        local_version_label: str | None = None,
        output: str = "dist",
    ) -> int:
        from poetry.masonry.builders import BUILD_FORMATS
    
        if not poetry.is_package_mode:
            io.write_error_line(
                "Building a package is not possible in non-package mode."
            )
            return 1
    
        with build_environment(poetry=poetry, env=env, io=io) as env:
            dist_dir = Path(output)
            package = poetry.package
            io.write_line(
                f"Building <c1>{package.pretty_name}</c1> (<c2>{package.version}</c2>)"
            )
    
            if not dist_dir.is_absolute():
                dist_dir = poetry.pyproject_path.parent / dist_dir
    
            if clean:
                remove_directory(path=dist_dir, force=True)
    
            if format in BUILD_FORMATS:
                builders = [BUILD_FORMATS[format]]
            elif format == "all":
                builders = list(BUILD_FORMATS.values())
            else:
>               raise ValueError(f"Invalid build format: {format}")
E               ValueError: Invalid build format: None

/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:101: ValueError