annotate garcon/pypi.py @ 1145:e94737572542

serve: Fix an issue where false positive matches were rendered as the requested page. Now we try to render the page, but also try to detect for the most common "empty" pages.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 05 Jun 2018 22:08:51 -0700
parents a013a3bea22a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1070
a013a3bea22a cm: Upgrade release script.
Ludovic Chabant <ludovic@chabant.com>
parents: 1005
diff changeset
1 import os.path
992
bd269692dbb4 cm: Make the release script commit changed FoodTruck assets if needed.
Ludovic Chabant <ludovic@chabant.com>
parents: 742
diff changeset
2 import re
1070
a013a3bea22a cm: Upgrade release script.
Ludovic Chabant <ludovic@chabant.com>
parents: 1005
diff changeset
3 import shutil
642
79aefe82c6b6 cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
4 from invoke import task, run
79aefe82c6b6 cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
5
79aefe82c6b6 cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
6
79aefe82c6b6 cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
7 @task
990
22cf13b86cc3 cm: Upgrade Garcon tasks to the latest PyInvoke version.
Ludovic Chabant <ludovic@chabant.com>
parents: 742
diff changeset
8 def makerelease(ctx, version, local_only=False):
642
79aefe82c6b6 cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
9 if not version:
79aefe82c6b6 cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
10 raise Exception("You must specify a version!")
79aefe82c6b6 cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
11
79aefe82c6b6 cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
12 # FoodTruck assets.
648
1696f0a41cfc cm: Update npm modules and bower packages before making a release.
Ludovic Chabant <ludovic@chabant.com>
parents: 642
diff changeset
13 print("Update node modules")
1696f0a41cfc cm: Update npm modules and bower packages before making a release.
Ludovic Chabant <ludovic@chabant.com>
parents: 642
diff changeset
14 run("npm install")
1696f0a41cfc cm: Update npm modules and bower packages before making a release.
Ludovic Chabant <ludovic@chabant.com>
parents: 642
diff changeset
15 print("Generating FoodTruck assets")
642
79aefe82c6b6 cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
16 run("gulp")
79aefe82c6b6 cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
17
992
bd269692dbb4 cm: Make the release script commit changed FoodTruck assets if needed.
Ludovic Chabant <ludovic@chabant.com>
parents: 742
diff changeset
18 # See if any asset was modified and needs to be submitted.
bd269692dbb4 cm: Make the release script commit changed FoodTruck assets if needed.
Ludovic Chabant <ludovic@chabant.com>
parents: 742
diff changeset
19 r = run('hg status', hide=True)
bd269692dbb4 cm: Make the release script commit changed FoodTruck assets if needed.
Ludovic Chabant <ludovic@chabant.com>
parents: 742
diff changeset
20 if re.match(r'^[R\!] ', r.stdout):
bd269692dbb4 cm: Make the release script commit changed FoodTruck assets if needed.
Ludovic Chabant <ludovic@chabant.com>
parents: 742
diff changeset
21 raise Exception("FoodTruck assets are missing or were removed!")
bd269692dbb4 cm: Make the release script commit changed FoodTruck assets if needed.
Ludovic Chabant <ludovic@chabant.com>
parents: 742
diff changeset
22
bd269692dbb4 cm: Make the release script commit changed FoodTruck assets if needed.
Ludovic Chabant <ludovic@chabant.com>
parents: 742
diff changeset
23 commit_assets = False
bd269692dbb4 cm: Make the release script commit changed FoodTruck assets if needed.
Ludovic Chabant <ludovic@chabant.com>
parents: 742
diff changeset
24 if re.match(r'^[MA] ', r.stdout):
bd269692dbb4 cm: Make the release script commit changed FoodTruck assets if needed.
Ludovic Chabant <ludovic@chabant.com>
parents: 742
diff changeset
25 commit_assets = True
bd269692dbb4 cm: Make the release script commit changed FoodTruck assets if needed.
Ludovic Chabant <ludovic@chabant.com>
parents: 742
diff changeset
26
742
9231172e3d81 cm: Add generation of online changelog to the release task.
Ludovic Chabant <ludovic@chabant.com>
parents: 676
diff changeset
27 # CHANGELOG.rst and documentation changelog page.
642
79aefe82c6b6 cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
28 run("invoke changelog --last %s" % version)
742
9231172e3d81 cm: Add generation of online changelog to the release task.
Ludovic Chabant <ludovic@chabant.com>
parents: 676
diff changeset
29 run("invoke changelog --last %s -o docs/pages/support/changelog.md" %
1070
a013a3bea22a cm: Upgrade release script.
Ludovic Chabant <ludovic@chabant.com>
parents: 1005
diff changeset
30 version)
a013a3bea22a cm: Upgrade release script.
Ludovic Chabant <ludovic@chabant.com>
parents: 1005
diff changeset
31
a013a3bea22a cm: Upgrade release script.
Ludovic Chabant <ludovic@chabant.com>
parents: 1005
diff changeset
32 # Clean `dist` folder before running setuptools.
a013a3bea22a cm: Upgrade release script.
Ludovic Chabant <ludovic@chabant.com>
parents: 1005
diff changeset
33 dist_dir = os.path.join(
a013a3bea22a cm: Upgrade release script.
Ludovic Chabant <ludovic@chabant.com>
parents: 1005
diff changeset
34 os.path.dirname(os.path.dirname(__file__)),
a013a3bea22a cm: Upgrade release script.
Ludovic Chabant <ludovic@chabant.com>
parents: 1005
diff changeset
35 'dist')
a013a3bea22a cm: Upgrade release script.
Ludovic Chabant <ludovic@chabant.com>
parents: 1005
diff changeset
36 if os.path.isdir(dist_dir):
a013a3bea22a cm: Upgrade release script.
Ludovic Chabant <ludovic@chabant.com>
parents: 1005
diff changeset
37 print("Removing %s" % dist_dir)
a013a3bea22a cm: Upgrade release script.
Ludovic Chabant <ludovic@chabant.com>
parents: 1005
diff changeset
38 shutil.rmtree(dist_dir)
642
79aefe82c6b6 cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
39
650
1e543ed2bf38 cm: Tweaks to the release script.
Ludovic Chabant <ludovic@chabant.com>
parents: 648
diff changeset
40 if not local_only:
992
bd269692dbb4 cm: Make the release script commit changed FoodTruck assets if needed.
Ludovic Chabant <ludovic@chabant.com>
parents: 742
diff changeset
41 if commit_assets:
1001
112ff1ab110c cm: Only commit admin assets if they have changed.
Ludovic Chabant <ludovic@chabant.com>
parents: 992
diff changeset
42 res = run('hg status piecrust/admin/static')
112ff1ab110c cm: Only commit admin assets if they have changed.
Ludovic Chabant <ludovic@chabant.com>
parents: 992
diff changeset
43 if not res:
112ff1ab110c cm: Only commit admin assets if they have changed.
Ludovic Chabant <ludovic@chabant.com>
parents: 992
diff changeset
44 return
112ff1ab110c cm: Only commit admin assets if they have changed.
Ludovic Chabant <ludovic@chabant.com>
parents: 992
diff changeset
45 if res.stdout.strip() != '':
112ff1ab110c cm: Only commit admin assets if they have changed.
Ludovic Chabant <ludovic@chabant.com>
parents: 992
diff changeset
46 run('hg commit piecrust/admin/static '
112ff1ab110c cm: Only commit admin assets if they have changed.
Ludovic Chabant <ludovic@chabant.com>
parents: 992
diff changeset
47 '-m "admin: Regenerate FoodTruck assets."')
992
bd269692dbb4 cm: Make the release script commit changed FoodTruck assets if needed.
Ludovic Chabant <ludovic@chabant.com>
parents: 742
diff changeset
48
650
1e543ed2bf38 cm: Tweaks to the release script.
Ludovic Chabant <ludovic@chabant.com>
parents: 648
diff changeset
49 # Submit the CHANGELOG.
742
9231172e3d81 cm: Add generation of online changelog to the release task.
Ludovic Chabant <ludovic@chabant.com>
parents: 676
diff changeset
50 run('hg commit CHANGELOG.rst docs/pages/support/changelog.md '
9231172e3d81 cm: Add generation of online changelog to the release task.
Ludovic Chabant <ludovic@chabant.com>
parents: 676
diff changeset
51 '-m "cm: Regenerate the CHANGELOG."')
650
1e543ed2bf38 cm: Tweaks to the release script.
Ludovic Chabant <ludovic@chabant.com>
parents: 648
diff changeset
52
1e543ed2bf38 cm: Tweaks to the release script.
Ludovic Chabant <ludovic@chabant.com>
parents: 648
diff changeset
53 # Tag in Mercurial, which will then be used for PyPi version.
642
79aefe82c6b6 cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
54 run("hg tag %s" % version)
79aefe82c6b6 cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
55
650
1e543ed2bf38 cm: Tweaks to the release script.
Ludovic Chabant <ludovic@chabant.com>
parents: 648
diff changeset
56 # PyPi upload.
676
a04288f199a5 cm: Don't always generation the version when running `setuptools`.
Ludovic Chabant <ludovic@chabant.com>
parents: 650
diff changeset
57 run("python setup.py version")
1070
a013a3bea22a cm: Upgrade release script.
Ludovic Chabant <ludovic@chabant.com>
parents: 1005
diff changeset
58 run("python setup.py sdist bdist_wheel")
a013a3bea22a cm: Upgrade release script.
Ludovic Chabant <ludovic@chabant.com>
parents: 1005
diff changeset
59 run("twine upload dist/*")
742
9231172e3d81 cm: Add generation of online changelog to the release task.
Ludovic Chabant <ludovic@chabant.com>
parents: 676
diff changeset
60 else:
992
bd269692dbb4 cm: Make the release script commit changed FoodTruck assets if needed.
Ludovic Chabant <ludovic@chabant.com>
parents: 742
diff changeset
61 if commit_assets:
bd269692dbb4 cm: Make the release script commit changed FoodTruck assets if needed.
Ludovic Chabant <ludovic@chabant.com>
parents: 742
diff changeset
62 print("Would submit FoodTruck assets...")
742
9231172e3d81 cm: Add generation of online changelog to the release task.
Ludovic Chabant <ludovic@chabant.com>
parents: 676
diff changeset
63 print("Would submit changelog files...")
9231172e3d81 cm: Add generation of online changelog to the release task.
Ludovic Chabant <ludovic@chabant.com>
parents: 676
diff changeset
64 print("Would tag repo with %s..." % version)
9231172e3d81 cm: Add generation of online changelog to the release task.
Ludovic Chabant <ludovic@chabant.com>
parents: 676
diff changeset
65 print("Would upload to PyPi...")
642
79aefe82c6b6 cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
66