|
2 | 2 | """ |
3 | 3 |
|
4 | 4 | import argparse |
5 | | -import glob |
6 | 5 | import os |
7 | 6 | import shutil |
8 | 7 | import sys |
@@ -315,94 +314,3 @@ def prepare_release(session: nox.Session) -> None: |
315 | 314 | next_dev_version = release.get_next_development_version(version) |
316 | 315 | release.update_version_file(next_dev_version, VERSION_FILE) |
317 | 316 | release.commit_file(session, VERSION_FILE, message="Bump for development") |
318 | | - |
319 | | - |
320 | | -@nox.session(name="build-release") |
321 | | -def build_release(session: nox.Session) -> None: |
322 | | - version = release.get_version_from_arguments(session) |
323 | | - if not version: |
324 | | - session.error("Usage: nox -s build-release -- YY.N[.P]") |
325 | | - |
326 | | - session.log("# Ensure no files in dist/") |
327 | | - if release.have_files_in_folder("dist"): |
328 | | - session.error( |
329 | | - "There are files in dist/. Remove them and try again. " |
330 | | - "You can use `git clean -fxdi -- dist` command to do this" |
331 | | - ) |
332 | | - |
333 | | - session.log("# Install dependencies") |
334 | | - session.install("build", "twine") |
335 | | - |
336 | | - with release.isolated_temporary_checkout(session, version) as build_dir: |
337 | | - session.log( |
338 | | - "# Start the build in an isolated, " |
339 | | - f"temporary Git checkout at {build_dir!s}", |
340 | | - ) |
341 | | - with release.workdir(session, build_dir): |
342 | | - tmp_dists = build_dists(session) |
343 | | - |
344 | | - tmp_dist_paths = (build_dir / p for p in tmp_dists) |
345 | | - session.log(f"# Copying dists from {build_dir}") |
346 | | - os.makedirs("dist", exist_ok=True) |
347 | | - for dist, final in zip(tmp_dist_paths, tmp_dists): |
348 | | - session.log(f"# Copying {dist} to {final}") |
349 | | - shutil.copy(dist, final) |
350 | | - |
351 | | - |
352 | | -def build_dists(session: nox.Session) -> List[str]: |
353 | | - """Return dists with valid metadata.""" |
354 | | - session.log( |
355 | | - "# Check if there's any Git-untracked files before building the wheel", |
356 | | - ) |
357 | | - |
358 | | - has_forbidden_git_untracked_files = any( |
359 | | - # Don't report the environment this session is running in |
360 | | - not untracked_file.startswith(".nox/build-release/") |
361 | | - for untracked_file in release.get_git_untracked_files() |
362 | | - ) |
363 | | - if has_forbidden_git_untracked_files: |
364 | | - session.error( |
365 | | - "There are untracked files in the working directory. " |
366 | | - "Remove them and try again", |
367 | | - ) |
368 | | - |
369 | | - session.log("# Build distributions") |
370 | | - session.run("python", "-m", "build", silent=True) |
371 | | - produced_dists = glob.glob("dist/*") |
372 | | - |
373 | | - session.log(f"# Verify distributions: {', '.join(produced_dists)}") |
374 | | - session.run("twine", "check", *produced_dists, silent=True) |
375 | | - |
376 | | - return produced_dists |
377 | | - |
378 | | - |
379 | | -@nox.session(name="upload-release") |
380 | | -def upload_release(session: nox.Session) -> None: |
381 | | - version = release.get_version_from_arguments(session) |
382 | | - if not version: |
383 | | - session.error("Usage: nox -s upload-release -- YY.N[.P]") |
384 | | - |
385 | | - session.log("# Install dependencies") |
386 | | - session.install("twine") |
387 | | - |
388 | | - distribution_files = glob.glob("dist/*") |
389 | | - session.log(f"# Distribution files: {distribution_files}") |
390 | | - |
391 | | - # Sanity check: Make sure there's 2 distribution files. |
392 | | - count = len(distribution_files) |
393 | | - if count != 2: |
394 | | - session.error( |
395 | | - f"Expected 2 distribution files for upload, got {count}. " |
396 | | - f"Remove dist/ and run 'nox -s build-release -- {version}'" |
397 | | - ) |
398 | | - # Sanity check: Make sure the files are correctly named. |
399 | | - distfile_names = (os.path.basename(fn) for fn in distribution_files) |
400 | | - expected_distribution_files = [ |
401 | | - f"pip-{version}-py3-none-any.whl", |
402 | | - f"pip-{version}.tar.gz", |
403 | | - ] |
404 | | - if sorted(distfile_names) != sorted(expected_distribution_files): |
405 | | - session.error(f"Distribution files do not seem to be for {version} release.") |
406 | | - |
407 | | - session.log("# Upload distributions") |
408 | | - session.run("twine", "upload", *distribution_files) |
0 commit comments