Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python_distribution editable installs in exports #18639

Merged
merged 33 commits into from
Apr 10, 2023

Conversation

cognifloyd
Copy link
Member

@cognifloyd cognifloyd commented Mar 31, 2023

About Editable Installs

Editable installs were traditionally done via pip with pip install --editable. It is primarily useful during development when software needs access to the entry points metadata.

When PEP 517 was adopted, they punted on how to allow for editable installs. PEP 660 extended the PEP 517 backend API to support building "editable" wheels. Therefore, there is now a standard way to collect and install the metadata for "editable" installs, using the "editable" wheel as an interchange between the backend (which collects the metadata + builds the editable wheel) and the frontend (which marshals the backend to perform a user-requested "editable" install).

Why would we need editable installs in pants?

I need editable installs in pants-exported virtualenvs so that dev tools outside of pants have access to:

  • The locked requirements
  • The editable sources on the python path
  • The entry points (and any other package metadata that can be loaded from dist-info. Entry points is the biggest most impactful example)

I need to point all the external dev tooling at a virtualenv, and technically I could export a pex that includes all of the python-distributions pre-installed and use pex-tools to create a virtualenv, but then I would have to recreate that venv for every dev change wouldn't be a good dev experience.

One of those dev tools is nosetest. I considred using run to support running that, but I am leary of adding all the complex BUILD machinery to support running a tool that I'm trying to get rid of. Editable installs is a more generic solution that serves my current needs, while allowing for using it in other scenarios.

This PR comes in part from #16621 (comment)

Overview of this PR

Scope & Future work

This PR focuses on adding editable installs to exported virtualenvs. Two other issues ask for editable installs while running tests:

We can probably reuse a significant portion of this to generate editable wheels for use in testing as well. Parts of this code will need to be refactored to support that use case. But we also have to figure out the UX for how users will define dependencies on a python_distribution when they want an editable install instead of the built wheel to show up in the sandbox. Anyway, addressing that is out of scope for this PR.

New option [export].py_editable_in_resolve (a StrListOption)

This option allows user resolves to opt in to using the editable installs. After consulting with @kaos, I decided to add an option for this instead of always trying to generate/install the editable wheels.

python_distribution does not have a resolve field. So figuring out which resolve a python_distribution belongs to can be expensive: calculating the owned deps of all distributions, and for each distribution, look through those deps until one of them has a resolve field, and use that for that dist’s resolve.

Plus there’s the cost of building the PEP-660 wheels - if the configured PEP-517 build backend doesn’t support the PEP-660 methods, then it falls back to a method that is, sadly, optional in PEP-517. If that method isn’t there, then it falls back to telling that backend to build the whole wheel, and then it extracts just the dist-info directory from it and discards the rest.

So, installing these editable wheels isn’t free. It’ll slow down the export, though I’m not sure by how much.

For StackStorm, I plan to set this in pants.toml for the default resolve that has python_distributions.

Even without this option, I tried to bail out early if there were no python_distributions to install.

Installing editable wheels for exports

I added this feature to the new export code path, which requires using export --resolve=. The legacy codepath, which uses cli specs export <address specs> did not change at all. I also ignored the tool resolves which cannot have any relevant dists (and tool resolves are deprecated anyway). Also, this is only for mutable_virtualenv exports, as we need modify the virtualenv to install the editable wheels in the venv after pex creates it from the lockfile.

When exporting a user resolve, we do a Get(EditableLocalDists, EditableLocalDistsRequest(resolve=resolve)): I'll skip over exactly how this builds the wheels for now so this section can focus on how installing works.

if resolve in export_subsys.py_editables_in_resolve:
editable_local_dists = await Get(
EditableLocalDists, EditableLocalDistsRequest(resolve=resolve)
)
editable_local_dists_digest = editable_local_dists.optional_digest
else:
editable_local_dists_digest = None

As described in the commit message of b5aa26a, I tried a variety of methods for installing the editable wheels using pex. Ultimately, the best I came up with is telling pex that the digest containing our editable wheels are sources when building the requirements.pex used to populate the venv, so that they would land in the virtualenv (even though they land as plain wheel files.

Then we run pex-tools in a PostProcessingCommand to create and populate the virtualenv, just as we did before this PR.

Once the virtualenv is created, we add 3 more PostProcessingCommands to actually do the editable install. In this step, Pants is essentially acting as the PEP-660 front end, though we use pip for some of the heavy lifting. These commands:

  1. move the editable wheels out of the virtualenv lib directory to the temp dir that gets deleted at the end of the export
  2. use pip to install all of the editable wheels (which contain a .pth file that injects the source dir into sys.path and a .dist-info directory with dist metadata such as entry points).
  3. replace some of the pip-generated install metadata (*.dist-info/direct_url.json) with our own so that we comply with PEP-660 and mark the install as editable with a file url pointing the the sources in the build_root (vs in a sandbox).

Now, anything that uses the exported venv should have access to the standardized package metadata (in .dist-info) and the relevant source roots should be automatically included in sys.path.

Building PEP-660 editable wheels

The logic that actually builds the editable wheels is in pants.backend.python.util_rules.local_dists_pep660. Building these wheels requires the same chroot that pants uses to build regular wheels and sdists. So, I refactored the rule in util_rules.setup_py so that I could reuse the part that builds the DistBuildRequest.

These local_dists_pep660 rules do approx this, starting with the rule called in export:

  • Get(EditableLocalDists, EditableLocalDistsRequest(resolve=resolve)) uses rule build_editable_local_dists
    • injected arg: ResolveSortedPythonDistributionTargets comes from rule: sort_all_python_distributions_by_resolve
      • injected arg: AllPythonDistributionTargets comes from rule: find_all_python_distributions
    • Get(LocalDistPEP660Wheels, PythonDistributionFieldSet.create(dist)) for each dist in the resolve uses rule: isolate_local_dist_pep660_wheels
      • create DistBuildRequest using the create_dist_build_request method I exposed in util_rules.setup_py
      • Get(PEP660BuildResult, DistBuildRequest) uses rule: run_pep660_build
        • generates the .pth file that goes in the editable wheel
        • runs a PEP 517 build backend wrapper script I wrote
          • uses the PEP 517 build backend configured for the python_distribution to generate the .dist-info directory
          • generates the WHEEL and RECORD file to build a conformant wheel file
          • includes the .pth file previously generated (and placed in the sandbox with the wrapper script)
          • uses zipfile to build the wheel (using a vendored+modified function from the wheel package).
          • prints a path to the generated wheel
      • collects the generated editable wheel into a digest and collects metadata about the digest similar to how the local_dists rules do.
    • merges the editable wheel digests for all of the python_distribution targets. This gets wrapped in EditableLocalDists

Much of the rule logic was based on (copied then modified): pants.backend.python.util_rules.dists and pants.backend.python.util_rules.local_dists.

@cognifloyd cognifloyd added category:new feature backend: Python Python backend-related issues labels Mar 31, 2023
@cognifloyd cognifloyd force-pushed the editables-in-exports branch 4 times, most recently from ce9a9fc to a03b7e5 Compare April 7, 2023 02:37
@cognifloyd cognifloyd self-assigned this Apr 7, 2023
@cognifloyd cognifloyd added this to the 2.17.x milestone Apr 7, 2023
cognifloyd added a commit that referenced this pull request Apr 7, 2023
#18701)

In #18639, I have a change to allow pants to do editable installs of
`python_distribution`s for in exported-mutable virtualenvs of user code.

I need all of the dist chroot setup that happens in the
`package_python_dist` rule, so I extracted everything that creates
`DistBuildRequest` into a separate helper function.
cognifloyd added a commit that referenced this pull request Apr 8, 2023
…d (Cherry-pick of #18701) (#18703)

In #18639, I have a change to allow pants to do editable installs of
`python_distribution`s for in exported-mutable virtualenvs of user code.

I need all of the dist chroot setup that happens in the
`package_python_dist` rule, so I extracted everything that creates
`DistBuildRequest` into a separate helper function.
@cognifloyd
Copy link
Member Author

I made a copy of many of these sources so I could run them as a plugin with pants==2.16.0rc0 in the StackStorm repo.
This is what the output looks like:

(st2export is my lightweight copy of the export goal, so I could wire up my changes from this PR)

$ ./pants st2export --export-resolve=st2
19:34:33.90 [INFO] Initializing scheduler...
19:34:37.95 [INFO] Scheduler initialized.
19:34:59.69 [INFO] Completed: List contents of editable artifacts produced by contrib/runners/inquirer_runner:inquirer_runner
19:34:59.71 [INFO] Completed: List contents of editable artifacts produced by st2client:st2client
19:34:59.71 [INFO] Completed: List contents of editable artifacts produced by contrib/runners/orquesta_runner:orquesta_runner
19:34:59.75 [INFO] Completed: List contents of editable artifacts produced by contrib/runners/winrm_runner:winrm_runner
19:34:59.80 [INFO] Completed: List contents of editable artifacts produced by contrib/runners/local_runner:local_runner
19:34:59.84 [INFO] Completed: List contents of editable artifacts produced by contrib/runners/http_runner:http_runner
19:34:59.88 [INFO] Completed: List contents of editable artifacts produced by contrib/runners/remote_runner:remote_runner
19:34:59.88 [INFO] Completed: List contents of editable artifacts produced by st2tests:st2tests
19:34:59.89 [INFO] Completed: List contents of editable artifacts produced by contrib/runners/python_runner:python_runner
19:34:59.94 [INFO] Completed: List contents of editable artifacts produced by st2api:st2api
19:34:59.94 [INFO] Completed: List contents of editable artifacts produced by st2reactor:st2reactor
19:34:59.94 [INFO] Completed: List contents of editable artifacts produced by contrib/runners/announcement_runner:announcement_runner
19:34:59.95 [INFO] Completed: List contents of editable artifacts produced by st2common:st2common
19:34:59.95 [INFO] Completed: List contents of editable artifacts produced by st2actions:st2actions
19:34:59.96 [INFO] Completed: List contents of editable artifacts produced by st2stream:st2stream
19:34:59.97 [INFO] Completed: List contents of editable artifacts produced by contrib/runners/noop_runner:noop_runner
19:35:00.13 [INFO] Completed: List contents of editable artifacts produced by contrib/runners/action_chain_runner:action_chain_runner
19:35:00.20 [INFO] Completed: List contents of editable artifacts produced by st2auth:st2auth
19:35:06.24 [INFO] Completed: Build pex for resolve `st2`
19:35:09.98 [INFO] Completed: Get interpreter version
/home/cognifloyd/.cache/pants/named_caches/pex_root/installed_wheels/68aebecfd30b9ad462edf73b41e6463402f0d1d1466f19cfaa883347451e1d7e/pex-2.1.131-py2.py3-none-any.whl/pex/tools/commands/venv.py:164: PEXWarning: You asked for --pip to be installed in the venv at /home/cognifloyd/p/st2sandbox/st2.git/dist/export/python/virtualenvs/st2/3.6.15,
but the PEX at /home/cognifloyd/p/st2sandbox/st2.git/dist/export/python/virtualenvs/st2/3.6.15/.9acd66f5e3c644ba8707c16ffe484091.tmp/st2.pex already contains:
pip 21.3.1
setuptools 59.6
Uninstalling venv versions and using versions from the PEX.
  message=message
Uninstalling pip-18.1:
  Successfully uninstalled pip-18.1
Uninstalling setuptools-40.6.2:
  Successfully uninstalled setuptools-40.6.2
Processing ./dist/export/python/virtualenvs/st2/3.6.15/.9acd66f5e3c644ba8707c16ffe484091.tmp/st2actions-3.9.dev0-0.editable-py3-none-any.whl
Processing ./dist/export/python/virtualenvs/st2/3.6.15/.9acd66f5e3c644ba8707c16ffe484091.tmp/st2api-3.9.dev0-0.editable-py3-none-any.whl
Processing ./dist/export/python/virtualenvs/st2/3.6.15/.9acd66f5e3c644ba8707c16ffe484091.tmp/st2auth-3.9.dev0-0.editable-py3-none-any.whl
Processing ./dist/export/python/virtualenvs/st2/3.6.15/.9acd66f5e3c644ba8707c16ffe484091.tmp/st2client-3.9.dev0-0.editable-py3-none-any.whl
Processing ./dist/export/python/virtualenvs/st2/3.6.15/.9acd66f5e3c644ba8707c16ffe484091.tmp/st2common-3.9.dev0-0.editable-py3-none-any.whl
Processing ./dist/export/python/virtualenvs/st2/3.6.15/.9acd66f5e3c644ba8707c16ffe484091.tmp/st2reactor-3.9.dev0-0.editable-py3-none-any.whl
Processing ./dist/export/python/virtualenvs/st2/3.6.15/.9acd66f5e3c644ba8707c16ffe484091.tmp/st2stream-3.9.dev0-0.editable-py3-none-any.whl
Processing ./dist/export/python/virtualenvs/st2/3.6.15/.9acd66f5e3c644ba8707c16ffe484091.tmp/st2tests-3.9.dev0-0.editable-py3-none-any.whl
Processing ./dist/export/python/virtualenvs/st2/3.6.15/.9acd66f5e3c644ba8707c16ffe484091.tmp/stackstorm_runner_action_chain-3.9.dev0-0.editable-py3-none-any.whl
Processing ./dist/export/python/virtualenvs/st2/3.6.15/.9acd66f5e3c644ba8707c16ffe484091.tmp/stackstorm_runner_announcement-3.9.dev0-0.editable-py3-none-any.whl
Processing ./dist/export/python/virtualenvs/st2/3.6.15/.9acd66f5e3c644ba8707c16ffe484091.tmp/stackstorm_runner_http-3.9.dev0-0.editable-py3-none-any.whl
Processing ./dist/export/python/virtualenvs/st2/3.6.15/.9acd66f5e3c644ba8707c16ffe484091.tmp/stackstorm_runner_inquirer-3.9.dev0-0.editable-py3-none-any.whl
Processing ./dist/export/python/virtualenvs/st2/3.6.15/.9acd66f5e3c644ba8707c16ffe484091.tmp/stackstorm_runner_local-3.9.dev0-0.editable-py3-none-any.whl
Processing ./dist/export/python/virtualenvs/st2/3.6.15/.9acd66f5e3c644ba8707c16ffe484091.tmp/stackstorm_runner_noop-3.9.dev0-0.editable-py3-none-any.whl
Processing ./dist/export/python/virtualenvs/st2/3.6.15/.9acd66f5e3c644ba8707c16ffe484091.tmp/stackstorm_runner_orquesta-3.9.dev0-0.editable-py3-none-any.whl
Processing ./dist/export/python/virtualenvs/st2/3.6.15/.9acd66f5e3c644ba8707c16ffe484091.tmp/stackstorm_runner_python-3.9.dev0-0.editable-py3-none-any.whl
Processing ./dist/export/python/virtualenvs/st2/3.6.15/.9acd66f5e3c644ba8707c16ffe484091.tmp/stackstorm_runner_remote-3.9.dev0-0.editable-py3-none-any.whl
Processing ./dist/export/python/virtualenvs/st2/3.6.15/.9acd66f5e3c644ba8707c16ffe484091.tmp/stackstorm_runner_winrm-3.9.dev0-0.editable-py3-none-any.whl
Installing collected packages: stackstorm-runner-winrm, stackstorm-runner-remote, stackstorm-runner-python, stackstorm-runner-orquesta, stackstorm-runner-noop, stackstorm-runner-local, stackstorm-runner-inquirer, stackstorm-runner-http, stackstorm-runner-announcement, stackstorm-runner-action-chain, st2tests, st2stream, st2reactor, st2common, st2client, st2auth, st2api, st2actions
Successfully installed st2actions-3.9.dev0 st2api-3.9.dev0 st2auth-3.9.dev0 st2client-3.9.dev0 st2common-3.9.dev0 st2reactor-3.9.dev0 st2stream-3.9.dev0 st2tests-3.9.dev0 stackstorm-runner-action-chain-3.9.dev0 stackstorm-runner-announcement-3.9.dev0 stackstorm-runner-http-3.9.dev0 stackstorm-runner-inquirer-3.9.dev0 stackstorm-runner-local-3.9.dev0 stackstorm-runner-noop-3.9.dev0 stackstorm-runner-orquesta-3.9.dev0 stackstorm-runner-python-3.9.dev0 stackstorm-runner-remote-3.9.dev0 stackstorm-runner-winrm-3.9.dev0
Wrote mutable virtualenv for st2 (using Python 3.6.15) to dist/export/python/virtualenvs/st2/3.6.15

@cognifloyd cognifloyd marked this pull request as ready for review April 8, 2023 01:42
cognifloyd added a commit that referenced this pull request Apr 8, 2023
….py` + `subsystems/setup_py_generation.py` (#18702)

In pants v1, there was a [`setup-py`
goal](https://v1.pantsbuild.org/options_reference.html#setup-py). In
pants v2, that is now part of the more generic [`package`
goal](https://www.pantsbuild.org/docs/python-package-goal). So, the name
`setup_py` doesn't make sense any more.

Also, most of the rules in that file are used in contexts other than the
`package` goal. For instance, I'm using them in #18639 in the `export`
goal. And importing something from `goals` in `util_rules` feels rather
odd. So, I would like to see most of these rules under `util_rules`.

This change does the following:
- renames: `pants.backends.python.goals.setup_py` to
`pants.backends.python.util_rules.package_dists`
- adds a minimal: `pants.backends.python.goals.package_dists`
- moves `SetupPyGeneration(Subsystem)` to
`pants.backends.python.subsystems.setup_py_generation`
- adjusts imports to use the new locations as needed.
Copy link
Member

@kaos kaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome 🚀
Only left some minor nits.

Some of which certainly comes from my ignorance of Python build/packaging particulars. :)

src/python/pants/backend/python/goals/export.py Outdated Show resolved Hide resolved
@@ -123,6 +128,30 @@ class ExportPluginOptions:
removal_hint="Set the `[export].py_resolve_format` option to 'symlinked_immutable_virtualenv'",
)

py_editables_in_resolves = StrListOption(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This option name reads weird to me, but I've not yet been able to come up with something better..

Copy link
Sponsor Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I have also failed to come up with anything.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went through a lot of different names - I tried putting it on a PythonSetup(Subsystem) but that felt weird because this is specifically about export. So, then I moved it here and went with the py_ prefix similar to py_resolve_format. I'm still not entirely happy with it. But, this is the least bad I've come up with so far.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about py_editable_by_resolve?

I know it's a list; so plural. But it is used on a "one by one" basis, so this reads better to me. It answers: "Are python distributions to be installed in editable mode in this resolve?" for a given resolve. The "editable" thing is not plural in that question, nor is the resolve, but the source for the answer is used for multiple instances of that question.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each dist in the resolve is installed as editable, which is why I was thinking of using editables -- each resolve has more than one editable wheel installed.

As I struggle with naming this, one thing I'm worried about is: You can do an editable install of ~anything. If you request an editable install of a git repo, for example, pip will clone it and then you'll be able to see where it is cloned in pip list output. So, I want to make it clear that this is only editable for first party code.

That said, Hmm. by makes this sound like a map. I could however drop the plural and do py_editable_in_resolve. Is that any better?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That said, Hmm. by makes this sound like a map. I could however drop the plural and do py_editable_in_resolve. Is that any better?

To me, yes. As I see the editable as an adjective describing how something(s) are installed it looks weird to pluralize it. Maybe I'm overanalyzing this however.. language is.. rather subjective, perhaps.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I just pushed a change with py_editable_in_resolve.

src/python/pants/backend/python/goals/export.py Outdated Show resolved Hide resolved
@benjyw
Copy link
Sponsor Contributor

benjyw commented Apr 8, 2023

Before I even review, thanks for the very detailed and helpful PR description!

Copy link
Sponsor Contributor

@benjyw benjyw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! That is a lot of new machinery, but the tests are good and it's off by default, so that's OK.

LGTM mod @kaos's comments, which I agree with.

@@ -123,6 +128,30 @@ class ExportPluginOptions:
removal_hint="Set the `[export].py_resolve_format` option to 'symlinked_immutable_virtualenv'",
)

py_editables_in_resolves = StrListOption(
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I have also failed to come up with anything.

editable_wheel_path: str | None


# PEP 660 defines `prepare_metadata_for_build_editable`. If PEP 660 is not
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If PEP 660 is not supported by whom? This is for in-repo, first-party code, right? So we could require that you support PEP 660 (and maybe the PEP 517 fallback)? It is in the user's power to make that so.

I'm not necessarily proposing changes, more trying to understand the context, and how much bad stuff in the wild this is expected to handle?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PEP 660 is fairly new - it was marked as final only 10 months ago, which is a fairly short period of time for python packaging.

I'm still using python3.6 (sadly), and the version of setuptools that supports python3.6 does not support PEP 660. And, that older version of setuptools generated dist-info directories named pkg_name.dist-info instead of pkg_name-version.dist-info. So, I needed to handle most of these quirks for st2 where I want to use this feature.

The one quirk I didn't encounter was falling back to build_wheel. I have not reviewed the implementations of anything other than setuptools, so if there is a version (prob an older version) of poetry, pdm, flint, or whatever that people have configured as their PEP-517 backend, then this is required to fully support the PEP-517 and PEP-660 specs. In this section of PEP 517, it highlights:

One specific consequence of this is that in this PEP, we’re able to make the prepare_metadata_for_build_wheel command optional. In our design, this can be readily handled by build frontends, which can put code in their subprocess runner like:

And then it shows a code block that falls back to build_wheel and then runs an undefined unzip_metadata function to get the metadata.

So we could require that you support PEP 660 (and maybe the PEP 517 fallback)? It is in the user's power to make that so.

The backend does not actually have to support PEP 660 because we cannot delegate building the wheel to an external backend. We cannot delegate building the editable wheel because we're running in a sandbox and the spec doesn't give us a way to provide which directory should be used as the editable sources. So, all we're using the backend for is to get the wheel metadata. Though it does not need to implement PEP 660, it must support PEP 517. Basically, Pants becomes the PEP 660-compliant frontend + backend, delegating metadata creation to the user-requested PEP-517 backend.

Copy link
Member

@kaos kaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. 👍🏽

I've got a option name suggestion, perhaps an improvement? Otherwise I think this is good to land.

@@ -123,6 +128,30 @@ class ExportPluginOptions:
removal_hint="Set the `[export].py_resolve_format` option to 'symlinked_immutable_virtualenv'",
)

py_editables_in_resolves = StrListOption(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about py_editable_by_resolve?

I know it's a list; so plural. But it is used on a "one by one" basis, so this reads better to me. It answers: "Are python distributions to be installed in editable mode in this resolve?" for a given resolve. The "editable" thing is not plural in that question, nor is the resolve, but the source for the answer is used for multiple instances of that question.

@@ -146,6 +146,7 @@ class DistBuildResult:
_BACKEND_SHIM_BOILERPLATE = """
# DO NOT EDIT THIS FILE -- AUTOGENERATED BY PANTS

import errno
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flake8 complained about missing errno in my backend wrapper script - and I copied the use of errno from this shim script, so this needs the errno import as well.

@cognifloyd
Copy link
Member Author

K. I finished refactoring the backend wrapper into a separate resource script. And now CI is passing.

@kaos and @benjyw could you take another look before we merge this?

src/python/pants/backend/python/util_rules/BUILD Outdated Show resolved Hide resolved
Comment on lines +164 to +168
# The backend_wrapper has its own digest for cache reuse.
Get(
Digest,
CreateDigest([FileContent(backend_wrapper_path, backend_wrapper_content)]),
),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason this isn't part of the previous CreateDigest?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and now I see the comment--lol :p

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how big impact it has, if any, though.. curious what @stuhood thinks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how much of an impact it has. For ST2 we have 18 dists, each of which will have a different set of settings to pass in (in the conf_digest) but the backend_wrapper is the same for all of them. So, I figured I'd split the 2 digests up here.

We do merge the digests below, but we would have to do that merge anyway to include any input digest.

I can combine them. I don't know what impact it has one way or another, but I suspect this is at least marginally better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea I've no clue either. Guess it'll comer down to the performance of materializing an extra file in a digest vs running an additional (with cached result) workunit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend: Python Python backend-related issues category:new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants