We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Allow specifying output directory in pyodide build with -o or --outdir
I added the capability to specify output directory in pyodide build with `--output-directory`. But here `pypa/build` accepts either `--outdir` or `-o`. We should accept these as ways to specify the output directory for consistency

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pyodide-build/pyodide_build/cli/build.py`
Content:
```
1 import re
2 import shutil
3 import tempfile
4 from pathlib import Path
5 from typing import Optional
6 from urllib.parse import urlparse
7 
8 import requests
9 import typer
10 
11 from .. import common
12 from ..out_of_tree import build
13 from ..out_of_tree.pypi import (
14     build_dependencies_for_wheel,
15     build_wheels_from_pypi_requirements,
16     fetch_pypi_package,
17 )
18 from ..out_of_tree.utils import initialize_pyodide_root
19 
20 
21 def pypi(
22     package: str,
23     output_directory: Path,
24     exports: str = typer.Option(
25         "requested",
26         help="Which symbols should be exported when linking .so files?",
27     ),
28     ctx: typer.Context = typer.Context,
29 ) -> Path:
30     """Fetch a wheel from pypi, or build from source if none available."""
31     initialize_pyodide_root()
32     common.check_emscripten_version()
33     backend_flags = ctx.args
34     with tempfile.TemporaryDirectory() as tmpdir:
35         srcdir = Path(tmpdir)
36 
37         # get package from pypi
38         package_path = fetch_pypi_package(package, srcdir)
39         if not package_path.is_dir():
40             # a pure-python wheel has been downloaded - just copy to dist folder
41             dest_file = output_directory / package_path.name
42             shutil.copyfile(str(package_path), output_directory / package_path.name)
43             print(f"Successfully fetched: {package_path.name}")
44             return dest_file
45 
46         built_wheel = build.run(srcdir, output_directory, exports, backend_flags)
47         return built_wheel
48 
49 
50 def download_url(url: str, output_directory: Path) -> str:
51     with requests.get(url, stream=True) as response:
52         urlpath = Path(urlparse(response.url).path)
53         if urlpath.suffix == ".gz":
54             urlpath = urlpath.with_suffix("")
55         file_name = urlpath.name
56         with open(output_directory / file_name, "wb") as f:
57             for chunk in response.iter_content(chunk_size=1 << 20):
58                 f.write(chunk)
59         return file_name
60 
61 
62 def url(
63     package_url: str,
64     output_directory: Path,
65     exports: str = typer.Option(
66         "requested",
67         help="Which symbols should be exported when linking .so files?",
68     ),
69     ctx: typer.Context = typer.Context,
70 ) -> Path:
71     """Fetch a wheel or build sdist from url."""
72     initialize_pyodide_root()
73     common.check_emscripten_version()
74     backend_flags = ctx.args
75     with tempfile.TemporaryDirectory() as tmpdir:
76         tmppath = Path(tmpdir)
77         filename = download_url(package_url, tmppath)
78         if Path(filename).suffix == ".whl":
79             shutil.move(tmppath / filename, output_directory / filename)
80             return output_directory / filename
81 
82         builddir = tmppath / "build"
83         shutil.unpack_archive(tmppath / filename, builddir)
84         files = list(builddir.iterdir())
85         if len(files) == 1 and files[0].is_dir():
86             # unzipped into subfolder
87             builddir = files[0]
88         wheel_path = build.run(builddir, output_directory, exports, backend_flags)
89         return wheel_path
90 
91 
92 def source(
93     source_location: Path,
94     output_directory: Path,
95     exports: str = typer.Option(
96         "requested",
97         help="Which symbols should be exported when linking .so files?",
98     ),
99     ctx: typer.Context = typer.Context,
100 ) -> Path:
101     """Use pypa/build to build a Python package from source"""
102     initialize_pyodide_root()
103     common.check_emscripten_version()
104     backend_flags = ctx.args
105     built_wheel = build.run(source_location, output_directory, exports, backend_flags)
106     return built_wheel
107 
108 
109 # simple 'pyodide build' command
110 def main(
111     source_location: "Optional[str]" = typer.Argument(
112         "",
113         help="Build source, can be source folder, pypi version specification, or url to a source dist archive or wheel file. If this is blank, it will build the current directory.",
114     ),
115     output_directory: str = typer.Option(
116         "./dist",
117         help="which directory should the output be placed into?",
118     ),
119     requirements_txt: str = typer.Option(
120         "",
121         "--requirements",
122         "-r",
123         help="Build a list of package requirements from a requirements.txt file",
124     ),
125     exports: str = typer.Option(
126         "requested",
127         help="Which symbols should be exported when linking .so files?",
128     ),
129     build_dependencies: bool = typer.Option(
130         False, help="Fetch non-pyodide dependencies from pypi and build them too."
131     ),
132     output_lockfile: str = typer.Option(
133         "",
134         help="Output list of resolved dependencies to a file in requirements.txt format",
135     ),
136     skip_dependency: list[str] = typer.Option(
137         [],
138         help="Skip building or resolving a single dependency. Use multiple times or provide a comma separated list to skip multiple dependencies.",
139     ),
140     compression_level: int = typer.Option(
141         6, help="Compression level to use for the created zip file"
142     ),
143     ctx: typer.Context = typer.Context,
144 ) -> None:
145     """Use pypa/build to build a Python package from source, pypi or url."""
146     outpath = Path(output_directory).resolve()
147     outpath.mkdir(exist_ok=True)
148     extras: list[str] = []
149 
150     if len(requirements_txt) > 0:
151         # a requirements.txt - build it (and optionally deps)
152         if not Path(requirements_txt).exists():
153             raise RuntimeError(
154                 f"Couldn't find requirements text file {requirements_txt}"
155             )
156         reqs = []
157         with open(requirements_txt) as f:
158             raw_reqs = [x.strip() for x in f.readlines()]
159         for x in raw_reqs:
160             # remove comments
161             comment_pos = x.find("#")
162             if comment_pos != -1:
163                 x = x[:comment_pos].strip()
164             if len(x) > 0:
165                 if x[0] == "-":
166                     raise RuntimeError(
167                         f"pyodide build only supports name-based PEP508 requirements. [{x}] will not work."
168                     )
169                 if x.find("@") != -1:
170                     raise RuntimeError(
171                         f"pyodide build does not support URL based requirements. [{x}] will not work"
172                     )
173                 reqs.append(x)
174         try:
175             build_wheels_from_pypi_requirements(
176                 reqs,
177                 outpath,
178                 build_dependencies,
179                 skip_dependency,
180                 exports,
181                 ctx.args,
182                 output_lockfile=output_lockfile,
183             )
184         except BaseException as e:
185             import traceback
186 
187             print("Failed building multiple wheels:", traceback.format_exc())
188             raise e
189         return
190 
191     if source_location is not None:
192         extras = re.findall(r"\[(\w+)\]", source_location)
193         if len(extras) != 0:
194             source_location = source_location[0 : source_location.find("[")]
195     if not source_location:
196         # build the current folder
197         wheel = source(Path.cwd(), outpath, exports, ctx)
198     elif source_location.find("://") != -1:
199         wheel = url(source_location, outpath, exports, ctx)
200     elif Path(source_location).is_dir():
201         # a folder, build it
202         wheel = source(Path(source_location).resolve(), outpath, exports, ctx)
203     elif source_location.find("/") == -1:
204         # try fetch or build from pypi
205         wheel = pypi(source_location, outpath, exports, ctx)
206     else:
207         raise RuntimeError(f"Couldn't determine source type for {source_location}")
208     # now build deps for wheel
209     if build_dependencies:
210         try:
211             build_dependencies_for_wheel(
212                 wheel,
213                 extras,
214                 skip_dependency,
215                 exports,
216                 ctx.args,
217                 output_lockfile=output_lockfile,
218                 compression_level=compression_level,
219             )
220         except BaseException as e:
221             import traceback
222 
223             print("Failed building dependencies for wheel:", traceback.format_exc())
224             wheel.unlink()
225             raise e
226 
227 
228 main.typer_kwargs = {  # type: ignore[attr-defined]
229     "context_settings": {
230         "ignore_unknown_options": True,
231         "allow_extra_args": True,
232     },
233 }
234
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/pyodide-build/pyodide_build/cli/build.py b/pyodide-build/pyodide_build/cli/build.py
--- a/pyodide-build/pyodide_build/cli/build.py
+++ b/pyodide-build/pyodide_build/cli/build.py
@@ -1,5 +1,6 @@
 import re
 import shutil
+import sys
 import tempfile
 from pathlib import Path
 from typing import Optional
@@ -113,9 +114,12 @@
         help="Build source, can be source folder, pypi version specification, or url to a source dist archive or wheel file. If this is blank, it will build the current directory.",
     ),
     output_directory: str = typer.Option(
-        "./dist",
+        "",
+        "--outdir",
+        "-o",
         help="which directory should the output be placed into?",
     ),
+    output_directory_compat: str = typer.Option("", "--output-directory", hidden=True),
     requirements_txt: str = typer.Option(
         "",
         "--requirements",
@@ -143,6 +147,16 @@
     ctx: typer.Context = typer.Context,
 ) -> None:
     """Use pypa/build to build a Python package from source, pypi or url."""
+    if output_directory_compat:
+        print(
+            "--output-directory is deprecated, use --outdir or -o instead",
+            file=sys.stderr,
+        )
+    if output_directory_compat and output_directory:
+        print("Cannot provide both --outdir and --output-directory", file=sys.stderr)
+        sys.exit(1)
+    output_directory = output_directory_compat or output_directory or "./dist"
+
     outpath = Path(output_directory).resolve()
     outpath.mkdir(exist_ok=True)
     extras: list[str] = []

{"golden_diff": "diff --git a/pyodide-build/pyodide_build/cli/build.py b/pyodide-build/pyodide_build/cli/build.py\n--- a/pyodide-build/pyodide_build/cli/build.py\n+++ b/pyodide-build/pyodide_build/cli/build.py\n@@ -1,5 +1,6 @@\n import re\n import shutil\n+import sys\n import tempfile\n from pathlib import Path\n from typing import Optional\n@@ -113,9 +114,12 @@\n         help=\"Build source, can be source folder, pypi version specification, or url to a source dist archive or wheel file. If this is blank, it will build the current directory.\",\n     ),\n     output_directory: str = typer.Option(\n-        \"./dist\",\n+        \"\",\n+        \"--outdir\",\n+        \"-o\",\n         help=\"which directory should the output be placed into?\",\n     ),\n+    output_directory_compat: str = typer.Option(\"\", \"--output-directory\", hidden=True),\n     requirements_txt: str = typer.Option(\n         \"\",\n         \"--requirements\",\n@@ -143,6 +147,16 @@\n     ctx: typer.Context = typer.Context,\n ) -> None:\n     \"\"\"Use pypa/build to build a Python package from source, pypi or url.\"\"\"\n+    if output_directory_compat:\n+        print(\n+            \"--output-directory is deprecated, use --outdir or -o instead\",\n+            file=sys.stderr,\n+        )\n+    if output_directory_compat and output_directory:\n+        print(\"Cannot provide both --outdir and --output-directory\", file=sys.stderr)\n+        sys.exit(1)\n+    output_directory = output_directory_compat or output_directory or \"./dist\"\n+\n     outpath = Path(output_directory).resolve()\n     outpath.mkdir(exist_ok=True)\n     extras: list[str] = []\n", "issue": "Allow specifying output directory in pyodide build with -o or --outdir\nI added the capability to specify output directory in pyodide build with `--output-directory`. But here `pypa/build` accepts either `--outdir` or `-o`. We should accept these as ways to specify the output directory for consistency\n", "before_files": [{"content": "import re\nimport shutil\nimport tempfile\nfrom pathlib import Path\nfrom typing import Optional\nfrom urllib.parse import urlparse\n\nimport requests\nimport typer\n\nfrom .. import common\nfrom ..out_of_tree import build\nfrom ..out_of_tree.pypi import (\n    build_dependencies_for_wheel,\n    build_wheels_from_pypi_requirements,\n    fetch_pypi_package,\n)\nfrom ..out_of_tree.utils import initialize_pyodide_root\n\n\ndef pypi(\n    package: str,\n    output_directory: Path,\n    exports: str = typer.Option(\n        \"requested\",\n        help=\"Which symbols should be exported when linking .so files?\",\n    ),\n    ctx: typer.Context = typer.Context,\n) -> Path:\n    \"\"\"Fetch a wheel from pypi, or build from source if none available.\"\"\"\n    initialize_pyodide_root()\n    common.check_emscripten_version()\n    backend_flags = ctx.args\n    with tempfile.TemporaryDirectory() as tmpdir:\n        srcdir = Path(tmpdir)\n\n        # get package from pypi\n        package_path = fetch_pypi_package(package, srcdir)\n        if not package_path.is_dir():\n            # a pure-python wheel has been downloaded - just copy to dist folder\n            dest_file = output_directory / package_path.name\n            shutil.copyfile(str(package_path), output_directory / package_path.name)\n            print(f\"Successfully fetched: {package_path.name}\")\n            return dest_file\n\n        built_wheel = build.run(srcdir, output_directory, exports, backend_flags)\n        return built_wheel\n\n\ndef download_url(url: str, output_directory: Path) -> str:\n    with requests.get(url, stream=True) as response:\n        urlpath = Path(urlparse(response.url).path)\n        if urlpath.suffix == \".gz\":\n            urlpath = urlpath.with_suffix(\"\")\n        file_name = urlpath.name\n        with open(output_directory / file_name, \"wb\") as f:\n            for chunk in response.iter_content(chunk_size=1 << 20):\n                f.write(chunk)\n        return file_name\n\n\ndef url(\n    package_url: str,\n    output_directory: Path,\n    exports: str = typer.Option(\n        \"requested\",\n        help=\"Which symbols should be exported when linking .so files?\",\n    ),\n    ctx: typer.Context = typer.Context,\n) -> Path:\n    \"\"\"Fetch a wheel or build sdist from url.\"\"\"\n    initialize_pyodide_root()\n    common.check_emscripten_version()\n    backend_flags = ctx.args\n    with tempfile.TemporaryDirectory() as tmpdir:\n        tmppath = Path(tmpdir)\n        filename = download_url(package_url, tmppath)\n        if Path(filename).suffix == \".whl\":\n            shutil.move(tmppath / filename, output_directory / filename)\n            return output_directory / filename\n\n        builddir = tmppath / \"build\"\n        shutil.unpack_archive(tmppath / filename, builddir)\n        files = list(builddir.iterdir())\n        if len(files) == 1 and files[0].is_dir():\n            # unzipped into subfolder\n            builddir = files[0]\n        wheel_path = build.run(builddir, output_directory, exports, backend_flags)\n        return wheel_path\n\n\ndef source(\n    source_location: Path,\n    output_directory: Path,\n    exports: str = typer.Option(\n        \"requested\",\n        help=\"Which symbols should be exported when linking .so files?\",\n    ),\n    ctx: typer.Context = typer.Context,\n) -> Path:\n    \"\"\"Use pypa/build to build a Python package from source\"\"\"\n    initialize_pyodide_root()\n    common.check_emscripten_version()\n    backend_flags = ctx.args\n    built_wheel = build.run(source_location, output_directory, exports, backend_flags)\n    return built_wheel\n\n\n# simple 'pyodide build' command\ndef main(\n    source_location: \"Optional[str]\" = typer.Argument(\n        \"\",\n        help=\"Build source, can be source folder, pypi version specification, or url to a source dist archive or wheel file. If this is blank, it will build the current directory.\",\n    ),\n    output_directory: str = typer.Option(\n        \"./dist\",\n        help=\"which directory should the output be placed into?\",\n    ),\n    requirements_txt: str = typer.Option(\n        \"\",\n        \"--requirements\",\n        \"-r\",\n        help=\"Build a list of package requirements from a requirements.txt file\",\n    ),\n    exports: str = typer.Option(\n        \"requested\",\n        help=\"Which symbols should be exported when linking .so files?\",\n    ),\n    build_dependencies: bool = typer.Option(\n        False, help=\"Fetch non-pyodide dependencies from pypi and build them too.\"\n    ),\n    output_lockfile: str = typer.Option(\n        \"\",\n        help=\"Output list of resolved dependencies to a file in requirements.txt format\",\n    ),\n    skip_dependency: list[str] = typer.Option(\n        [],\n        help=\"Skip building or resolving a single dependency. Use multiple times or provide a comma separated list to skip multiple dependencies.\",\n    ),\n    compression_level: int = typer.Option(\n        6, help=\"Compression level to use for the created zip file\"\n    ),\n    ctx: typer.Context = typer.Context,\n) -> None:\n    \"\"\"Use pypa/build to build a Python package from source, pypi or url.\"\"\"\n    outpath = Path(output_directory).resolve()\n    outpath.mkdir(exist_ok=True)\n    extras: list[str] = []\n\n    if len(requirements_txt) > 0:\n        # a requirements.txt - build it (and optionally deps)\n        if not Path(requirements_txt).exists():\n            raise RuntimeError(\n                f\"Couldn't find requirements text file {requirements_txt}\"\n            )\n        reqs = []\n        with open(requirements_txt) as f:\n            raw_reqs = [x.strip() for x in f.readlines()]\n        for x in raw_reqs:\n            # remove comments\n            comment_pos = x.find(\"#\")\n            if comment_pos != -1:\n                x = x[:comment_pos].strip()\n            if len(x) > 0:\n                if x[0] == \"-\":\n                    raise RuntimeError(\n                        f\"pyodide build only supports name-based PEP508 requirements. [{x}] will not work.\"\n                    )\n                if x.find(\"@\") != -1:\n                    raise RuntimeError(\n                        f\"pyodide build does not support URL based requirements. [{x}] will not work\"\n                    )\n                reqs.append(x)\n        try:\n            build_wheels_from_pypi_requirements(\n                reqs,\n                outpath,\n                build_dependencies,\n                skip_dependency,\n                exports,\n                ctx.args,\n                output_lockfile=output_lockfile,\n            )\n        except BaseException as e:\n            import traceback\n\n            print(\"Failed building multiple wheels:\", traceback.format_exc())\n            raise e\n        return\n\n    if source_location is not None:\n        extras = re.findall(r\"\\[(\\w+)\\]\", source_location)\n        if len(extras) != 0:\n            source_location = source_location[0 : source_location.find(\"[\")]\n    if not source_location:\n        # build the current folder\n        wheel = source(Path.cwd(), outpath, exports, ctx)\n    elif source_location.find(\"://\") != -1:\n        wheel = url(source_location, outpath, exports, ctx)\n    elif Path(source_location).is_dir():\n        # a folder, build it\n        wheel = source(Path(source_location).resolve(), outpath, exports, ctx)\n    elif source_location.find(\"/\") == -1:\n        # try fetch or build from pypi\n        wheel = pypi(source_location, outpath, exports, ctx)\n    else:\n        raise RuntimeError(f\"Couldn't determine source type for {source_location}\")\n    # now build deps for wheel\n    if build_dependencies:\n        try:\n            build_dependencies_for_wheel(\n                wheel,\n                extras,\n                skip_dependency,\n                exports,\n                ctx.args,\n                output_lockfile=output_lockfile,\n                compression_level=compression_level,\n            )\n        except BaseException as e:\n            import traceback\n\n            print(\"Failed building dependencies for wheel:\", traceback.format_exc())\n            wheel.unlink()\n            raise e\n\n\nmain.typer_kwargs = {  # type: ignore[attr-defined]\n    \"context_settings\": {\n        \"ignore_unknown_options\": True,\n        \"allow_extra_args\": True,\n    },\n}\n", "path": "pyodide-build/pyodide_build/cli/build.py"}], "after_files": [{"content": "import re\nimport shutil\nimport sys\nimport tempfile\nfrom pathlib import Path\nfrom typing import Optional\nfrom urllib.parse import urlparse\n\nimport requests\nimport typer\n\nfrom .. import common\nfrom ..out_of_tree import build\nfrom ..out_of_tree.pypi import (\n    build_dependencies_for_wheel,\n    build_wheels_from_pypi_requirements,\n    fetch_pypi_package,\n)\nfrom ..out_of_tree.utils import initialize_pyodide_root\n\n\ndef pypi(\n    package: str,\n    output_directory: Path,\n    exports: str = typer.Option(\n        \"requested\",\n        help=\"Which symbols should be exported when linking .so files?\",\n    ),\n    ctx: typer.Context = typer.Context,\n) -> Path:\n    \"\"\"Fetch a wheel from pypi, or build from source if none available.\"\"\"\n    initialize_pyodide_root()\n    common.check_emscripten_version()\n    backend_flags = ctx.args\n    with tempfile.TemporaryDirectory() as tmpdir:\n        srcdir = Path(tmpdir)\n\n        # get package from pypi\n        package_path = fetch_pypi_package(package, srcdir)\n        if not package_path.is_dir():\n            # a pure-python wheel has been downloaded - just copy to dist folder\n            dest_file = output_directory / package_path.name\n            shutil.copyfile(str(package_path), output_directory / package_path.name)\n            print(f\"Successfully fetched: {package_path.name}\")\n            return dest_file\n\n        built_wheel = build.run(srcdir, output_directory, exports, backend_flags)\n        return built_wheel\n\n\ndef download_url(url: str, output_directory: Path) -> str:\n    with requests.get(url, stream=True) as response:\n        urlpath = Path(urlparse(response.url).path)\n        if urlpath.suffix == \".gz\":\n            urlpath = urlpath.with_suffix(\"\")\n        file_name = urlpath.name\n        with open(output_directory / file_name, \"wb\") as f:\n            for chunk in response.iter_content(chunk_size=1 << 20):\n                f.write(chunk)\n        return file_name\n\n\ndef url(\n    package_url: str,\n    output_directory: Path,\n    exports: str = typer.Option(\n        \"requested\",\n        help=\"Which symbols should be exported when linking .so files?\",\n    ),\n    ctx: typer.Context = typer.Context,\n) -> Path:\n    \"\"\"Fetch a wheel or build sdist from url.\"\"\"\n    initialize_pyodide_root()\n    common.check_emscripten_version()\n    backend_flags = ctx.args\n    with tempfile.TemporaryDirectory() as tmpdir:\n        tmppath = Path(tmpdir)\n        filename = download_url(package_url, tmppath)\n        if Path(filename).suffix == \".whl\":\n            shutil.move(tmppath / filename, output_directory / filename)\n            return output_directory / filename\n\n        builddir = tmppath / \"build\"\n        shutil.unpack_archive(tmppath / filename, builddir)\n        files = list(builddir.iterdir())\n        if len(files) == 1 and files[0].is_dir():\n            # unzipped into subfolder\n            builddir = files[0]\n        wheel_path = build.run(builddir, output_directory, exports, backend_flags)\n        return wheel_path\n\n\ndef source(\n    source_location: Path,\n    output_directory: Path,\n    exports: str = typer.Option(\n        \"requested\",\n        help=\"Which symbols should be exported when linking .so files?\",\n    ),\n    ctx: typer.Context = typer.Context,\n) -> Path:\n    \"\"\"Use pypa/build to build a Python package from source\"\"\"\n    initialize_pyodide_root()\n    common.check_emscripten_version()\n    backend_flags = ctx.args\n    built_wheel = build.run(source_location, output_directory, exports, backend_flags)\n    return built_wheel\n\n\n# simple 'pyodide build' command\ndef main(\n    source_location: \"Optional[str]\" = typer.Argument(\n        \"\",\n        help=\"Build source, can be source folder, pypi version specification, or url to a source dist archive or wheel file. If this is blank, it will build the current directory.\",\n    ),\n    output_directory: str = typer.Option(\n        \"\",\n        \"--outdir\",\n        \"-o\",\n        help=\"which directory should the output be placed into?\",\n    ),\n    output_directory_compat: str = typer.Option(\"\", \"--output-directory\", hidden=True),\n    requirements_txt: str = typer.Option(\n        \"\",\n        \"--requirements\",\n        \"-r\",\n        help=\"Build a list of package requirements from a requirements.txt file\",\n    ),\n    exports: str = typer.Option(\n        \"requested\",\n        help=\"Which symbols should be exported when linking .so files?\",\n    ),\n    build_dependencies: bool = typer.Option(\n        False, help=\"Fetch non-pyodide dependencies from pypi and build them too.\"\n    ),\n    output_lockfile: str = typer.Option(\n        \"\",\n        help=\"Output list of resolved dependencies to a file in requirements.txt format\",\n    ),\n    skip_dependency: list[str] = typer.Option(\n        [],\n        help=\"Skip building or resolving a single dependency. Use multiple times or provide a comma separated list to skip multiple dependencies.\",\n    ),\n    compression_level: int = typer.Option(\n        6, help=\"Compression level to use for the created zip file\"\n    ),\n    ctx: typer.Context = typer.Context,\n) -> None:\n    \"\"\"Use pypa/build to build a Python package from source, pypi or url.\"\"\"\n    if output_directory_compat:\n        print(\n            \"--output-directory is deprecated, use --outdir or -o instead\",\n            file=sys.stderr,\n        )\n    if output_directory_compat and output_directory:\n        print(\"Cannot provide both --outdir and --output-directory\", file=sys.stderr)\n        sys.exit(1)\n    output_directory = output_directory_compat or output_directory or \"./dist\"\n\n    outpath = Path(output_directory).resolve()\n    outpath.mkdir(exist_ok=True)\n    extras: list[str] = []\n\n    if len(requirements_txt) > 0:\n        # a requirements.txt - build it (and optionally deps)\n        if not Path(requirements_txt).exists():\n            raise RuntimeError(\n                f\"Couldn't find requirements text file {requirements_txt}\"\n            )\n        reqs = []\n        with open(requirements_txt) as f:\n            raw_reqs = [x.strip() for x in f.readlines()]\n        for x in raw_reqs:\n            # remove comments\n            comment_pos = x.find(\"#\")\n            if comment_pos != -1:\n                x = x[:comment_pos].strip()\n            if len(x) > 0:\n                if x[0] == \"-\":\n                    raise RuntimeError(\n                        f\"pyodide build only supports name-based PEP508 requirements. [{x}] will not work.\"\n                    )\n                if x.find(\"@\") != -1:\n                    raise RuntimeError(\n                        f\"pyodide build does not support URL based requirements. [{x}] will not work\"\n                    )\n                reqs.append(x)\n        try:\n            build_wheels_from_pypi_requirements(\n                reqs,\n                outpath,\n                build_dependencies,\n                skip_dependency,\n                exports,\n                ctx.args,\n                output_lockfile=output_lockfile,\n            )\n        except BaseException as e:\n            import traceback\n\n            print(\"Failed building multiple wheels:\", traceback.format_exc())\n            raise e\n        return\n\n    if source_location is not None:\n        extras = re.findall(r\"\\[(\\w+)\\]\", source_location)\n        if len(extras) != 0:\n            source_location = source_location[0 : source_location.find(\"[\")]\n    if not source_location:\n        # build the current folder\n        wheel = source(Path.cwd(), outpath, exports, ctx)\n    elif source_location.find(\"://\") != -1:\n        wheel = url(source_location, outpath, exports, ctx)\n    elif Path(source_location).is_dir():\n        # a folder, build it\n        wheel = source(Path(source_location).resolve(), outpath, exports, ctx)\n    elif source_location.find(\"/\") == -1:\n        # try fetch or build from pypi\n        wheel = pypi(source_location, outpath, exports, ctx)\n    else:\n        raise RuntimeError(f\"Couldn't determine source type for {source_location}\")\n    # now build deps for wheel\n    if build_dependencies:\n        try:\n            build_dependencies_for_wheel(\n                wheel,\n                extras,\n                skip_dependency,\n                exports,\n                ctx.args,\n                output_lockfile=output_lockfile,\n                compression_level=compression_level,\n            )\n        except BaseException as e:\n            import traceback\n\n            print(\"Failed building dependencies for wheel:\", traceback.format_exc())\n            wheel.unlink()\n            raise e\n\n\nmain.typer_kwargs = {  # type: ignore[attr-defined]\n    \"context_settings\": {\n        \"ignore_unknown_options\": True,\n        \"allow_extra_args\": True,\n    },\n}\n", "path": "pyodide-build/pyodide_build/cli/build.py"}]}