Python
|
Add | Remove | Arguments | Anchored |
---|---|---|---|
include |
exclude |
file-pattern1 [file-patternN] | ✔ |
global-include |
global-exclude |
file-pattern1 [file-patternN] | ✘ |
recursive-include |
recursive-exclude |
dir-pattern file-pattern1 [file-patternN] | ✔ dir pattern ✘ file patterns |
graft |
prune |
dir-pattern | ✔ |
The order of the commands in your template file matters. I recommend doing includes first, then excludes, going from most specific to most general.
include
sglobal-include
srecursive-include
sgraft
sexclude
sglobal-exclude
srecursive-exclude
sprune
s
Remember: You only need to exclude files get added to the list by default or
*with your include commands -- *you do not need to fully mirror your
*.gitignore
with exclude commands.
Anchoring
If a pattern is anchored that means it must match the root of the project precisely. For example, given these files:
.
├── LICENSE.txt
└── things
└── LICENSE.txt
- The command
include LICENSE.txt
would addLICENSE.txt
but missthings/LICENSE.txt
. - The command
global-include LICENSE.txt
would add anyLICENSE.txt
found in the tree.
Thus you want to be certain to use a global-exclude
to keep out unwanted
files that get strewn about everywhere:
global-exclude *.py[cod]
global-exclude .DS_Store
Shell-style glob patterns
Glob | Becomes regex | Matches | Example |
---|---|---|---|
* |
[^/]* |
Match 0 or more anything but a path seperator, e.g. / |
*.txt |
? |
[^/] |
Match 1 of anything but a path seperator, e.g. / |
|
** |
.* |
Match anything, including path seperators. | src/**/templates |
[seq] |
[seq] |
Match any character within; ranges are valid. | step-[0-9].png |
[!seq] |
[^seq] |
Match anything except a character within; ranges are valid. | [!0-9] |
Note: Older versions of Python did not support the globstar (
**
). While it is a wonderful addition in newer version of Python andsetuptools
, it can still take some playing with to get the result you want, particularly withgraft
andprune
.
Other syntax
- Leading and trailing whitespace are irrelevant.
- Comments are an
#
not escaped with a\
, i.e.,\#
would not start a comment. - Lines can be continued using a
\
.
Examples
An example of some syntax is useful:
include LICENSE.txt
# If you need a literal special glob character, put it in a sequence.
include myfile[?].txt
# To match a literal hash, escape it.
include my\#file.txt
graft docs
global-exclude \
*.py[cod] \ # Comments after line continuations are valid.
# And between line continuations as well!
.DS_Store \ # Last item can have a line continuation as well, as long as the next line is blank.
prune docs/build
For a real-world example, have a look at the included example/MANIFEST.in
.
Other resources
Release
set -gx VSCE_TOKEN "<token from 1Password>"
set -gx OVSX_TOKEN "<token from 1Password>"
set -gx PCKG_VERSION "v1.0.1"
pew workon vscode-python-manifest-template
# Probably already done.
npm i -g vsce ovsx
vsce login benspaulding
# Good to review.
vsce ls
# Should do before running publish, just to be safe.
vsce package
# Bump version number in package.json.
git add package.json
git commit -m "Bump version for $PCKG_VERSION"
git tag -a -m "vscode-python-manifest-template extension $PCKG_VERSION" "$PCKG_VERSION"
git push
git push --tags
git fetch --all # Because of my multi-push setup.
# And publish!
vsce publish --githubBranch "main" -p "$VSCE_TOKEN"
ovsx publish --baseImagesUrl "https://github.com/benspaulding/vscode-python-manifest-template/raw/main/" -p "$OVSX_TOKEN"