/scie-pants

Protects your Pants from the elements.

Primary LanguageRustApache License 2.0Apache-2.0

scie-pants

GitHub Github Actions CI (x86_64 Linux / MacOS / Windows) CircleCI (Linux aarch64)

The scie-pants binary is the next-generation ./pants script.

It's currently in production use as the recommended way to install Pants and is suitable for trying out in any existing Pants-using project. We welcome reports of successes, failures and where things work but could be better.

Installing

See the official installation recommendations here for use as your pants launcher: https://www.pantsbuild.org/docs/installation

The binaries are released via GitHub Releases for both Linux and macOS and both aarch64 and x86_64 chip architectures.

If you'd like to build your own version, see the contribution guide. There are build instructions there.

Features

You can run scie-pants anywhere you'd use ./pants and other places besides. It should work just like your existing ./pants script but with ~33% less latency launching Pants.

Beyond support for all known existing ./pants script features, the scie-pants executable provides the following:

  • A hermetic Python interpreter appropriate for the current active Pants version:

    You no longer need to have Python of the right version, or even any Python at all, installed on your system to use Pants. If you use scie-pants in a repo with old Pants (< 2.5.0), it will fetch a CPython 3.8 interpreter to use and a CPython 3.9 interpreter otherwise. These interpreters are self-contained from the Python Build Standalone project.

  • Support for .env files:

    The first .env file found in the current directory or any of its parent directories is loaded and exported into Pants (and scie-pants) environment.

  • The ability to run Pants in a subdirectory of your project:

    This is of limited utility since Pants internals don't support this well at the moment, but as soon as they do, scie-pants will allow you to work in the style you prefer.

  • Built-in ability to set up a new Pants project:

    If you run scie-pants in a directory where Pants is not already set up, it will prompt you, and you can let it set up the latest Pants stable version for your project.

  • Built-in pants_from_sources support. You can either execute scie-pants with PANTS_SOURCE set to the path of a local clone of the Pants repo or else copy, link or symlink your scie-pants executable to pants_from_sources and execute that. In this case PANTS_SOURCE will default to ../pants just as was the case in the bespoke ./pants_from_sources scripts.

  • Partial support for firewalls:

    Currently, you can only re-direct the URLs scie-pants uses to fetch Python Build Standalone CPython distributions it uses to bootstrap Pants with. This is done by exporting a PANTS_BOOTSTRAP_URLS environment variable specifying the path to a JSON file containing a mapping of file names to URLS to fetch them from under a top-level "ptex" key. For example:

    {
      "ptex": {
        "cpython-3.8.16+20230507-x86_64-unknown-linux-gnu-install_only.tar.gz": "https://github.com/indygreg/python-build-standalone/releases/download/20230507/cpython-3.8.16%2B20230507-x86_64-unknown-linux-gnu-install_only.tar.gz",
        "cpython-3.8.16+20230507-aarch64-apple-darwin-install_only.tar.gz": "https://github.com/indygreg/python-build-standalone/releases/download/20230507/cpython-3.8.16%2B20230507-aarch64-apple-darwin-install_only.tar.gz",
        "cpython-3.9.16+20230507-x86_64-unknown-linux-gnu-install_only.tar.gz": "https://github.com/indygreg/python-build-standalone/releases/download/20230507/cpython-3.9.16%2B20230507-x86_64-unknown-linux-gnu-install_only.tar.gz",
        "cpython-3.9.16+20230507-aarch64-apple-darwin-install_only.tar.gz": "https://github.com/indygreg/python-build-standalone/releases/download/20230507/cpython-3.9.16%2B20230507-aarch64-apple-darwin-install_only.tar.gz",
      }
    }

    To see the current mapping used by your version of scie-pants you can run:

    $ SCIE=inspect scie-pants | jq .ptex
    

    You'll need to run this once for each platform you use scie-pants on to gather all mappings you'll need; e.g.: once for Linux x86_64 and once for Mac ARM.

    The keys in your re-mapping must match, but the URLs, of course will be different; presumably from a private network server or file share. The full output of the inspect command can be used to examine the expected file size and hash of each of these distributions. Your re-directed URLs must provide the same content; if the hashes of downloaded files do not match those recorded in scie-pants, install will fail fast and let you know about the hash mismatch. Once Pants itself starts shipping scies, those will also be able to redirected using the same file.

Caveats

The scie-pants binary will re-install versions of Pants you have already installed. The underlying scie technology uses an nce cache directory that is different from the ~/.cache/pants/setup directory used by the ./pants script. This is a one-time event per Pants version.

Solving Problems

Try upgrading

If you run into an issue with scie-pants you might 1st try upgrading. You can do this with:

SCIE_BOOT=update scie-pants

That will update to the latest available stable release if there is a newer one and tell you if there is not. You can also supply a scie-pants version as the sole argument to downgrade or switch to a specific version.

Report an issue

You can report an issue directly at https://github.com/pantsbuild/scie-pants/issues. Please include the scie-pants version you're using. You can get this by running:

PANTS_BOOTSTRAP_VERSION=report scie-pants

You might want to check the existing issues first though. There are some known features and bugs on the roadmap you may have run into and if there is an existing issue, you can chime in on your support for it or your particular take on it.

Chip in

There is a contribution guide and more developer docs are coming soon. Any help fixing bugs or improving UX is very welcome.