Skip to content

Commit

Permalink
Don't clean dist before each package
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart committed Oct 11, 2021
1 parent 1b1883d commit 3f2f9be
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
6 changes: 5 additions & 1 deletion jupyter_releaser/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,14 +383,18 @@ def check_changelog(
def build_python(dist_dir, python_packages):
"""Build Python dist files"""
prev_dir = os.getcwd()
clean = True
for python_package in python_packages:
os.chdir(python_package)
if not util.PYPROJECT.exists() and not util.SETUP_PY.exists():
util.log(
f"Skipping build-python in {python_package} since there are no python package files"
)
else:
python.build_dist(Path(os.path.relpath(".", python_package)) / dist_dir)
python.build_dist(
Path(os.path.relpath(".", python_package)) / dist_dir, clean=clean
)
clean = False
os.chdir(prev_dir)


Expand Down
9 changes: 5 additions & 4 deletions jupyter_releaser/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@
SETUP_PY = util.SETUP_PY


def build_dist(dist_dir):
def build_dist(dist_dir, clean=True):
"""Build the python dist files into a dist folder"""
# Clean the dist folder of existing npm tarballs
os.makedirs(dist_dir, exist_ok=True)
dest = Path(dist_dir)
for pkg in glob(f"{dest}/*.gz") + glob(f"{dest}/*.whl"):
os.remove(pkg)
if clean:
for pkg in glob(f"{dest}/*.gz") + glob(f"{dest}/*.whl"):
os.remove(pkg)

if PYPROJECT.exists():
util.run(f"python -m build --outdir {dest} .", quiet=True)
util.run(f"python -m build --outdir {dest} .", quiet=True, show_cwd=True)
elif SETUP_PY.exists():
util.run(f"python setup.py sdist --dist-dir {dest}", quiet=True)
util.run(f"python setup.py bdist_wheel --dist-dir {dest}", quiet=True)
Expand Down
9 changes: 7 additions & 2 deletions jupyter_releaser/tee.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,11 @@ def tee_func(line: bytes, sink: List[str], pipe: Optional[Any]) -> None:


def run(args: Union[str, List[str]], **kwargs: Any) -> CompletedProcess:
"""Drop-in replacement for subprocerss.run that behaves like tee.
"""Drop-in replacement for subprocess.run that behaves like tee.
Extra arguments added by our version:
echo: False - Prints command before executing it.
quiet: False - Avoid printing output
show_cwd: False - Prints the current working directory.
"""
if isinstance(args, str):
cmd = args
Expand All @@ -158,7 +159,11 @@ def run(args: Union[str, List[str]], **kwargs: Any) -> CompletedProcess:
if kwargs.get("echo", False):
# This is modified from the default implementation since
# we want all output to be interleved on the same stream
print(f"COMMAND: {cmd}", file=sys.stderr)
prefix = "COMMAND"
if kwargs.get("show_cwd", False):
prefix += f" (in '{os.getcwd()}')"
prefix += ":"
print(f"{prefix} {cmd}", file=sys.stderr)

loop = asyncio.get_event_loop()
result = loop.run_until_complete(_stream_subprocess(cmd, **kwargs))
Expand Down

0 comments on commit 3f2f9be

Please sign in to comment.