diff options
author | Malfurious <m@lfurio.us> | 2025-01-03 09:59:53 -0500 |
---|---|---|
committer | Malfurious <m@lfurio.us> | 2025-01-04 23:54:51 -0500 |
commit | d4aacb45a070f05eddb5fbfec191b440e381e268 (patch) | |
tree | 3b06b2f7e8c1efbace542beb4f8665dd196cc292 /hooks | |
parent | 6d1418c28161c51c6a0649207c51e9b03c7d197a (diff) | |
download | nsploit-d4aacb45a070f05eddb5fbfec191b440e381e268.tar.gz nsploit-d4aacb45a070f05eddb5fbfec191b440e381e268.zip |
Don't rely on git for version information
The version information for the nsploit distribution is now defined in
pyproject.toml, and we no longer attempt to obtain details via
git-describe. As previously, the library version is made available via
`nsploit.__version__`.
The main benefit of working this way is to allow a proper install of
nsploit from a simple tarball of the source code, or even a shallow git
clone. In each of these cases, tag information will not usually be
present.
As an added feature over the previous system, nsploit will now report in
its version string if the running version is from a source tree, rather
than an installed copy.
Signed-off-by: Malfurious <m@lfurio.us>
Diffstat (limited to 'hooks')
-rw-r--r-- | hooks/bake_version.py | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/hooks/bake_version.py b/hooks/bake_version.py deleted file mode 100644 index f4cd935..0000000 --- a/hooks/bake_version.py +++ /dev/null @@ -1,26 +0,0 @@ -from hatchling.builders.hooks.plugin.interface import BuildHookInterface - -import os -import re - -filename = os.path.normpath(os.path.join("nsploit","__init__.py")) - -#put the file back when the build ends -class RestoreVersionFile: - def __init__(self,contents): - self.contents = contents - def __del__(self): - with open(filename,"w") as f: - f.write(self.contents) - -class BakeVersionBuildHook(BuildHookInterface): - def initialize(self,version,build_data): - with open(filename,"r") as f: - self.restore = RestoreVersionFile(f.read()) - pattern = r'(?i)^__version__ *= *(?P<version>.+?)$' - match = re.search(pattern, self.restore.contents, flags=re.MULTILINE) - if not match: - raise ValueError("regex of version file failed") - span = match.span('version') - with open(filename,"w") as f: - f.write(f'{self.restore.contents[:span[0]]}"v{self.metadata.version}"{self.restore.contents[span[1]:]}') |