Skip to content

Commit

Permalink
use build
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvanmele committed Feb 29, 2024
1 parent 74f302a commit 29185be
Showing 1 changed file with 5 additions and 49 deletions.
54 changes: 5 additions & 49 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,50 +118,6 @@ def linkcheck(ctx, rebuild=False):
ctx.run("sphinx-build {} -b linkcheck docs dist/docs".format(opts))


@invoke.task(
help={
"docs": "True to clean up generated documentation, otherwise False",
"bytecode": "True to clean up compiled python files, otherwise False.",
"builds": "True to clean up build/packaging artifacts, otherwise False.",
}
)
def clean(ctx, docs=True, bytecode=True, builds=True, ghuser=True):
"""Cleans the local copy from compiled artifacts."""

with chdir(ctx.base_folder):
if builds:
ctx.run("python setup.py clean")

if bytecode:
for root, dirs, files in os.walk(ctx.base_folder):
for f in files:
if f.endswith(".pyc"):
os.remove(os.path.join(root, f))
if ".git" in dirs:
dirs.remove(".git")

folders = []

if docs:
folders.append("docs/api/generated")

folders.append("dist/")

if bytecode:
for t in ("src", "tests"):
folders.extend(glob.glob("{}/**/__pycache__".format(t), recursive=True))

if builds:
folders.append("build/")
folders.extend(glob.glob("src/**/*.egg-info", recursive=False))

if ghuser and ctx.get("ghuser"):
folders.append(os.path.abspath(ctx.ghuser.target_dir))

for folder in folders:
shutil.rmtree(os.path.join(ctx.base_folder, folder), ignore_errors=True)


@invoke.task(help={"release_type": "Type of release follows semver rules. Must be one of: major, minor, patch."})
def release(ctx, release_type):
"""Releases the project in one swift command!"""
Expand All @@ -172,13 +128,13 @@ def release(ctx, release_type):
ctx.run("invoke format")

# Run checks
ctx.run("invoke check test")
ctx.run("invoke test")

# Bump version and git tag it
ctx.run("bump2version %s --verbose" % release_type)
ctx.run("bump-my-version bump %s --verbose" % release_type)

# Build project
ctx.run("python setup.py clean --all sdist bdist_wheel")
ctx.run("python -m build")

# Prepare the change log for the next release
prepare_changelog(ctx)
Expand Down Expand Up @@ -221,9 +177,9 @@ def prepare_changelog(ctx):
tests.test,
tests.testdocs,
tests.testcodeblocks,
build.prepare_changelog,
prepare_changelog,
clean,
build.release,
release,
build.build_ghuser_components,
)
ns.configure(
Expand Down

0 comments on commit 29185be

Please sign in to comment.