cool-account-59189
06/13/2023, 7:28 PMpython_distribution(
name="tools_dist",
dependencies=[
"tools:tool_files",
"tools:tools_pyproject",
"tools/src:tools_lib",
"shared:shared_dist",
],
provides=python_artifact(
name="awesome_tools",
version = "$WANT_THIS_TO_BE_SOME_MAGIC_VARIABLE_SET_AT_PANTS_RUN_TIME",
authors = "Ryan",
authorEmail = "<mailto:rmahoney@aledade.com|rmahoney@aledade.com>",
readme = "README.md"
),
sdist=False, # Do NOT generate an sdist (as a result only a wheel is generated)
)
cool-account-59189
06/13/2023, 7:31 PMvcs_version
target (https://www.pantsbuild.org/docs/generating-version-tags), which might work for what I need given enough force, but I'm not sure how to pull the generated value in that file out to be referenced within the version
field abovecool-account-59189
06/13/2023, 7:44 PMcurved-television-6568
06/13/2023, 7:53 PMIs there a way to pass this into a given invocation of pants.You may leverage environment variable for this:
...
python_artifact(
name="awesome_tools",
version = env("SOME_VERSION", "0.0.0"), # the 0.0.0 part is an optional default in case the env var is undefined.
...
then:
# SOME_VERSION=1.2.3 pants package ...
curved-television-6568
06/13/2023, 7:54 PMcool-account-59189
06/13/2023, 7:54 PMcool-account-59189
06/13/2023, 7:55 PMcurved-television-6568
06/13/2023, 7:55 PMcool-account-59189
06/13/2023, 7:55 PMfew-arm-93065
06/13/2023, 10:59 PMquick-midnight-96336
07/27/2023, 3:29 PMcool-account-59189
07/27/2023, 3:30 PMcool-account-59189
07/27/2023, 3:31 PMcool-account-59189
07/27/2023, 3:32 PMfiles(name="tools_additional_files_needed_for_wheel", sources=["README.md"])
python_distribution(
name="tools_dist",
dependencies=[
"tools:tools_additional_files_needed_for_wheel",
"tools/src:tools_lib",
"shared:shared_dist",
],
provides=python_artifact(
name="awesome_tools",
version=env("AWESOME_PROJECT_SPECIFIC_WHEEL_BUILD_VERSION", "0.1.0"),
author="Awesome",
author_email="<mailto:support@awesome.com|support@awesome.com>",
long_description_content_type="text/markdown",
),
long_description_path="README.md",
sdist=False, # Do NOT generate an sdist (as a result only a wheel is generated)
)
cool-account-59189
07/27/2023, 3:33 PMcool-account-59189
07/27/2023, 3:33 PMAWESOME_PROJECT_SPECIFIC_WHEEL_BUILD_VERSION=0.133.0 pants package ::
cool-account-59189
07/27/2023, 3:34 PMquick-midnight-96336
07/27/2023, 3:46 PMexport AWESOME_PROJECT_SPECIFIC_WHEEL_BUILD_VERSION=0.0.1
export AWESOME_PROJECT_2_SPECIFIC_WHEEL_BUILD_VERSION=0.0.1
and then in each BUILD file:
provides=python_artifact(
name="awesome_tools",
version=env("AWESOME_PROJECT_SPECIFIC_WHEEL_BUILD_VERSION", "0.1.0"),
author="Awesome",
author_email="<mailto:support@awesome.com|support@awesome.com>",
long_description_content_type="text/markdown",
),
provides=python_artifact(
name="awesome_tools",
version=env("AWESOME_PROJECT_SPECIFIC_2_WHEEL_BUILD_VERSION", "0.1.0"),
author="Awesome",
author_email="<mailto:support@awesome.com|support@awesome.com>",
long_description_content_type="text/markdown",
),
So i generate the packages as
source VERSIONS.env && pants package ::
This helps me to maintain all the versions explicit in one entrypoint, but it forces our team to manually bump versions by hand before merging and deploying, which is prone to errors.
That's why I was interested in still injecting the vcs_version
, but I think it is still not possible, and also I wonder if it would just update all versions at once with the last commit / tag (unless I do the --changed-since=origin/main, or something)...not sure what is going to be the optimal solution to us.
If I manage to automatize it or create a plugin worth to share I will keep you updated !
many thanks @cool-account-59189 !cool-account-59189
07/27/2023, 3:47 PMcool-account-59189
07/27/2023, 3:47 PMAWESOME_PROJECT_SPECIFIC_2_WHEEL_BUILD_VERSION=1.1.${CI_PIPELINE_IID}
cool-account-59189
07/27/2023, 3:48 PMquick-midnight-96336
07/27/2023, 3:49 PMquick-midnight-96336
07/27/2023, 3:50 PM