Skip to content

Make environment option's content available in tasks as a Project property #825

@lormico

Description

@lormico

I have to package and release on a custom PyPI repository several different versions of a project, intended for different execution environments (development, testing, production, etc.). Each version will have the same source code, but will incorporate data files with different values for each environment. I need to access an environment property in order to:

  • differentiate releases by appending a tag in the version (for example, so that 1.0.0 becomes 1.0.0+<environment>);
  • choose the right data to filter resource files (for example, to load src/main/environments/<environment>.json);
  • use the right dependency versions for proprietary libraries that follow the same versioning criteria (for example, myproject-1.0.0+<environment> may need mylibrary-0.1.0+<environment>).

In Apache Maven, I would have set a <profile-id/> property in the <profiles/> section, one for each defined profile; I would have done it in a parent pom.xml and would not have had to replicate them on each project.

In the current version of Pybuilder, I could get what I need by defining in build.py something like this (<environment> is of course just a placeholder string):

@init(environments="<environment>")
def set_environment_<environment>(project):
    project.set_property("environment", "<environment>")

repeating this block for each environment I need to track and on each versioned project.

I think it would be nice to have instead a property defined in project so that if one launches Pybuilder like this:

pyb -E <environment1> -E <environment2> ...

one could access, for instance, project.environments and get the list ["<environment1>", "<environment2>"].

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions