hatch-env-plus 0.1.0__tar.gz → 1.0.0__tar.gz
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-0.1.0 → hatch_env_plus-1.0.0}/PKG-INFO +10 -6
- {hatch_env_plus-0.1.0 → hatch_env_plus-1.0.0}/README.md +9 -5
- {hatch_env_plus-0.1.0 → hatch_env_plus-1.0.0}/pyproject.toml +3 -5
- {hatch_env_plus-0.1.0 → hatch_env_plus-1.0.0}/src/hatch_env_plus/plugin.py +1 -1
- {hatch_env_plus-0.1.0 → hatch_env_plus-1.0.0}/tests/test_plugin.py +9 -2
- {hatch_env_plus-0.1.0 → hatch_env_plus-1.0.0}/.gitignore +0 -0
- {hatch_env_plus-0.1.0 → hatch_env_plus-1.0.0}/LICENSE +0 -0
- {hatch_env_plus-0.1.0 → hatch_env_plus-1.0.0}/src/hatch_env_plus/__init__.py +0 -0
- {hatch_env_plus-0.1.0 → hatch_env_plus-1.0.0}/src/hatch_env_plus/hooks.py +0 -0
- {hatch_env_plus-0.1.0 → hatch_env_plus-1.0.0}/tests/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hatch-env-plus
|
|
3
|
-
Version:
|
|
3
|
+
Version: 1.0.0
|
|
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
|
|
@@ -28,7 +28,7 @@ Description-Content-Type: text/markdown
|
|
|
28
28
|
# Hatchling Environment Variable Version Source
|
|
29
29
|
|
|
30
30
|
A Hatchling version source plugin that reads the version from an environment variable with a configurable fallback value,
|
|
31
|
-
since the built-in
|
|
31
|
+
since the built-in `env` version source does not allow to define a fallback.
|
|
32
32
|
|
|
33
33
|
## Installation
|
|
34
34
|
|
|
@@ -57,13 +57,17 @@ Then, configure the version source:
|
|
|
57
57
|
[tool.hatch.version]
|
|
58
58
|
source = "env-plus"
|
|
59
59
|
variable = "PACKAGE_VERSION" # optional, default shown
|
|
60
|
-
fallback = "0.0.0dev0"
|
|
60
|
+
fallback = "0.0.0dev0" # optional, default shown
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
Use the `variable` field to set the environment variable to use and set `fallback` to the desired fallback version.
|
|
63
|
+
Use the `variable` field to set the environment variable to use, and set `fallback` to the desired fallback version.
|
|
64
64
|
|
|
65
|
-
**Note: An empty
|
|
66
|
-
|
|
65
|
+
**Note: An empty string, whether from the configured environment variable or from the fallback, is an
|
|
66
|
+
undefined version.**
|
|
67
|
+
|
|
68
|
+
If you explicitly set the configured environment variable to the empty string, your build will fail as no valid version
|
|
69
|
+
is set. If you explicitly set `fallback` to an empty string, your build will fail when the configured environment
|
|
70
|
+
variable is not set. This is the default behavior of Hatchling's built-in enviroment variable version source `env`.
|
|
67
71
|
|
|
68
72
|
## Usage
|
|
69
73
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Hatchling Environment Variable Version Source
|
|
2
2
|
|
|
3
3
|
A Hatchling version source plugin that reads the version from an environment variable with a configurable fallback value,
|
|
4
|
-
since the built-in
|
|
4
|
+
since the built-in `env` version source does not allow to define a fallback.
|
|
5
5
|
|
|
6
6
|
## Installation
|
|
7
7
|
|
|
@@ -30,13 +30,17 @@ Then, configure the version source:
|
|
|
30
30
|
[tool.hatch.version]
|
|
31
31
|
source = "env-plus"
|
|
32
32
|
variable = "PACKAGE_VERSION" # optional, default shown
|
|
33
|
-
fallback = "0.0.0dev0"
|
|
33
|
+
fallback = "0.0.0dev0" # optional, default shown
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
Use the `variable` field to set the environment variable to use and set `fallback` to the desired fallback version.
|
|
36
|
+
Use the `variable` field to set the environment variable to use, and set `fallback` to the desired fallback version.
|
|
37
37
|
|
|
38
|
-
**Note: An empty
|
|
39
|
-
|
|
38
|
+
**Note: An empty string, whether from the configured environment variable or from the fallback, is an
|
|
39
|
+
undefined version.**
|
|
40
|
+
|
|
41
|
+
If you explicitly set the configured environment variable to the empty string, your build will fail as no valid version
|
|
42
|
+
is set. If you explicitly set `fallback` to an empty string, your build will fail when the configured environment
|
|
43
|
+
variable is not set. This is the default behavior of Hatchling's built-in enviroment variable version source `env`.
|
|
40
44
|
|
|
41
45
|
## Usage
|
|
42
46
|
|
|
@@ -24,8 +24,7 @@ classifiers = [
|
|
|
24
24
|
"Framework :: Hatch",
|
|
25
25
|
]
|
|
26
26
|
dependencies = [
|
|
27
|
-
# Package dependencies go here
|
|
28
|
-
# "pandas>=1,<3",
|
|
27
|
+
# Package dependencies go here.
|
|
29
28
|
]
|
|
30
29
|
|
|
31
30
|
[project.urls]
|
|
@@ -42,7 +41,7 @@ dev = [
|
|
|
42
41
|
]
|
|
43
42
|
|
|
44
43
|
[build-system]
|
|
45
|
-
requires = ["hatchling>=1.21.1"]
|
|
44
|
+
requires = ["hatchling>=1.21.1", "hatch-env-plus>=0.1.0"]
|
|
46
45
|
build-backend = "hatchling.build"
|
|
47
46
|
|
|
48
47
|
[tool.hatch.build.targets.sdist]
|
|
@@ -60,8 +59,7 @@ sources = ["src"]
|
|
|
60
59
|
only-include = ["src/hatch_env_plus"]
|
|
61
60
|
|
|
62
61
|
[tool.hatch.version]
|
|
63
|
-
source = "env"
|
|
64
|
-
variable = "PACKAGE_VERSION"
|
|
62
|
+
source = "env-plus"
|
|
65
63
|
|
|
66
64
|
[tool.pytest.ini_options]
|
|
67
65
|
addopts = "--cov=hatch_env_plus --cov-report=term-missing --cov-report=html"
|
|
@@ -8,7 +8,7 @@ class EnvironmentVariableVersionSource(VersionSourceInterface):
|
|
|
8
8
|
|
|
9
9
|
def get_version_data(self) -> dict:
|
|
10
10
|
variable = self.config.get('variable', 'PACKAGE_VERSION')
|
|
11
|
-
fallback = self.config.get('fallback', '0.0.0dev0')
|
|
11
|
+
fallback = self.config.get('fallback', '0.0.0dev0') or None
|
|
12
12
|
version = os.environ.get(variable, fallback)
|
|
13
13
|
return {'version': version}
|
|
14
14
|
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import os
|
|
2
|
-
|
|
3
1
|
import pytest
|
|
4
2
|
|
|
5
3
|
from hatchling.version.source.plugin.interface import VersionSourceInterface
|
|
@@ -63,3 +61,12 @@ def test_env_var_takes_precedence_over_fallback():
|
|
|
63
61
|
# Set - uses env var
|
|
64
62
|
m.setenv('CUSTOM_VER', '5.0.0')
|
|
65
63
|
assert plugin.get_version_data() == {'version': '5.0.0'}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def test_empty_fallback_string_treated_as_none():
|
|
67
|
+
"""Empty fallback string is converted to None."""
|
|
68
|
+
plugin = EnvironmentVariableVersionSource('', {'fallback': ''})
|
|
69
|
+
with pytest.MonkeyPatch().context() as m:
|
|
70
|
+
m.delenv('PACKAGE_VERSION', raising=False)
|
|
71
|
+
data = plugin.get_version_data()
|
|
72
|
+
assert data == {'version': None}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|