billowy-motherboard-58443
10/01/2020, 7:44 PMhundreds-father-404
10/01/2020, 7:50 PMbillowy-motherboard-58443
10/01/2020, 7:51 PMbillowy-motherboard-58443
10/01/2020, 7:52 PMbillowy-motherboard-58443
10/01/2020, 7:52 PMbillowy-motherboard-58443
10/01/2020, 7:55 PMbillowy-motherboard-58443
10/01/2020, 7:55 PMhundreds-father-404
10/01/2020, 8:05 PMbillowy-motherboard-58443
10/01/2020, 8:07 PMbillowy-motherboard-58443
10/01/2020, 8:07 PMbillowy-motherboard-58443
10/01/2020, 8:07 PMhundreds-father-404
10/01/2020, 8:12 PM./pants --changed-since=<branch> --changed-dependees=transitive test
in CI.
For example, some orgs set up their CI so that when library A changes, the team owning app C will be notified and will have to approve the change.billowy-motherboard-58443
10/01/2020, 8:13 PMbillowy-motherboard-58443
10/01/2020, 8:14 PMhundreds-father-404
10/01/2020, 8:14 PMversion
used in your python_distribution
, that is a workflow that can be supported in several different ways. For example, one user is using Git to update versions based on what files change. To do this type of thing, you would write a plugin for setup_py
That is sound to deal with versioning that way because you are not trying to “pin” your own internal code. You’re instead talking about what code gets exported externally. Because that code is getting exported externally, by definition, it’s a “snapshot” of the code at a certain time.billowy-motherboard-58443
10/01/2020, 8:14 PMbillowy-motherboard-58443
10/01/2020, 8:15 PMpip install -U foo
hundreds-father-404
10/01/2020, 8:15 PMpip
billowy-motherboard-58443
10/01/2020, 8:15 PMbillowy-motherboard-58443
10/01/2020, 8:15 PMbillowy-motherboard-58443
10/01/2020, 8:15 PMbillowy-motherboard-58443
10/01/2020, 8:15 PMbillowy-motherboard-58443
10/01/2020, 8:16 PMpip install -U foo
billowy-motherboard-58443
10/01/2020, 8:16 PMbillowy-motherboard-58443
10/01/2020, 8:16 PMhundreds-father-404
10/01/2020, 8:17 PMbillowy-motherboard-58443
10/01/2020, 8:17 PMbillowy-motherboard-58443
10/01/2020, 8:17 PMbillowy-motherboard-58443
10/01/2020, 8:17 PMbillowy-motherboard-58443
10/01/2020, 8:17 PMhundreds-father-404
10/01/2020, 8:20 PMbillowy-motherboard-58443
10/01/2020, 8:22 PMbillowy-motherboard-58443
10/01/2020, 8:22 PMbillowy-motherboard-58443
10/01/2020, 8:22 PMbillowy-motherboard-58443
10/01/2020, 8:23 PMbillowy-motherboard-58443
10/01/2020, 8:23 PMbillowy-motherboard-58443
10/01/2020, 8:24 PMbillowy-motherboard-58443
10/01/2020, 8:24 PMbillowy-motherboard-58443
10/01/2020, 8:25 PMbillowy-motherboard-58443
10/01/2020, 8:25 PMbillowy-motherboard-58443
10/01/2020, 8:25 PMbillowy-motherboard-58443
10/01/2020, 8:25 PMbillowy-motherboard-58443
10/01/2020, 8:25 PMbillowy-motherboard-58443
10/01/2020, 8:26 PMpip install boto3
gets you botocorebillowy-motherboard-58443
10/01/2020, 8:26 PMbillowy-motherboard-58443
10/01/2020, 8:27 PMbillowy-motherboard-58443
10/01/2020, 8:27 PMsetup-py
or similar, sed
the version into the BUILD filehundreds-father-404
10/01/2020, 8:28 PMns/core
, ns/foo
, and ns/bar
all living in the same monorepo. Each of those top-level namespaces is a distinct `python_distribution`/wheel, right? And there might be dependencies between those packages within that same repo.
At the same time, you have several other projects in your org which are not under that monorepo? They live in distinct repositories, and they install from your “lib monorepo” via internal wheels. It sounds like these are more your apps, rather than your core/libs. Is that right?billowy-motherboard-58443
10/01/2020, 8:28 PMbillowy-motherboard-58443
10/01/2020, 8:28 PMbillowy-motherboard-58443
10/01/2020, 8:29 PMhundreds-father-404
10/01/2020, 8:30 PMbillowy-motherboard-58443
10/01/2020, 8:30 PMbillowy-motherboard-58443
10/01/2020, 8:31 PMbillowy-motherboard-58443
10/01/2020, 8:32 PMbillowy-motherboard-58443
10/01/2020, 8:32 PMhundreds-father-404
10/01/2020, 8:33 PMns/foo
truly is correct, that it reflects the state of things. For example, if ns/core
has any changes, then `ns/foo`’s version should be bumped. Is that correct?billowy-motherboard-58443
10/01/2020, 8:33 PMbillowy-motherboard-58443
10/01/2020, 8:34 PMbillowy-motherboard-58443
10/01/2020, 8:34 PMbillowy-motherboard-58443
10/01/2020, 8:34 PMbillowy-motherboard-58443
10/01/2020, 8:35 PMbillowy-motherboard-58443
10/01/2020, 8:36 PMbillowy-motherboard-58443
10/01/2020, 8:36 PMbillowy-motherboard-58443
10/01/2020, 8:36 PMbillowy-motherboard-58443
10/01/2020, 8:37 PMhundreds-father-404
10/01/2020, 8:37 PMsetup-py
kwargs then, which would read from Git and dynamically set the value without ever writing it to a BUILD file. https://www.pantsbuild.org/docs/python-setup-py-goal
Do you already have the logic written for how you read from Git to determine the version? You only need to teach Pants how to read the value, rather than sed-ing your BUILD file?billowy-motherboard-58443
10/01/2020, 8:37 PMhundreds-father-404
10/01/2020, 8:40 PMpython_distribution(
...
provides=setup_py(
..
version=subprocess.run(["git", "version-logic"]),
)
Does that sound right?hundreds-father-404
10/01/2020, 8:41 PMbillowy-motherboard-58443
10/01/2020, 8:42 PMbillowy-motherboard-58443
10/01/2020, 8:44 PMgit tag parent-repo | grep core | sort -V
billowy-motherboard-58443
10/01/2020, 8:44 PMns.foo
buildbillowy-motherboard-58443
10/01/2020, 8:44 PMbillowy-motherboard-58443
10/01/2020, 8:45 PMhundreds-father-404
10/01/2020, 8:45 PMgit tag parent-repo
, and then you could use Python to search and to sort.billowy-motherboard-58443
10/01/2020, 8:45 PMbillowy-motherboard-58443
10/01/2020, 8:45 PMbillowy-motherboard-58443
10/01/2020, 8:45 PMhundreds-father-404
10/01/2020, 8:46 PMbut it would be nicer to be able to pin in a fileTo pin the computed version to a BUILD file? Would that have the same challenge you were originally trying to solve of not wanting the BUILD file persisted to disk?
hundreds-father-404
10/01/2020, 8:47 PMcan one invent other macros? (targets, I guess?)Yes, absolutely. And you can also add new fields to pre-existing target types for consumption by your plugin. See https://www.pantsbuild.org/docs/target-api-concepts for the Target API I’m not sure if that would be what you want to do here, though. I’m trying to figure out the best way to solve the goal you’re after
billowy-motherboard-58443
10/01/2020, 8:47 PMbillowy-motherboard-58443
10/01/2020, 8:48 PMbillowy-motherboard-58443
10/01/2020, 8:48 PMbillowy-motherboard-58443
10/01/2020, 8:49 PMhundreds-father-404
10/01/2020, 8:50 PMI want that in ns/foo/BUILD to pin the version of ns/coreThis goes back to my original comment. I don’t think that this type of workflow works with Pants (or other build tools afaict). You can’t pin to certain versions of your own first-party code in the same monorepo. Your build always represents the current state of things.
billowy-motherboard-58443
10/01/2020, 8:52 PMhundreds-father-404
10/01/2020, 8:54 PMbillowy-motherboard-58443
10/01/2020, 8:54 PMbillowy-motherboard-58443
10/01/2020, 8:54 PMbillowy-motherboard-58443
10/01/2020, 8:54 PMbillowy-motherboard-58443
10/01/2020, 8:55 PMhundreds-father-404
10/01/2020, 9:10 PMversion
(but not write to BUILD). We’d be happy to help with it
Also happy to keep talking through your org’s code structure and whether a build tool like Pants or Bazel is a good fit. Even if y’all do end up going back to a single monolithic distribution, we hope Pants might be helpful in managing that monorepo, like running your tests and linters. And if Pants isn’t a good fit, that’s totally valid too.
Our underlying motivation is to help people to have a solid build experience.billowy-motherboard-58443
10/01/2020, 9:13 PMbillowy-motherboard-58443
10/01/2020, 9:13 PMaloof-angle-91616
10/01/2020, 9:14 PMbillowy-motherboard-58443
10/01/2020, 9:16 PMbillowy-motherboard-58443
10/01/2020, 9:16 PMbillowy-motherboard-58443
10/01/2020, 9:16 PMbillowy-motherboard-58443
10/01/2020, 9:17 PMbillowy-motherboard-58443
10/01/2020, 9:17 PMpip install boto3.s3
because that was the only thing you wanted - and it knew to pull in a pinned (or at least minimum) version of botocorebillowy-motherboard-58443
10/01/2020, 9:17 PMbillowy-motherboard-58443
10/01/2020, 9:25 PMhappy-kitchen-89482
10/01/2020, 10:24 PMhappy-kitchen-89482
10/01/2020, 10:25 PMhundreds-father-404
10/01/2020, 10:26 PMIt sounds like you just need a custom way to generate version numbers based on git state?Yes, but iiuc, the desire is to further be able to pin a portion of the monorepo to a certain state of the rest of the monorepo. Like how you would pin a 3rdparty req to ==x.y.z, but now you’d be doing it with your own first-party code in the same repo.
happy-kitchen-89482
10/01/2020, 10:26 PMA==1.2.3
in its requirements metadata, but when you run B's tests it simply grabs A's code from within the repo?happy-kitchen-89482
10/01/2020, 10:28 PMhundreds-father-404
10/01/2020, 10:29 PMOK, so even at build time (say when running tests) you consume the wheel version, not the raw source?Michael had to log off, but this is my understanding of what he’s after. That’s how the rest of their organization does it; they have several smaller repos that consume this one monorepo of libraries. Those each pin to the particular version they want of the monorepo.
billowy-motherboard-58443
10/02/2020, 1:41 PMif lib B depends on lib A then at deploy time B is a wheel that declares A==1.2.3 in its requirements metadata, but when you run B's tests it simply grabs A's code from within the repo?
billowy-motherboard-58443
10/02/2020, 1:44 PMsetup-py
. But we do have cases, much like for 3rdparty, of wanting to pin an internal dep, just like benjyw said. This sort of 1stparty pin we would explicitly write into B's BUILD file and commit that to version control (just like requirements.txt, etc.)billowy-motherboard-58443
10/02/2020, 1:46 PMsetup-py
that Pants goes and infers "B depends on A; let's look at the version="..."
in A/BUILD and use that value when generating the setup.py `install_requires`"billowy-motherboard-58443
10/02/2020, 1:47 PMpython_distribution
)billowy-motherboard-58443
10/02/2020, 4:24 PMbillowy-motherboard-58443
10/02/2020, 4:24 PMbillowy-motherboard-58443
10/02/2020, 4:26 PMinstall_requires
billowy-motherboard-58443
10/02/2020, 4:26 PMbillowy-motherboard-58443
10/02/2020, 4:29 PMbillowy-motherboard-58443
10/02/2020, 4:30 PMpython_requirement_library(
name="installed_core",
requirements=["ns.core==1.0.0"],
)
python_library(
name="cassandra_leader_election_lib",
sources=['*.py', '!tests'],
dependencies=[
":installed_core"
# "gh/core"
],
)
python_distribution(
name="leader_election_cassandra",
dependencies=[
":cassandra_leader_election_lib",
],
provides=setup_py(
....
)
billowy-motherboard-58443
10/02/2020, 4:31 PMpython_requirement_library()
to create an alias of sortsbillowy-motherboard-58443
10/02/2020, 4:31 PMhappy-kitchen-89482
10/02/2020, 4:44 PMhappy-kitchen-89482
10/02/2020, 4:45 PMpython_requirement_library
I guess.billowy-motherboard-58443
10/02/2020, 4:49 PMhappy-kitchen-89482
10/02/2020, 4:49 PMbillowy-motherboard-58443
10/02/2020, 4:49 PMbillowy-motherboard-58443
10/02/2020, 4:50 PMhappy-kitchen-89482
10/02/2020, 5:57 PMhappy-kitchen-89482
10/02/2020, 5:58 PMpython_distribution
reflects "how to publish A", the python_requirement_library
is "A after it has been published" and the python_library
is "the code of A".billowy-motherboard-58443
10/02/2020, 5:59 PMbillowy-motherboard-58443
10/02/2020, 6:00 PMhappy-kitchen-89482
10/02/2020, 6:00 PMpython_library
of A then it pulls in A's code directly from the repo at the current git sha. If it depends on the python_requirement_library
then it pulls in A's code as-if it was a third party dep.happy-kitchen-89482
10/02/2020, 6:00 PMhappy-kitchen-89482
10/02/2020, 6:00 PMbillowy-motherboard-58443
10/02/2020, 6:01 PMhappy-kitchen-89482
10/02/2020, 10:16 PMpython_requirement_library
instead of the python_library
sounds like exactly the right move.