@@ -615,7 +615,6 @@ def build(session):
615
615
616
616
git show -s --format=%at HEAD
617
617
"""
618
- shutil .rmtree ("dist/" , ignore_errors = True )
619
618
if SKIP_REQUIREMENTS_INSTALL is False :
620
619
requirements_file = REPO_ROOT / "requirements" / "build.txt"
621
620
session .install (
@@ -624,6 +623,22 @@ def build(session):
624
623
str (requirements_file .relative_to (REPO_ROOT )),
625
624
silent = PIP_INSTALL_SILENT ,
626
625
)
626
+
627
+ if not session .posargs :
628
+ build_path = REPO_ROOT
629
+ elif len (session .posargs ) > 1 :
630
+ session .error ("Only one argument supported, which is `examples`" )
631
+ elif session .posargs [0 ] in ("src" , "source" ):
632
+ build_path = REPO_ROOT
633
+ elif session .posargs [0 ] == "examples" :
634
+ build_path = REPO_ROOT / "examples"
635
+ else :
636
+ session .error (
637
+ f"Passing '{ session .posargs [0 ]} ' is not supported. Only one argument "
638
+ "supported, which is `examples`"
639
+ )
640
+
641
+ shutil .rmtree (build_path / "dist" , ignore_errors = True )
627
642
timestamp = session .run (
628
643
"git" ,
629
644
"show" ,
@@ -641,17 +656,19 @@ def build(session):
641
656
"build" ,
642
657
"--sdist" ,
643
658
"--wheel" ,
644
- str (REPO_ROOT ),
659
+ str (build_path ),
645
660
env = env ,
646
661
)
647
662
# Recreate sdist to be reproducible
648
663
recompress = Recompress (timestamp )
649
- for targz in REPO_ROOT .joinpath ("dist" ).glob ("*.tar.gz" ):
664
+ for targz in build_path .joinpath ("dist" ).glob ("*.tar.gz" ):
650
665
session .log ("Re-compressing %s..." , targz .relative_to (REPO_ROOT ))
651
666
recompress .recompress (targz )
652
667
653
668
sha256sum = shutil .which ("sha256sum" )
654
669
if sha256sum :
655
- packages = [str (pkg .relative_to (REPO_ROOT )) for pkg in REPO_ROOT .joinpath ("dist" ).iterdir ()]
670
+ packages = [
671
+ str (pkg .relative_to (REPO_ROOT )) for pkg in build_path .joinpath ("dist" ).iterdir ()
672
+ ]
656
673
session .run ("sha256sum" , * packages , external = True )
657
- session .run ("python" , "-m" , "twine" , "check" , "dist/*" )
674
+ session .run ("python" , "-m" , "twine" , "check" , str ( build_path / "dist" / "*" ) )
0 commit comments