Is there anyway to know the external dependencies ...
# general
n
Is there anyway to know the external dependencies ahead of time so we can take care of those requirements w/o Pants trying to access internet?
e
Yes, run
./pants help tools
. You'll get information about each tool we use and either the Python requirements that we grab the tool via or else the URLs we fetch the tool from.
That's pretty new, available in Pants 2.8.x and newer: https://pypi.org/project/pantsbuild.pants/2.8.0rc5/
n
Ah, at the moment we only have 2.7.1 available internally.
Can you show me the commit for that CLI option? Maybe I can just copy it into my local install if the feature is isn't too scattered.
Also had Pex 2.1.54 installed already in the virtual environment; is this not enough to satisfy Pants or does it insist on downloading a specific binary (that hashes the same)?
e
Pants tries very hard to ignore your environment and be fully hermetic so a build that passes on your machine passes on mine. Anything installed in a venv used to run Pants is - hopefully - ignored. Except for the python interpreter and its stdlib.
n
Gotcha. That explains why even after pip installing, it still went through the entire process again (and forced us to configure it to use internal Artifactory/SSL). So where should I place these binaries it does not fetch from PyPI if the only option is to retrieve them directly myself (not sure how esay it will be for us to host binaries in a downloadable location, unless a network file location would work).
e
Yeah - you must provide a shared filesystem or an http server if you can't get these from the internet. Each tool will need to be (re)configured to point at that internal location.
Here's the list from main:
Copy code
$ ./pants help tools

External Tools
--------------

autoflake          The Autoflake Python code formatter (<https://github.com/myint/autoflake>).
                   Version: autoflake==1.4

black              The Black Python code formatter (<https://black.readthedocs.io/>).
                   Version: black==21.9b0

coursier           A dependency resolver for the Maven ecosystem.
                   Version: v2.0.16-169-g194ebc55c
                   URL template: <https://github.com/coursier/coursier/releases/download/{version}/cs-{platform}.gz>

coverage-py        Configuration for Python test coverage measurement.
                   Version: coverage[toml]>=5.5,<5.6

docformatter       The Python docformatter tool (<https://github.com/myint/docformatter>).
                   Version: docformatter>=1.4,<1.5

dockerfile-parser  Used to parse Dockerfile build specs to infer their dependencies.
                   Version: dockerfile==3.2.0

download-pex-bin   The PEX (Python EXecutable) tool (<https://github.com/pantsbuild/pex>).
                   Version: v2.1.54
                   URL template: <https://github.com/pantsbuild/pex/releases/download/{version}/pex>

flake8             The Flake8 Python linter (<https://flake8.pycqa.org/>).
                   Version: flake8>=3.9.2,<4.0

ipython            The IPython enhanced REPL (<https://ipython.org/>).
                   Version: ipython==7.16.1

isort              The Python import sorter tool (<https://pycqa.github.io/isort/>).
                   Version: isort[pyproject,colors]>=5.9.3,<6.0

mypy               The MyPy Python type checker (<http://mypy-lang.org/>).
                   Version: mypy==0.910

poetry             Used to generate lockfiles for third-party Python dependencies.
                   Version: poetry==1.1.8

pytest             The pytest Python test framework (<https://docs.pytest.org/>).
                   Version: pytest>=6.2.4,<6.3

scala              Scala programming language
                   Version: 2.13.6

scc                The Succinct Code Counter, aka `scc` (<https://github.com/boyter/scc>).
                   Version: 3.0.0
                   URL template: <https://github.com/boyter/scc/releases/download/v{version}/scc-{version}-{platform}.zip>

setuptools         Python setuptools, used to package `python_distribution` targets.
                   Version: setuptools>=50.3.0,<58.0

shellcheck         A linter for shell scripts.
                   Version: v0.7.1
                   URL template: <https://github.com/koalaman/shellcheck/releases/download/{version}/shellcheck-{version}.{platform}.tar.xz>

shfmt              An autoformatter for shell scripts (<https://github.com/mvdan/sh>).
                   Version: v3.2.4
                   URL template: <https://github.com/mvdan/sh/releases/download/{version}/shfmt_{version}_{platform}>

twine              The utility for publishing Python distributions to PyPi and other Python repositories.
                   Version: twine==3.4.2

Use `./pants help $tool` to get help for a specific tool.
n
Ok this is helpful. I can fetch all of these from my desktop and then place them on an accessible network drive Pants (running on a Linux host) will have access to. When you say configure each tool, is that in pants.toml and which field am I setting (don't have access to the docs rn, but I think it's in the tools or 3rd part deps section?)
💯 1
e
So, lets take
download-pex-bin
for example. You'd then ask for
./pants help-advanced
for that tool:
Copy code
$ ./pants help-advanced download-pex-bin

`download-pex-bin` subsystem options
------------------------------------

The PEX (Python EXecutable) tool (<https://github.com/pantsbuild/pex>).
 
Config section: [download-pex-bin]
 
None available.

`download-pex-bin` subsystem advanced options
---------------------------------------------
 
  --download-pex-bin-version=<str>
  PANTS_DOWNLOAD_PEX_BIN_VERSION
  version
      default: v2.1.54
      current value: v2.1.54
      Use this version of pex.
      
      Supported pex versions: >=2.1.51,<3.0

  --download-pex-bin-known-versions="['<str>', '<str>', ...]"
  PANTS_DOWNLOAD_PEX_BIN_KNOWN_VERSIONS
  known_versions
      default: [
          "v2.1.54|macos_arm64|c892c82961f73e41aaafad3c692cfd51f6013bed2f7b408041be6c1b90d06451|3679238",
          "v2.1.54|macos_x86_64|c892c82961f73e41aaafad3c692cfd51f6013bed2f7b408041be6c1b90d06451|3679238",
          "v2.1.54|linux_x86_64|c892c82961f73e41aaafad3c692cfd51f6013bed2f7b408041be6c1b90d06451|3679238"
      ]
      current value: [
          "v2.1.54|macos_arm64|c892c82961f73e41aaafad3c692cfd51f6013bed2f7b408041be6c1b90d06451|3679238",
          "v2.1.54|macos_x86_64|c892c82961f73e41aaafad3c692cfd51f6013bed2f7b408041be6c1b90d06451|3679238",
          "v2.1.54|linux_x86_64|c892c82961f73e41aaafad3c692cfd51f6013bed2f7b408041be6c1b90d06451|3679238"
      ]
      
      Known versions to verify downloads against.
      
      Each element is a pipe-separated string of `version|platform|sha256|length`, where:
      
        - `version` is the version string
        - `platform` is one of [linux_arm64,linux_x86_64,macos_arm64,macos_x86_64],
        - `sha256` is the 64-character hex representation of the expected sha256
          digest of the download file, as emitted by `shasum -a 256`
        - `length` is the expected length of the download file in bytes, as emitted by
          `wc -c`
      
      E.g., `3.1.2|macos_x86_64|6d0f18cd84b918c7b3edd0203e75569e0c7caecb1367bbbe409b44e28514f5be|42813`.
      
      Values are space-stripped, so pipes can be indented for readability if necessary.

  --download-pex-bin-use-unsupported-version=<UnsupportedVersionUsage>
  PANTS_DOWNLOAD_PEX_BIN_USE_UNSUPPORTED_VERSION
  use_unsupported_version
      one of: [error, warning]
      default: error
      current value: error
      
      What action to take in case the requested version of pex is not supported.
      
      Supported pex versions: >=2.1.51,<3.0

  --download-pex-bin-url-template=<str>
  PANTS_DOWNLOAD_PEX_BIN_URL_TEMPLATE
  url_template
      default: <https://github.com/pantsbuild/pex/releases/download/{version}/pex>
      current value: <https://github.com/pantsbuild/pex/releases/download/{version}/pex>
      URL to download the tool, either as a single binary file or a compressed file (e.g. zip file). You can change this to point to your own hosted file, e.g. to work with proxies or for access via the filesystem through a `file:$abspath` URL (e.g.
      `file:/this/is/absolute`, possibly by [templating the buildroot in a config file](<https://www.pantsbuild.org/v2.9/docs/options#config-file-entries))>.
      
      Use `{version}` to have the value from --version substituted, and `{platform}` to have a value from --url-platform-mapping substituted in, depending on the current platform. For example, <https://github.com/.../protoc-{version}-{platform}.zip>.

  --download-pex-bin-url-platform-mapping="{'key1': val1, 'key2': val2, ...}"
  PANTS_DOWNLOAD_PEX_BIN_URL_PLATFORM_MAPPING
  url_platform_mapping
      default: {}
      current value: {}
      A dictionary mapping platforms to strings to be used when generating the URL to download the tool.
      
      In --url-template, anytime the `{platform}` string is used, Pants will determine the current platform, and substitute `{platform}` with the respective value from your dictionary.
      
      For example, if you define `{"macos_x86_64": "apple-darwin", "linux_x86_64": "unknown-linux"}, and run Pants on Linux with an intel architecture, then `{platform}` will be substituted in the --url-template option with unknown-linux.


`download-pex-bin` subsystem deprecated options
-----------------------------------------------
 
None available.
That gives you the details of which options to set.
🙌 2
Yeah - "configure each tool" means setting options in pants.toml.
It would be really useful if we had a `./pants offline tools`goal wouldn't it? That would maybe look like:
./pants offline tools --dir=/download/here/please
and that would both download all tools known and output the configuration you'd need to add to pants.toml to point to those tools.
👍 2
💯 1
If you agree, it would mean alot to have that feature request come from a user with your own details about how this would best work for you. If you're willing to file a GitHub issue, that would be great.
n
well, assuming we move forward w/ pants as our main build automation tool (and get our firm to stop blocking humbug as a dependency), would be happy to!
🙌 2
agree it makes a lot of sense for users in a commercial environment where there's no internet access
h
That would be an awesome feature!
e
Hrm, the humbug thing is unfortunate since its opt-in.
h
I tried to implement something like it in Pants v1 years ago, but never got it quite over the finish line (this sort of thing is much easier to do in v2)
n
yah so the pants wheel is on our artifactory, but when trying to install it gets blocked by humbug dependency not being there because of some tbd issue with the scanner
i got around it, but it's hard hwen pants wants to bootstrap itself
and impossible in a Jenkins job, so we can only test locally for now
h
We can finesse the humbug issue if we must
n
i'll report back here what the reason for them rejecting humbug is
if it's not serious, i don't think it will matterin the long-run
h
we have a good relationship with the humbug folks, so if it requires changes on their end I think we can make those happen
e
Ok. Well, it would definitely make sense for the pants script to use
pantsbuild.pants[telemetry]
by default, but allow you to opt out and just have it use
pantsbuild.pants
. We don't have
humbug
set up as a
telemetry
extra today, but we could structure it that way if this is a (common) problem.
👆 2
n
let me see right now if i can find out what our xray blocked it, not sure if it's license, security, unsupported dependency, or what
why*
e
Just to be clear for other readers, humbug is an unconditional dependency right now, you can't opt out of that yet, but the telemetry it provides is opt-in. We nag you to add a pants.toml config to turn it on or off explicitly, but its off implicitly by defaqult.
h
I.e., if you don't opt in, humbug code is inert, but still present.
n
Good news, my request to get humbug cleared was approved because I was able to clean reinstall Pants w/ no issues. And I got it to use a file:// url for Pex. Hung up on another issue now though, will post a different thread.
That means we have a much higher chance now of being able to use Pants running from arbitrary build hosts/uids 🙂
❤️ 1
👍 1
And sry the other "issue" is building the black.pex from black_default_lockfile.txt taking awhile, wasn't sure if it was another connection about to timeout
Just ran black on the entire proto repo: "Oh no! 8 files would be reformatted, 99 files would be left unchanged." Feels good!
💯 1
Thx for all your help guys, I can submit that feature request on Github tomorrow
h
You're welcome! Check back any time if we can be helpful.
1
w
we should probably start a new thread about your original screenshot though… we should definitely never download the same file multiple times in parallel!
h
I don't think we are - I think that's the dynamic UI not rendering correctly. Look at the timestamps
w
oh, it’s being smeared downward… got it. @nice-florist-55958: do you commonly see the UI smearing like that? we attempt to disable it in locations without a real TTY, but it looks like we failed in this case
1
n
@witty-crayon-22786 So far only when trying to download a binary on the internet like this. This is using PyCharm Professional’s terminal on Linux. Didn’t think to mention it, but it goes wild for a bit spamming the download attempt message and flickering. Also doesn’t gracefully exit after a keyboard interrupt until after several minutes go by. Btw at the office now and was able to successfully deploy pants on production CI servers! Will experiment with some workflows (including multiplatform) and see how it goes.
👀 1
🚀 1
w
ah, got it. sorry for the trouble… you can disable the UI with
--no-dynamic-ui
, but i’ll open an issue about that. EDIT: https://github.com/pantsbuild/pants/issues/13595
🙌 1