-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This can be useful for testing purposes. Signed-off-by: Stephen Finucane <stephen@that.guru>
- Loading branch information
1 parent
5a4f523
commit 2157f48
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import argparse | ||
import os | ||
import pathlib | ||
import sys | ||
|
||
from ._frontend import SdistResult, WheelResult | ||
from ._via_fresh_subprocess import SubprocessFrontend | ||
|
||
|
||
def main_parser() -> argparse.ArgumentParser: | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
"srcdir", | ||
type=pathlib.Path, | ||
nargs="?", | ||
default=pathlib.Path(os.getcwd()), | ||
help="source directory (defaults to current directory)", | ||
) | ||
parser.add_argument( | ||
"--sdist", | ||
"-s", | ||
dest="distributions", | ||
action="append_const", | ||
const="sdist", | ||
default=[], | ||
help="build a source distribution", | ||
) | ||
parser.add_argument( | ||
"--wheel", | ||
"-w", | ||
dest="distributions", | ||
action="append_const", | ||
const="wheel", | ||
help="build a wheel distribution", | ||
) | ||
parser.add_argument( | ||
"--outdir", | ||
"-o", | ||
type=pathlib.Path, | ||
help=f"output directory (defaults to {{srcdir}}{os.sep}dist)", | ||
) | ||
return parser | ||
|
||
|
||
def build(argv: list[str]) -> None: | ||
parser = main_parser() | ||
args = parser.parse_args(argv) | ||
|
||
outdir = args.outdir or args.srcdir / "dist" | ||
distributions = args.distributions or ["sdist", "wheel"] | ||
|
||
frontend = SubprocessFrontend(*SubprocessFrontend.create_args_from_folder(args.srcdir)[:-1]) | ||
res: SdistResult | WheelResult | ||
|
||
if "sdist" in distributions: | ||
print("Building sdist...") | ||
res = frontend.build_sdist(sdist_directory=outdir) | ||
print(res.out) | ||
print(res.err) | ||
|
||
if "wheel" in distributions: | ||
print("Building wheel...") | ||
res = frontend.build_wheel(outdir) | ||
print(res.out) | ||
print(res.err) | ||
|
||
|
||
if __name__ == "__main__": | ||
build(sys.argv[1:]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters