:wave: Hello~ Is there a way to use a variable for...
# general
b
👋 Hello~ Is there a way to use a variable for a glob? I’m trying to do something like this:
Copy code
__dependents_rules__(
    # If it's a service, cant depend on another service.
    (
        ({"path": "//src/services/<GLOB VARIABLE>/**" # Selector
        ("!//src/services/!<GLOB VARIABLE>/**"), # DENY other services.
        ("*") # Allow everything else
    ),
   ....
)
my project structure looks like
Copy code
BUILD    <-- where I'm putting the rules above
src
  libs
     libOne
     libTwo
  services
     serviceA
         BUILD
         ...
     serviceB
         BUILD
         ...
f
BUILD
file syntax is Python syntax. You can probably just use
f
-string there.
b
A nice way to do it is to use a different resolve for each service
This way pants doesn't let the service import for other services and as a bonus each service will have it's own lockfile
b
but with multiple resolves, doesn’t’ that mean the two services could depend on different versions of the same dependency? The way I have it set up is such that you have a shared
requirements.txt
for everything—and then each service can have its own
requirements.txt
file that would be added on top of the shared one
f
you may find using a macro for declaring visibility rules helpful. Please see an example in this blog post https://blog.pantsbuild.org/visibility-feature-in-pants-2-16/
đź‘€ 1
by declaring a macro you can reuse the same ruleset for all services so that they share the same dependencies / dependents policy. In a macro, you can use variables (so it would feel very closely to writing a Python module with some functions).