hatch-env-plus 0.1.0__py3-none-any.whl → 1.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
hatch_env_plus/plugin.py CHANGED
@@ -4,13 +4,13 @@ from hatchling.version.source.plugin.interface import VersionSourceInterface
4
4
 
5
5
 
6
6
  class EnvironmentVariableVersionSource(VersionSourceInterface):
7
- PLUGIN_NAME = 'env-plus'
7
+ PLUGIN_NAME = "env-plus"
8
8
 
9
9
  def get_version_data(self) -> dict:
10
- variable = self.config.get('variable', 'PACKAGE_VERSION')
11
- fallback = self.config.get('fallback', '0.0.0dev0')
12
- version = os.environ.get(variable, fallback)
13
- return {'version': version}
10
+ variable = self.config.get("variable", "PACKAGE_VERSION")
11
+ fallback = self.config.get("fallback", "0.0.0dev0") or None
12
+ version = os.environ.get(variable, None) or fallback
13
+ return {"version": version}
14
14
 
15
15
  def set_version(self, version: str, version_data: dict) -> None:
16
- version_data['version'] = version
16
+ version_data["version"] = version
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hatch-env-plus
3
- Version: 0.1.0
3
+ Version: 1.0.1
4
4
  Summary: A version source for Hatchling that reads the version from a given environment variable, but also allows for a fallback if the variable is not populated.
5
5
  Project-URL: homepage, https://github.com/jenskeiner/hatch_env_plus/
6
6
  Project-URL: repository, https://github.com/jenskeiner/hatch_env_plus.git
@@ -27,8 +27,9 @@ Description-Content-Type: text/markdown
27
27
 
28
28
  # Hatchling Environment Variable Version Source
29
29
 
30
- A Hatchling version source plugin that reads the version from an environment variable with a configurable fallback value,
31
- since the built-in environment variable version source does not allow to define a fallback.
30
+ A [Hatchling](https://github.com/pypa/hatch) version source plugin that reads the version from an environment variable
31
+ with a configurable fallback value, since the built-in [`env`](https://hatch.pypa.io/latest/plugins/version-source/env/)
32
+ version source does not allow to define a fallback.
32
33
 
33
34
  ## Installation
34
35
 
@@ -57,13 +58,18 @@ Then, configure the version source:
57
58
  [tool.hatch.version]
58
59
  source = "env-plus"
59
60
  variable = "PACKAGE_VERSION" # optional, default shown
60
- fallback = "0.0.0dev0" # optional, default shown
61
+ fallback = "0.0.0dev0" # optional, default shown
61
62
  ```
62
63
 
63
- Use the `variable` field to set the environment variable to use and set `fallback` to the desired fallback version.
64
+ Use the `variable` field to set the environment variable to use, and set `fallback` to the desired fallback version.
64
65
 
65
- **Note: An empty version string is treated as undefined. Therefore, this will throw an error if the configured environment
66
- variable as well as the fallback are both empty.**
66
+ **Note: An empty string, whether from the configured environment variable or from the fallback, is an
67
+ undefined version.**
68
+
69
+ If you explicitly set the configured environment variable to the empty string, your build will fail as no valid version
70
+ is set. If you explicitly set `fallback` to an empty string, your build will fail when the configured environment
71
+ variable is not set. This is the default behavior of [Hatchling]([Hatchling](https://github.com/pypa/hatch))'s built-in
72
+ enviroment variable version source [`env`](https://hatch.pypa.io/latest/plugins/version-source/env/).
67
73
 
68
74
  ## Usage
69
75
 
@@ -0,0 +1,8 @@
1
+ hatch_env_plus/__init__.py,sha256=zJGQMEhazvvgCqxv453ca9YmaZf-nT8q78dfju1jNnI,101
2
+ hatch_env_plus/hooks.py,sha256=5yc22VRzKOcVdAqHB-6UYOMBty1IUlgFSyTNOSJWtZc,185
3
+ hatch_env_plus/plugin.py,sha256=GZ1PpuF-mNltkLZMZ9IpXj32XkpnX_HZg9Pl1yXt0iE,567
4
+ hatch_env_plus-1.0.1.dist-info/METADATA,sha256=7_VedzpMPl12uMkLd-zBWOoDBr_WlDtHKCoW4w86rfk,3309
5
+ hatch_env_plus-1.0.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
6
+ hatch_env_plus-1.0.1.dist-info/entry_points.txt,sha256=znfR_zsEJqQ4kew-3ZauRvfOFU1lrzMeZC4vshELYXY,40
7
+ hatch_env_plus-1.0.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
8
+ hatch_env_plus-1.0.1.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- hatch_env_plus/__init__.py,sha256=zJGQMEhazvvgCqxv453ca9YmaZf-nT8q78dfju1jNnI,101
2
- hatch_env_plus/hooks.py,sha256=5yc22VRzKOcVdAqHB-6UYOMBty1IUlgFSyTNOSJWtZc,185
3
- hatch_env_plus/plugin.py,sha256=p7QfyI5D4IkenzjA64QmzRSObKX44vN3EIeYKXgnynE,551
4
- hatch_env_plus-0.1.0.dist-info/METADATA,sha256=3-2lBgA-uuq_foG906Q4bxkctdY9V4cSQq_NO-zL-ig,2835
5
- hatch_env_plus-0.1.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
6
- hatch_env_plus-0.1.0.dist-info/entry_points.txt,sha256=znfR_zsEJqQ4kew-3ZauRvfOFU1lrzMeZC4vshELYXY,40
7
- hatch_env_plus-0.1.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
8
- hatch_env_plus-0.1.0.dist-info/RECORD,,