forked from pantsbuild/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor V2 PEX creation rules (pantsbuild#8080)
pantsbuild#8063 was originally going to result in creating a `SourcesPex` (in addition to `RequirementsPex`). In preparation for that, the below refactors were made. Even though the approach to pantsbuild#8063 has changed, these are good changes to make in general and may be useful to porting `./pants binary`. * Extract out `download_pex_bin` rule. * Rename `resolve_requirements.py` -> `create_requirements_pex.py` for more explicit name (and avoid name clash with V1 file). * Fix shadowing variable name. * Use long CLI args.
- Loading branch information
1 parent
37cb2d6
commit f9bb8d6
Showing
6 changed files
with
77 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from pants.engine.fs import Digest, Snapshot, UrlToFetch | ||
from pants.engine.rules import rule | ||
from pants.engine.selectors import Get | ||
from pants.util.objects import datatype | ||
|
||
|
||
class DownloadedPexBin(datatype([('executable', str), ('directory_digest', Digest)])): | ||
pass | ||
|
||
|
||
@rule(DownloadedPexBin, []) | ||
def download_pex_bin(): | ||
# TODO: Inject versions and digests here through some option, rather than hard-coding it. | ||
url = 'https://github.com/pantsbuild/pex/releases/download/v1.6.8/pex' | ||
digest = Digest('2ca320aede7e7bbcb907af54c9de832707a1df965fb5a0d560f2df29ba8a2f3d', 1866441) | ||
snapshot = yield Get(Snapshot, UrlToFetch(url, digest)) | ||
yield DownloadedPexBin(executable=snapshot.files[0], directory_digest=snapshot.directory_digest) | ||
|
||
|
||
def rules(): | ||
return [ | ||
download_pex_bin, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters