harald/pythonbuilder
1
0
Fork
You've already forked pythonbuilder
0

Dynamically generated target address/pointer/name #4

Closed
opened 2025年08月29日 12:24:46 +02:00 by harald · 1 comment

Current Situation

The Target.item is currently treated as the name, the address or the pointer to the actual content or value we want to keep updated by the build. The canonical example is the Path of a file.

This is most clearly seen by the fact that state= and cmd= functions (usually) don't get the Target passed as a parameter, but its item's value, meaning they can change the value the item is pointing to but not the Target's item itself.

Further, the current assumption is that

  • the thing we want to keep updated depends on the dependencies
  • its address or name is known ahead of time and, in particular, does not depend on the dependencies

An example where this breaks down is when the file's path is provided by an environment variable and we would like to treat the environment variable as a dependency. In this case it is not the content of the file which depends on the dependency, but its path.

Requirement

Provide a means whereby the Target.item, as a pointer to the actual value to keep updated, may depend on the dependencies.

Rationale

One, somewhat weak, argument I encountered goes as follows: If we use

 Target(Path(os.getenv("SOMEENV"), name="libout")

assuming that SOMEENV is actually set, the value of SOMEENV ends up in the dependency graph. I like my projects to show the dependency graph on Codeberg, but I don't like to expose my private software setup.

If we could write something along the lines of

 liboutEnv = Target(Getenv("SOMEENV"))
 Target(lambda getenv: Path(getenv.get()), liboutEnv)

we would only see str(Getenv("SOMEENV")) in the output, which should avoid to provide the actual environment value. But it would obviously require to allow to compute the target's item on the fly,

  • after the dependencies are updated
  • with the dependencies as parameters

Considerations and Ideas

  • If the first argument of Target is callable, its signature must match the list of dependencies and it must return a T, the generic argument type of Target.
  • defining an @property which calls the callable, if needed, might be just right
# Current Situation The `Target.item` is currently treated as the name, the address or the pointer to the actual content or value we want to keep updated by the build. The canonical example is the `Path` of a file. This is most clearly seen by the fact that `state=` and `cmd=` functions (usually) don't get the `Target` passed as a parameter, but its `item`'s value, meaning they can change the value the item is pointing to but not the `Target`'s item itself. Further, the current assumption is that - the thing we want to keep updated depends on the dependencies - its address or name is known ahead of time and, in particular, does not depend on the dependencies An example where this breaks down is when the file's path is provided by an environment variable and we would like to treat the environment variable as a dependency. In this case it is not the content of the file which depends on the dependency, but its path. # Requirement Provide a means whereby the `Target.item`, as a pointer to the actual value to keep updated, may depend on the dependencies. # Rationale One, somewhat weak, argument I encountered goes as follows: If we use ```python Target(Path(os.getenv("SOMEENV"), name="libout") ``` assuming that `SOMEENV` is actually set, the value of `SOMEENV` ends up in the dependency graph. I like my projects to show the dependency graph on Codeberg, but I don't like to expose my private software setup. If we could write something along the lines of ```python liboutEnv = Target(Getenv("SOMEENV")) Target(lambda getenv: Path(getenv.get()), liboutEnv) ``` we would only see `str(Getenv("SOMEENV"))` in the output, which should avoid to provide the actual environment value. But it would obviously require to allow to compute the target's item on the fly, - after the dependencies are updated - with the dependencies as parameters # Considerations and Ideas - If the first argument of `Target` is callable, its signature must match the list of dependencies and it must return a `T`, the generic argument type of `Target`. - defining an `@property` which calls the callable, if needed, might be just right
Author
Owner
Copy link

Implemented in 6a1d321679 .

Implemented in 6a1d321679ab94ccb6d3f6dd548cfac7a8751e41 .
Sign in to join this conversation.
No Branch/Tag specified
main
v-2025年10月23日
list
v-2025年09月26日
v-2025年09月21日
v-2025年09月18日
v-2025年08月21日
v-2025年08月17日
v-2025年08月03日
v-2025年07月27日
v-2025年05月31日
v-2025年05月10日
No labels
feature
refactoring
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
harald/pythonbuilder#4
Reference in a new issue
harald/pythonbuilder
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?