hundreds-carpet-28072
06/07/2024, 3:43 PMpython_distribution
and modify its provides.python_artifact.version
to include a dev release: wheel-1.2.3.whl
-> wheel-1.2.3.dev1.whl
but can’t see a way to do this with __defaults__
and vcs_version
plugin isn’t exactly what I want.wide-midnight-78598
06/07/2024, 3:48 PMcurved-television-6568
06/07/2024, 3:57 PMenv()
and .pants.bootstrap
to manage it: https://www.pantsbuild.org/2.21/docs/using-pants/key-concepts/targets-and-build-files#environment-variables
https://www.pantsbuild.org/2.21/docs/using-pants/key-concepts/options#pantsbootstrap-filecurved-television-6568
06/07/2024, 3:59 PMdef acme_version(value: str) -> str:
"""Define a version.
This will include any pre-release suffix as applicable.
"""
return value + env("PRE_RELEASE_SUFFIX")
def acme_lib(version: str, provides=None, **kwargs):
python_distribution(
provides=python_artifact(
name=build_file_dir().name,
version=acme_version(version),
**(provides or {}),
),
**kwargs,
)
and in .pants.bootstrap
# Set some default values, unless provided..
export BRANCH=${BRANCH:-$(git rev-parse --abbrev-ref HEAD)}
export BUILD_NUMBER=${BUILD_NUMBER:-0}
# Setup release variant (stable / dev) based on branch.
if [ "${BRANCH}" == "master" ]; then
PRE_RELEASE_SUFFIX=
else
PRE_RELEASE_SUFFIX=".dev${BUILD_NUMBER}"
fi
export PRE_RELEASE_SUFFIX
hundreds-carpet-28072
06/07/2024, 4:10 PMPANTS_CONFIG_FILES=pants.ci.toml
curved-television-6568
06/07/2024, 8:01 PMhundreds-carpet-28072
06/08/2024, 7:23 AMcurved-television-6568
06/08/2024, 7:53 AMhundreds-carpet-28072
06/14/2024, 9:23 AMmacros.py
, I’m decided to pass through the version from provides instead but I’m getting an error when trying to unpack and pass provides as kwargs using your example:
# macros.py
def python_distribution2(provides=None, **kwargs):
python_distribution(
provides=python_artifact(
name=build_file_dir().name,
version=dev_version(provides.kwargs["version"]),
**(provides or {}),
),
**kwargs,
)
MappingError: Failed to parse ./oxlibs/oxlibs/BUILD:
TypeError: pants.backend.python.macros.python_artifact.PythonArtifact() argument after ** must be a mapping, not PythonArtifact
Using provides.kwargs
instead duplicates the name/version fields, is there a way to only provide the kwargs that aren’t overwritten?hundreds-carpet-28072
06/14/2024, 9:58 AMpython_distribution
with my python_distribution_custom
macro?curved-television-6568
06/14/2024, 10:20 AMpython_distribution_custom
rather than replacing the original target with the custom one, as that could be surprising to folks looking up docs etc for the target if not realizing it has been customized.hundreds-carpet-28072
07/15/2024, 4:46 PMdef python_distribution_custom(provides=None, **kwargs):
python_distribution(
provides=python_artifact(
**dict(provides.kwargs,
name=build_file_dir().name,
version=modify_version(provides.kwargs["version"])
) or {},
),
**kwargs,
)
Is there a nice way for me to only apply this modification on the targets that are being passed to pants package <targets>
and not the first-party dependents of those targets?curved-television-6568
07/15/2024, 8:32 PMhundreds-carpet-28072
07/16/2024, 9:02 AMcurved-television-6568
07/16/2024, 10:50 AMhundreds-carpet-28072
07/16/2024, 11:16 AM