How to change one component for another at build time? #179
-
Hello! I am trying to create two different versions of a cli tool for two clients, but both should use the same base, with different components. I know how to do this in the Clojure implementation of Polylith, but trying to do so with python has eluded me. I tried to structure my project like so:
The component under the high level namespace would have shared code, while client specific code would be under the folders for each client. In the base, I would do an import like so: from mynamespace import cli_impl
cli_impl.do_something() And then in the client1's
client2's
I expected this to be the best way to change out one component for another at build time, but it didn't work, and it continues to go outside of the client1 and client2 subfolders when building. Is it possible to do this? Am I going about it the wrong way? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
I think this failes because of the way bricks are identified currently. It is pretty strict; the tool expects the flat I wasn't aware about this possibility in Clojure - I know about What I would do is to instead have two separate thin bases for each client, and let them import their respective components. Would that work for you? Also, wouldn't the Another alternative would be to have one component, but two "endpoints" in it, one for each client, unless they require different third-party libraries. |
Beta Was this translation helpful? Give feedback.
I think it should work to do as you have done from a tech perspective, but I might have made assumptions about the flat structure as I mentioned before. I can have a look at it!
From a Polylith perspective, I would still recommend to rethink the setup with the nested client1 and client2. Are they represented as components when you run
poly info
? Ideally, I think the cli_impl should be the components and not the top folders.As I see it, the reusability of bases are not as common as for components - even if it is possible. The main use case that I have known about before for reusing a
base
is to have several services running with the same base but with different environment variables.If t…