From afa8d823cd9f1b655ce060b29b8da315e3b167ff Mon Sep 17 00:00:00 2001 From: Asher Foa Date: Fri, 6 Jan 2023 16:42:44 -0500 Subject: [PATCH 01/26] Upgrade toolchain plugin and config for toolchain (#117) --- pants.toml | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/pants.toml b/pants.toml index 69e8306..8f72070 100644 --- a/pants.toml +++ b/pants.toml @@ -12,20 +12,23 @@ backend_packages.add = [ "pants.backend.python.typecheck.mypy", ] -# Pants' sponsor, Toolchain, offers remote caching, which can improve your CI performance -# with minimal configuration. For more details, visit https://toolchain.com +# Pants' sponsor, Toolchain, offers remote caching, which can improve your CI performance with minimal configuration. +# Visit https://toolchain.com to enable and try it on your repository +# docs: https://docs.toolchain.com/docs plugins.add = [ - "toolchain.pants.plugin==0.20.0", + "toolchain.pants.plugin==0.25.0", ] - remote_cache_read = false remote_cache_write = false -remote_store_address = "grpcs://cache.toolchain.com:443" -remote_auth_plugin = "toolchain.pants.auth.plugin:toolchain_auth_plugin" -# End Toolchain-specific configuration +[toolchain-setup] +repo = "example-python" +org = "pantsbuild" +[buildsense] +enable = false +# End Toolchain-specific configuration [anonymous-telemetry] enabled = true @@ -58,14 +61,3 @@ resolves = { python-default = "python-default.lock"} # problematic system Pythons. See # https://www.pantsbuild.org/docs/python-interpreter-compatibility#changing-the-interpreter-search-path. search_path = ["", ""] - - -# Configuration for Toolchain instrumentation and remote caching -# Visit https://toolchain.com to enable and try it on your repository - -[toolchain-setup] -repo = "pants" -org = "example-python" - -[buildsense] -enable = false From 7cf8c0fefe27be4444a165e1229ea0ce31c91baf Mon Sep 17 00:00:00 2001 From: Asher Foa Date: Fri, 20 Jan 2023 11:33:10 -0500 Subject: [PATCH 02/26] Update pytest & running tailor in CI (#119) see: https://github.com/pantsbuild/example-python/pull/109#issuecomment-1282640689 --- .github/workflows/pants.yaml | 3 +- python-default.lock | 118 +++++++++++++---------------------- requirements.txt | 2 +- 3 files changed, 48 insertions(+), 75 deletions(-) diff --git a/.github/workflows/pants.yaml b/.github/workflows/pants.yaml index b502253..e3aa38e 100644 --- a/.github/workflows/pants.yaml +++ b/.github/workflows/pants.yaml @@ -46,7 +46,8 @@ jobs: # See https://pants.readme.io/docs/using-pants-in-ci for tips on how to periodically clean it up. # Alternatively you change gha-cache-key to ignore old caches. - name: Check BUILD files - run: ./pants tailor --check update-build-files --check + run: | + ./pants tailor --check update-build-files --check :: - name: Lint and typecheck run: | ./pants lint check :: diff --git a/python-default.lock b/python-default.lock index 498b4eb..0bfb6b1 100644 --- a/python-default.lock +++ b/python-default.lock @@ -10,7 +10,7 @@ // ], // "generated_with_requirements": [ // "ansicolors==1.1.8", -// "pytest==7.0.1", +// "pytest==7.1.3", // "setuptools<57,>=56.2.0", // "types-setuptools<58,>=56.2.0" // ], @@ -52,89 +52,83 @@ "artifacts": [ { "algorithm": "sha256", - "hash": "86efa402f67bf2df34f51a335487cf46b1ec130d02b8d39fd248abfd30da551c", - "url": "https://files.pythonhosted.org/packages/f2/bc/d817287d1aa01878af07c19505fafd1165cd6a119e9d0821ca1d1c20312d/attrs-22.1.0-py2.py3-none-any.whl" + "hash": "29e95c7f6778868dbd49170f98f8818f78f3dc5e0e37c0b1f474e3561b240836", + "url": "https://files.pythonhosted.org/packages/fb/6e/6f83bf616d2becdf333a1640f1d463fef3150e2e926b7010cb0f81c95e88/attrs-22.2.0-py3-none-any.whl" }, { "algorithm": "sha256", - "hash": "29adc2665447e5191d0e7c568fde78b21f9672d344281d0c6e1ab085429b22b6", - "url": "https://files.pythonhosted.org/packages/1a/cb/c4ffeb41e7137b23755a45e1bfec9cbb76ecf51874c6f1d113984ecaa32c/attrs-22.1.0.tar.gz" + "hash": "c9227bfc2f01993c03f68db37d1d15c9690188323c067c641f1a35ca58185f99", + "url": "https://files.pythonhosted.org/packages/21/31/3f468da74c7de4fcf9b25591e682856389b3400b4b62f201e65f15ea3e07/attrs-22.2.0.tar.gz" } ], "project_name": "attrs", "requires_dists": [ - "cloudpickle; platform_python_implementation == \"CPython\" and extra == \"dev\"", - "cloudpickle; platform_python_implementation == \"CPython\" and extra == \"tests\"", + "attrs[docs,tests]; extra == \"dev\"", + "attrs[tests-no-zope]; extra == \"tests\"", + "attrs[tests]; extra == \"cov\"", + "cloudpickle; platform_python_implementation == \"CPython\" and extra == \"tests-no-zope\"", "cloudpickle; platform_python_implementation == \"CPython\" and extra == \"tests_no_zope\"", - "coverage[toml]>=5.0.2; extra == \"dev\"", - "coverage[toml]>=5.0.2; extra == \"tests\"", - "coverage[toml]>=5.0.2; extra == \"tests_no_zope\"", - "furo; extra == \"dev\"", + "coverage-enable-subprocess; extra == \"cov\"", + "coverage[toml]>=5.3; extra == \"cov\"", "furo; extra == \"docs\"", - "hypothesis; extra == \"dev\"", - "hypothesis; extra == \"tests\"", + "hypothesis; extra == \"tests-no-zope\"", "hypothesis; extra == \"tests_no_zope\"", - "mypy!=0.940,>=0.900; extra == \"dev\"", - "mypy!=0.940,>=0.900; extra == \"tests\"", - "mypy!=0.940,>=0.900; extra == \"tests_no_zope\"", - "pre-commit; extra == \"dev\"", - "pympler; extra == \"dev\"", - "pympler; extra == \"tests\"", + "mypy<0.990,>=0.971; platform_python_implementation == \"CPython\" and extra == \"tests-no-zope\"", + "mypy<0.990,>=0.971; platform_python_implementation == \"CPython\" and extra == \"tests_no_zope\"", + "myst-parser; extra == \"docs\"", + "pympler; extra == \"tests-no-zope\"", "pympler; extra == \"tests_no_zope\"", - "pytest-mypy-plugins; extra == \"dev\"", - "pytest-mypy-plugins; extra == \"tests\"", - "pytest-mypy-plugins; extra == \"tests_no_zope\"", - "pytest>=4.3.0; extra == \"dev\"", - "pytest>=4.3.0; extra == \"tests\"", + "pytest-mypy-plugins; (platform_python_implementation == \"CPython\" and python_version < \"3.11\") and extra == \"tests-no-zope\"", + "pytest-mypy-plugins; (platform_python_implementation == \"CPython\" and python_version < \"3.11\") and extra == \"tests_no_zope\"", + "pytest-xdist[psutil]; extra == \"tests-no-zope\"", + "pytest-xdist[psutil]; extra == \"tests_no_zope\"", + "pytest>=4.3.0; extra == \"tests-no-zope\"", "pytest>=4.3.0; extra == \"tests_no_zope\"", - "sphinx-notfound-page; extra == \"dev\"", "sphinx-notfound-page; extra == \"docs\"", - "sphinx; extra == \"dev\"", "sphinx; extra == \"docs\"", - "zope.interface; extra == \"dev\"", + "sphinxcontrib-towncrier; extra == \"docs\"", + "towncrier; extra == \"docs\"", "zope.interface; extra == \"docs\"", "zope.interface; extra == \"tests\"" ], - "requires_python": ">=3.5", - "version": "22.1" + "requires_python": ">=3.6", + "version": "22.2" }, { "artifacts": [ { "algorithm": "sha256", - "hash": "011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3", - "url": "https://files.pythonhosted.org/packages/9b/dd/b3c12c6d707058fa947864b67f0c4e0c39ef8610988d7baea9578f3c48f3/iniconfig-1.1.1-py2.py3-none-any.whl" + "hash": "b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374", + "url": "https://files.pythonhosted.org/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl" }, { "algorithm": "sha256", - "hash": "bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32", - "url": "https://files.pythonhosted.org/packages/23/a2/97899f6bd0e873fed3a7e67ae8d3a08b21799430fb4da15cfedf10d6e2c2/iniconfig-1.1.1.tar.gz" + "hash": "2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3", + "url": "https://files.pythonhosted.org/packages/d7/4b/cbd8e699e64a6f16ca3a8220661b5f83792b3017d0f79807cb8708d33913/iniconfig-2.0.0.tar.gz" } ], "project_name": "iniconfig", "requires_dists": [], - "requires_python": null, - "version": "1.1.1" + "requires_python": ">=3.7", + "version": "2" }, { "artifacts": [ { "algorithm": "sha256", - "hash": "ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522", - "url": "https://files.pythonhosted.org/packages/05/8e/8de486cbd03baba4deef4142bd643a3e7bbe954a784dc1bb17142572d127/packaging-21.3-py3-none-any.whl" + "hash": "714ac14496c3e68c99c29b00845f7a2b85f3bb6f1078fd9f72fd20f0570002b2", + "url": "https://files.pythonhosted.org/packages/ed/35/a31aed2993e398f6b09a790a181a7927eb14610ee8bbf02dc14d31677f1c/packaging-23.0-py3-none-any.whl" }, { "algorithm": "sha256", - "hash": "dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb", - "url": "https://files.pythonhosted.org/packages/df/9e/d1a7217f69310c1db8fdf8ab396229f55a699ce34a203691794c5d1cad0c/packaging-21.3.tar.gz" + "hash": "b6ad297f8907de0fa2fe1ccbd26fdaf387f5f47c7275fedf8cce89f99446cf97", + "url": "https://files.pythonhosted.org/packages/47/d5/aca8ff6f49aa5565df1c826e7bf5e85a6df852ee063600c1efa5b932968c/packaging-23.0.tar.gz" } ], "project_name": "packaging", - "requires_dists": [ - "pyparsing!=3.0.5,>=2.0.2" - ], - "requires_python": ">=3.6", - "version": "21.3" + "requires_dists": [], + "requires_python": ">=3.7", + "version": "23" }, { "artifacts": [ @@ -182,40 +176,18 @@ "artifacts": [ { "algorithm": "sha256", - "hash": "5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc", - "url": "https://files.pythonhosted.org/packages/6c/10/a7d0fa5baea8fe7b50f448ab742f26f52b80bfca85ac2be9d35cdd9a3246/pyparsing-3.0.9-py3-none-any.whl" + "hash": "1377bda3466d70b55e3f5cecfa55bb7cfcf219c7964629b967c37cf0bda818b7", + "url": "https://files.pythonhosted.org/packages/e3/b9/3541bbcb412a9fd56593005ff32183825634ef795a1c01ceb6dee86e7259/pytest-7.1.3-py3-none-any.whl" }, { "algorithm": "sha256", - "hash": "2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb", - "url": "https://files.pythonhosted.org/packages/71/22/207523d16464c40a0310d2d4d8926daffa00ac1f5b1576170a32db749636/pyparsing-3.0.9.tar.gz" - } - ], - "project_name": "pyparsing", - "requires_dists": [ - "jinja2; extra == \"diagrams\"", - "railroad-diagrams; extra == \"diagrams\"" - ], - "requires_python": ">=3.6.8", - "version": "3.0.9" - }, - { - "artifacts": [ - { - "algorithm": "sha256", - "hash": "9ce3ff477af913ecf6321fe337b93a2c0dcf2a0a1439c43f5452112c1e4280db", - "url": "https://files.pythonhosted.org/packages/38/93/c7c0bd1e932b287fb948eb9ce5a3d6307c9fc619db1e199f8c8bc5dad95f/pytest-7.0.1-py3-none-any.whl" - }, - { - "algorithm": "sha256", - "hash": "e30905a0c131d3d94b89624a1cc5afec3e0ba2fbdb151867d8e0ebd49850f171", - "url": "https://files.pythonhosted.org/packages/3e/2c/a67ad48759051c7abf82ce182a4e6d766de371b183182d2dde03089e8dfb/pytest-7.0.1.tar.gz" + "hash": "4f365fec2dff9c1162f834d9f18af1ba13062db0c708bf7b946f8a5c76180c39", + "url": "https://files.pythonhosted.org/packages/a4/a7/8c63a4966935b0d0b039fd67ebf2e1ae00f1af02ceb912d838814d772a9a/pytest-7.1.3.tar.gz" } ], "project_name": "pytest", "requires_dists": [ "argcomplete; extra == \"testing\"", - "atomicwrites>=1.0; sys_platform == \"win32\"", "attrs>=19.2.0", "colorama; sys_platform == \"win32\"", "hypothesis>=3.56; extra == \"testing\"", @@ -231,8 +203,8 @@ "tomli>=1.0.0", "xmlschema; extra == \"testing\"" ], - "requires_python": ">=3.6", - "version": "7.0.1" + "requires_python": ">=3.7", + "version": "7.1.3" }, { "artifacts": [ @@ -324,7 +296,7 @@ "prefer_older_binary": false, "requirements": [ "ansicolors==1.1.8", - "pytest==7.0.1", + "pytest==7.1.3", "setuptools<57,>=56.2.0", "types-setuptools<58,>=56.2.0" ], diff --git a/requirements.txt b/requirements.txt index 73985bc..979167d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,4 @@ ansicolors==1.1.8 setuptools>=56.2.0,<57 types-setuptools>=56.2.0,<58 -pytest==7.0.1 +pytest==7.1.3 \ No newline at end of file From c5f6f1f18e213504c452f985f645be9aa292d93b Mon Sep 17 00:00:00 2001 From: Asher Foa Date: Fri, 20 Jan 2023 11:33:27 -0500 Subject: [PATCH 03/26] Fmt BUILD files (#118) --- pants.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pants.toml b/pants.toml index 8f72070..fc5bff0 100644 --- a/pants.toml +++ b/pants.toml @@ -4,6 +4,7 @@ [GLOBAL] pants_version = "2.14.0" backend_packages.add = [ + "pants.backend.build_files.fmt.black", "pants.backend.python", "pants.backend.python.lint.docformatter", "pants.backend.python.lint.black", From a792a8b4e137815dc4974010545f1740501802f4 Mon Sep 17 00:00:00 2001 From: Benjy Weinberger Date: Tue, 28 Feb 2023 10:31:47 -0800 Subject: [PATCH 04/26] Upgrade to Pants 2.15.0 and use scie-pants. (#122) --- .github/workflows/pants.yaml | 20 +- README.md | 66 ++--- helloworld/BUILD | 2 +- pants | 481 ----------------------------------- pants.toml | 2 +- pants_from_sources | 23 -- python-default.lock | 2 +- 7 files changed, 48 insertions(+), 548 deletions(-) delete mode 100755 pants delete mode 100755 pants_from_sources diff --git a/.github/workflows/pants.yaml b/.github/workflows/pants.yaml index e3aa38e..b832eef 100644 --- a/.github/workflows/pants.yaml +++ b/.github/workflows/pants.yaml @@ -24,14 +24,16 @@ jobs: python-version: [3.9] steps: - uses: actions/checkout@v3 - - uses: pantsbuild/actions/init-pants@v2 + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - uses: pantsbuild/actions/init-pants@v4-scie-pants # This action bootstraps pants and manages 2-3 GHA caches. # See: github.com/pantsbuild/actions/tree/main/init-pants/ with: - pants-python-version: ${{ matrix.python-version }} - # cache0 makes it easy to bust the cache if needed + # v0 makes it easy to bust the cache if needed # just increase the integer to start with a fresh cache - gha-cache-key: cache0-py${{ matrix.python-version }} + gha-cache-key: v0 # The Python backend uses named_caches for Pip/PEX state, # so it is appropriate to invalidate on lockfile changes. named-caches-hash: ${{ hashFiles('python-default.lock') }} @@ -47,18 +49,18 @@ jobs: # Alternatively you change gha-cache-key to ignore old caches. - name: Check BUILD files run: | - ./pants tailor --check update-build-files --check :: + pants tailor --check update-build-files --check :: - name: Lint and typecheck run: | - ./pants lint check :: + pants lint check :: - name: Test run: | - ./pants test :: + pants test :: - name: Package / Run run: | # We also smoke test that our release process will work by running `package`. - ./pants package :: - ./pants run helloworld/main.py + pants package :: + pants run helloworld/main.py - name: Upload pants log uses: actions/upload-artifact@v3 with: diff --git a/README.md b/README.md index 49f48cc..098239f 100644 --- a/README.md +++ b/README.md @@ -9,14 +9,16 @@ example layouts. # Running Pants -You run Pants goals using the `./pants` wrapper script, which will bootstrap the -configured version of Pants if necessary. +You run Pants goals using the `pants` launcher binary, which will bootstrap the +version of Pants configured for this repo if necessary. -> :question: Running with Apple Silicon and/or MacOS? You will want to make changes to the `search_path` and -`interpreter_constraints` values in `pants.toml` before running `./pants` - there is guidance in `pants.toml` +See [here](https://www.pantsbuild.org/docs/installation) for how to install the `pants` binary. + +> :question: Running with Apple Silicon and/or macOS? You will want to make changes to the `search_path` and +`interpreter_constraints` values in `pants.toml` before running `pants` - there is guidance in `pants.toml` for those settings. -Use `./pants --version` to see the version of Pants configured for the repo (which you can also find +Use `pants --version` to see the version of Pants configured for the repo (which you can also find in `pants.toml`). # Goals @@ -24,7 +26,7 @@ in `pants.toml`). Pants commands are called _goals_. You can get a list of goals with ``` -./pants help goals +pants help goals ``` # Targets @@ -41,37 +43,37 @@ In the latter case, Pants locates target metadata for the source files as needed Invoking goals on files is straightforward, e.g., ``` -./pants test helloworld/greet/greeting_test.py +pants test helloworld/greet/greeting_test.py ``` You can use globs: ``` -./pants lint helloworld/greet/*.py +pants lint helloworld/greet/*.py ``` But note that these will be expanded by your shell, so this is equivalent to having used ``` -./pants lint helloworld/greet/__init__.py helloworld/greet/greeting.py helloworld/greet/greeting_test.py +pants lint helloworld/greet/__init__.py helloworld/greet/greeting.py helloworld/greet/greeting_test.py ``` If you want Pants itself to expand the globs (which is sometimes necessary), you must quote them in the shell: ``` -./pants lint 'helloworld/greet/*.py' +pants lint 'helloworld/greet/*.py' ``` You can run on all changed files: ``` -./pants --changed-since=HEAD lint +pants --changed-since=HEAD lint ``` You can run on all changed files, and any of their "dependees": ``` -./pants --changed-since=HEAD --changed-dependees=transitive test +pants --changed-since=HEAD --changed-dependees=transitive test ``` ## Target specifications @@ -79,14 +81,14 @@ You can run on all changed files, and any of their "dependees": Targets are referenced on the command line using their address, of the form `path/to/dir:name`, e.g., ``` -./pants lint helloworld/greet:lib +pants lint helloworld/greet:lib ``` You can glob over all targets in a directory with a single trailing `:`, or over all targets in a directory and all its subdirectories with a double trailing `::`, e.g., ``` -./pants lint helloworld:: +pants lint helloworld:: ``` ## Globbing semantics @@ -96,7 +98,7 @@ For example, if you run the `test` goal over a set of files that includes non-te those, rather than error. So you can safely do things like ``` -./pants test :: +pants test :: ``` To run all tests. @@ -108,50 +110,50 @@ Try these out in this repo! ## List targets ``` -./pants list :: # All targets. -./pants list 'helloworld/**/*.py' # Just targets containing Python code. +pants list :: # All targets. +pants list 'helloworld/**/*.py' # Just targets containing Python code. ``` ## Run linters and formatters ``` -./pants lint :: -./pants fmt helloworld/greet:: +pants lint :: +pants fmt helloworld/greet:: ``` ## Run MyPy ``` -./pants check :: +pants check :: ``` ## Run tests ``` -./pants test :: # Run all tests in the repo. -./pants test --output=all :: # Run all tests in the repo and view pytest output even for tests that passed (you can set this permanently in pants.toml). -./pants test helloworld/translator:tests # Run all the tests in this target. -./pants test helloworld/translator/translator_test.py # Run just the tests in this file. -./pants test helloworld/translator/translator_test.py -- -k test_unknown_phrase # Run just this one test by passing through pytest args. +pants test :: # Run all tests in the repo. +pants test --output=all :: # Run all tests in the repo and view pytest output even for tests that passed (you can set this permanently in pants.toml). +pants test helloworld/translator:tests # Run all the tests in this target. +pants test helloworld/translator/translator_test.py # Run just the tests in this file. +pants test helloworld/translator/translator_test.py -- -k test_unknown_phrase # Run just this one test by passing through pytest args. ``` ## Create a PEX binary ``` -./pants package helloworld/main.py +pants package helloworld/main.py ``` ## Run a binary directly ``` -./pants run helloworld/main.py +pants run helloworld/main.py ``` ## Open a REPL ``` -./pants repl helloworld/greet:lib # The REPL will have all relevant code and dependencies on its sys.path. -./pants repl --shell=ipython helloworld/greet:lib --no-pantsd # To use IPython, you must disable Pantsd for now. +pants repl helloworld/greet:lib # The REPL will have all relevant code and dependencies on its sys.path. +pants repl --shell=ipython helloworld/greet:lib --no-pantsd # To use IPython, you must disable Pantsd for now. ``` ## Build a wheel / generate `setup.py` @@ -159,16 +161,16 @@ Try these out in this repo! This will build both a `.whl` bdist and a `.tar.gz` sdist. ``` -./pants package helloworld/translator:dist +pants package helloworld/translator:dist ``` ## Count lines of code ``` -./pants count-loc '**/*' +pants count-loc '**/*' ``` ## Create virtualenv for IDE integration ``` -./pants export :: +pants export :: ``` diff --git a/helloworld/BUILD b/helloworld/BUILD index 7a3c568..5e55812 100644 --- a/helloworld/BUILD +++ b/helloworld/BUILD @@ -7,7 +7,7 @@ python_sources( ) # This target allows us to bundle our app into a PEX binary file via -# `./pants package`. We can also run it with `./pants run`. See +# `pants package`. We can also run it with `pants run`. See # https://www.pantsbuild.org/docs/python-package-goal and # https://www.pantsbuild.org/docs/python-run-goal. pex_binary( diff --git a/pants b/pants deleted file mode 100755 index 367830f..0000000 --- a/pants +++ /dev/null @@ -1,481 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -# =============================== NOTE =============================== -# This ./pants bootstrap script comes from the pantsbuild/setup -# project. It is intended to be checked into your code repository so -# that other developers have the same setup. -# -# Learn more here: https://www.pantsbuild.org/docs/installation -# ==================================================================== - -set -eou pipefail - -# an arbitrary number: bump when there's a change that someone might want to query for -# (e.g. checking $(PANTS_BOOTSTRAP_TOOLS=1 ./pants version) >= ...) -SCRIPT_VERSION=1 - -# Source any custom bootstrap settings for Pants from PANTS_BOOTSTRAP if it exists. -: ${PANTS_BOOTSTRAP:=".pants.bootstrap"} -if [[ -f "${PANTS_BOOTSTRAP}" ]]; then - source "${PANTS_BOOTSTRAP}" -fi - -# NOTE: To use an unreleased version of Pants from the pantsbuild/pants main branch, -# locate the main branch SHA, set PANTS_SHA= in the environment, and run this script as usual. -# -# E.g., PANTS_SHA=725fdaf504237190f6787dda3d72c39010a4c574 ./pants --version - -PYTHON_BIN_NAME="${PYTHON:-unspecified}" - -# Set this to specify a non-standard location for this script to read the Pants version from. -# NB: This will *not* cause Pants itself to use this location as a config file. -# You can use PANTS_CONFIG_FILES or --pants-config-files to do so. -PANTS_TOML=${PANTS_TOML:-pants.toml} - -PANTS_BIN_NAME="${PANTS_BIN_NAME:-$0}" - -PANTS_SETUP_CACHE="${PANTS_SETUP_CACHE:-${XDG_CACHE_HOME:-$HOME/.cache}/pants/setup}" -# If given a relative path, we fix it to be absolute. -if [[ "$PANTS_SETUP_CACHE" != /* ]]; then - PANTS_SETUP_CACHE="${PWD}/${PANTS_SETUP_CACHE}" -fi - -PANTS_BOOTSTRAP="${PANTS_SETUP_CACHE}/bootstrap-$(uname -s)-$(uname -m)" - -_PEX_VERSION=2.1.103 -_PEX_URL="https://github.com/pantsbuild/pex/releases/download/v${_PEX_VERSION}/pex" -_PEX_EXPECTED_SHA256="4d45336511484100ae4e2bab24542a8b86b12c8cb89230463593c60d08c4b8d3" - -VIRTUALENV_VERSION=20.4.7 -VIRTUALENV_REQUIREMENTS=$( -cat << EOF -virtualenv==${VIRTUALENV_VERSION} --hash sha256:2b0126166ea7c9c3661f5b8e06773d28f83322de7a3ff7d06f0aed18c9de6a76 -filelock==3.0.12 --hash sha256:929b7d63ec5b7d6b71b0fa5ac14e030b3f70b75747cef1b10da9b879fef15836 -six==1.16.0 --hash sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254 -distlib==0.3.2 --hash sha256:23e223426b28491b1ced97dc3bbe183027419dfc7982b4fa2f05d5f3ff10711c -appdirs==1.4.4 --hash sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128 -importlib-resources==5.1.4; python_version < "3.7" --hash sha256:e962bff7440364183203d179d7ae9ad90cb1f2b74dcb84300e88ecc42dca3351 -importlib-metadata==4.5.0; python_version < "3.8" --hash sha256:833b26fb89d5de469b24a390e9df088d4e52e4ba33b01dc5e0e4f41b81a16c00 -zipp==3.4.1; python_version < "3.10" --hash sha256:51cb66cc54621609dd593d1787f286ee42a5c0adbb4b29abea5a63edc3e03098 -typing-extensions==3.10.0.0; python_version < "3.8" --hash sha256:779383f6086d90c99ae41cf0ff39aac8a7937a9283ce0a414e5dd782f4c94a84 -EOF -) - -COLOR_RED="\x1b[31m" -COLOR_GREEN="\x1b[32m" -COLOR_YELLOW="\x1b[33m" -COLOR_RESET="\x1b[0m" - -INSTALL_URL="https://www.pantsbuild.org/docs/installation" - -function log() { - echo -e "$@" 1>&2 -} - -function die() { - (($# > 0)) && log "${COLOR_RED}$*${COLOR_RESET}" - exit 1 -} - -function green() { - (($# > 0)) && log "${COLOR_GREEN}$*${COLOR_RESET}" -} - -function warn() { - (($# > 0)) && log "${COLOR_YELLOW}$*${COLOR_RESET}" -} - -function tempdir { - mkdir -p "$1" - mktemp -d "$1"/pants.XXXXXX -} - -function get_exe_path_or_die { - local exe="$1" - if ! command -v "${exe}"; then - die "Could not find ${exe}. Please ensure ${exe} is on your PATH." - fi -} - -function get_pants_config_string_value { - local config_key="$1" - local optional_space="[[:space:]]*" - local prefix="^${config_key}${optional_space}=${optional_space}" - local raw_value - raw_value="$(sed -ne "/${prefix}/ s|${prefix}||p" "${PANTS_TOML}")" - local optional_suffix="${optional_space}(#.*)?$" - echo "${raw_value}" \ - | sed -E \ - -e "s|^'([^']*)'${optional_suffix}|\1|" \ - -e 's|^"([^"]*)"'"${optional_suffix}"'$|\1|' \ - && return 0 - return 0 -} - -function get_python_major_minor_version { - local python_exe="$1" - "$python_exe" </dev/null 2>&1; then - continue - fi - if [[ -n "$(check_python_exe_compatible_version "${interpreter_path}")" ]]; then - echo "${interpreter_path}" && return 0 - fi - done -} - -function determine_python_exe { - local pants_version="$1" - set_supported_python_versions "${pants_version}" - local requirement_str="For \`pants_version = \"${pants_version}\"\`, Pants requires Python ${supported_message} to run." - - local python_exe - if [[ "${PYTHON_BIN_NAME}" != 'unspecified' ]]; then - python_exe="$(get_exe_path_or_die "${PYTHON_BIN_NAME}")" || exit 1 - if [[ -z "$(check_python_exe_compatible_version "${python_exe}")" ]]; then - die "Invalid Python interpreter version for ${python_exe}. ${requirement_str}" - fi - else - python_exe="$(determine_default_python_exe)" - if [[ -z "${python_exe}" ]]; then - die "No valid Python interpreter found. ${requirement_str} Please check that a valid interpreter is installed and on your \$PATH." - fi - fi - echo "${python_exe}" -} - -function compute_sha256 { - local python="$1" - local path="$2" - - "$python" <&2 || exit 1 - fi - echo "${bootstrapped}" -} - -function scrub_env_vars { - # Ensure the virtualenv PEX runs as shrink-wrapped. - # See: https://github.com/pantsbuild/setup/issues/105 - local -r pex_env_vars=(${!PEX_@}) - if [[ ! ${#pex_env_vars[@]} -eq 0 ]]; then - local -r pex_env_vars_to_scrub="${pex_env_vars[@]/PEX_ROOT}" - if [[ -n "${pex_env_vars_to_scrub[@]}" ]]; then - warn "Scrubbing ${pex_env_vars_to_scrub[@]}" - unset ${pex_env_vars_to_scrub[@]} - fi - fi - # Also ensure pip doesn't think packages on PYTHONPATH - # are already installed. - if [ -n "${PYTHONPATH:-}" ]; then - warn "Scrubbing PYTHONPATH" - unset PYTHONPATH - fi -} - -function bootstrap_virtualenv { - local python="$1" - local bootstrapped="${PANTS_BOOTSTRAP}/virtualenv-${VIRTUALENV_VERSION}/virtualenv.pex" - if [[ ! -f "${bootstrapped}" ]]; then - ( - green "Creating the virtualenv PEX." - pex_path="$(bootstrap_pex "${python}")" || exit 1 - mkdir -p "${PANTS_BOOTSTRAP}" - local staging_dir - staging_dir=$(tempdir "${PANTS_BOOTSTRAP}") - cd "${staging_dir}" - echo "${VIRTUALENV_REQUIREMENTS}" > requirements.txt - ( - scrub_env_vars - "${python}" "${pex_path}" -r requirements.txt -c virtualenv -o virtualenv.pex - ) - mkdir -p "$(dirname "${bootstrapped}")" - mv -f "${staging_dir}/virtualenv.pex" "${bootstrapped}" - rm -rf "${staging_dir}" - ) 1>&2 || exit 1 - fi - echo "${bootstrapped}" -} - -function find_links_url { - local pants_version="$1" - local pants_sha="$2" - echo -n "https://binaries.pantsbuild.org/wheels/pantsbuild.pants/${pants_sha}/${pants_version/+/%2B}/index.html" -} - -function get_version_for_sha { - local sha="$1" - - # Retrieve the Pants version associated with this commit. - local pants_version - pants_version="$(curl --proto "=https" \ - --tlsv1.2 \ - --fail \ - --silent \ - --location \ - "https://raw.githubusercontent.com/pantsbuild/pants/${sha}/src/python/pants/VERSION")" - - # Construct the version as the release version from src/python/pants/VERSION, plus the string `+gitXXXXXXXX`, - # where the XXXXXXXX is the first 8 characters of the SHA. - echo "${pants_version}+git${sha:0:8}" -} - -function bootstrap_pants { - local pants_version="$1" - local python="$2" - local pants_sha="${3:-}" - - local pants_requirement="pantsbuild.pants==${pants_version}" - local maybe_find_links - if [[ -z "${pants_sha}" ]]; then - maybe_find_links="" - else - maybe_find_links="--find-links=$(find_links_url "${pants_version}" "${pants_sha}")" - fi - local python_major_minor_version - python_major_minor_version="$(get_python_major_minor_version "${python}")" - local target_folder_name="${pants_version}_py${python_major_minor_version}" - local bootstrapped="${PANTS_BOOTSTRAP}/${target_folder_name}" - - if [[ ! -d "${bootstrapped}" ]]; then - ( - green "Bootstrapping Pants using ${python}" - local staging_dir - staging_dir=$(tempdir "${PANTS_BOOTSTRAP}") - local virtualenv_path - virtualenv_path="$(bootstrap_virtualenv "${python}")" || exit 1 - green "Installing ${pants_requirement} into a virtual environment at ${bootstrapped}" - ( - scrub_env_vars - # shellcheck disable=SC2086 - "${python}" "${virtualenv_path}" --quiet --no-download "${staging_dir}/install" && \ - # Grab the latest pip, but don't advance setuptools past 58 which drops support for the - # `setup` kwarg `use_2to3` which Pants 1.x sdist dependencies (pystache) use. - "${staging_dir}/install/bin/pip" install --quiet -U pip "setuptools<58" && \ - "${staging_dir}/install/bin/pip" install ${maybe_find_links} --quiet --progress-bar off "${pants_requirement}" - ) && \ - ln -s "${staging_dir}/install" "${staging_dir}/${target_folder_name}" && \ - mv "${staging_dir}/${target_folder_name}" "${bootstrapped}" && \ - green "New virtual environment successfully created at ${bootstrapped}." - ) 1>&2 || exit 1 - fi - echo "${bootstrapped}" -} - -function run_bootstrap_tools { - # functionality for introspecting the bootstrapping process, without actually doing it - if [[ "${PANTS_BOOTSTRAP_TOOLS}" -gt "${SCRIPT_VERSION}" ]]; then - die "$0 script (bootstrap version ${SCRIPT_VERSION}) is too old for this invocation (with PANTS_BOOTSTRAP_TOOLS=${PANTS_BOOTSTRAP_TOOLS}). -Please update it by following ${INSTALL_URL}" - fi - - case "${1:-}" in - bootstrap-cache-key) - local pants_version=$(determine_pants_version) - local python="$(determine_python_exe "${pants_version}")" - # the python above may be a shim (e.g. pyenv or homebrew), so let's get an estimate of the - # actual path, as will be symlinked in the virtualenv. (NB. virtualenv does more complicated - # things, but we at least emulate the symlink-resolution that it does.) - local python_executable_path="$("${python}" -c 'import os, sys; print(os.path.realpath(sys.executable))')" - - local requirements_file="$(mktemp)" - echo "${VIRTUALENV_REQUIREMENTS}" > "${requirements_file}" - local virtualenv_requirements_sha256="$(compute_sha256 "${python}" "${requirements_file}")" - rm "${requirements_file}" - - local parts=( - "os_name=$(uname -s)" - "arch=$(uname -m)" - "python_path=${python}" - "python_executable_path=${python_executable_path}" - # the full interpreter information, for maximum compatibility - "python_version=$("$python" --version)" - "pex_version=${_PEX_VERSION}" - "virtualenv_requirements_sha256=${virtualenv_requirements_sha256}" - "pants_version=${pants_version}" - ) - echo "${parts[*]}" - ;; - bootstrap-version) - echo "${SCRIPT_VERSION}" - ;; - help|"") - cat < Date: Fri, 19 May 2023 09:06:45 -0500 Subject: [PATCH 05/26] Remove Toolchain config. (#124) --- pants.ci.toml | 5 ----- pants.toml | 18 ------------------ 2 files changed, 23 deletions(-) diff --git a/pants.ci.toml b/pants.ci.toml index 446bd0d..bcf7a2e 100644 --- a/pants.ci.toml +++ b/pants.ci.toml @@ -13,8 +13,3 @@ remote_cache_write = false [pytest] args = ["-vv", "--no-header"] - -# Toolchain plugin auth configuration -[auth] -from_env_var = "TOOLCHAIN_AUTH_TOKEN" -org = "pantsbuild" diff --git a/pants.toml b/pants.toml index dad9531..4ca8783 100644 --- a/pants.toml +++ b/pants.toml @@ -13,24 +13,6 @@ backend_packages.add = [ "pants.backend.python.typecheck.mypy", ] -# Pants' sponsor, Toolchain, offers remote caching, which can improve your CI performance with minimal configuration. -# Visit https://toolchain.com to enable and try it on your repository -# docs: https://docs.toolchain.com/docs - -plugins.add = [ - "toolchain.pants.plugin==0.25.0", -] -remote_cache_read = false -remote_cache_write = false - -[toolchain-setup] -repo = "example-python" -org = "pantsbuild" - -[buildsense] -enable = false -# End Toolchain-specific configuration - [anonymous-telemetry] enabled = true repo_id = "3B1D361B-E9F1-49A8-B761-03DCC41FD58E" From 27fc9ee7761e61f3c5c9b502d612df5f1f13e29b Mon Sep 17 00:00:00 2001 From: Alexey Tereshenkov <50622389+AlexTereshenkov@users.noreply.github.com> Date: Thu, 15 Jun 2023 15:31:59 +0100 Subject: [PATCH 06/26] Upgrade to pants 2.16.0 (#125) --- pants.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pants.toml b/pants.toml index 4ca8783..d0981a6 100644 --- a/pants.toml +++ b/pants.toml @@ -2,7 +2,7 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). [GLOBAL] -pants_version = "2.15.0" +pants_version = "2.16.0" backend_packages.add = [ "pants.backend.build_files.fmt.black", "pants.backend.python", From 751db8be2ed502dba733d8bc1c340064bb9d1995 Mon Sep 17 00:00:00 2001 From: Rhuan Barreto Date: Thu, 20 Jul 2023 17:53:22 +0200 Subject: [PATCH 07/26] ci: upgrade action version (#126) --- .github/workflows/pants.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pants.yaml b/.github/workflows/pants.yaml index b832eef..acea3a2 100644 --- a/.github/workflows/pants.yaml +++ b/.github/workflows/pants.yaml @@ -27,7 +27,7 @@ jobs: - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - - uses: pantsbuild/actions/init-pants@v4-scie-pants + - uses: pantsbuild/actions/init-pants@v5-scie-pants # This action bootstraps pants and manages 2-3 GHA caches. # See: github.com/pantsbuild/actions/tree/main/init-pants/ with: @@ -48,10 +48,10 @@ jobs: # See https://pants.readme.io/docs/using-pants-in-ci for tips on how to periodically clean it up. # Alternatively you change gha-cache-key to ignore old caches. - name: Check BUILD files - run: | + run: | pants tailor --check update-build-files --check :: - name: Lint and typecheck - run: | + run: | pants lint check :: - name: Test run: | From a930f25c26774316311b6f062eb598b7dd4fa6b8 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Fri, 1 Sep 2023 02:03:23 +1000 Subject: [PATCH 08/26] Upgrade to Pants 2.17.0 (#127) --- pants.toml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pants.toml b/pants.toml index d0981a6..59bdbc4 100644 --- a/pants.toml +++ b/pants.toml @@ -2,7 +2,7 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). [GLOBAL] -pants_version = "2.16.0" +pants_version = "2.17.0" backend_packages.add = [ "pants.backend.build_files.fmt.black", "pants.backend.python", @@ -44,3 +44,7 @@ resolves = { python-default = "python-default.lock"} # problematic system Pythons. See # https://www.pantsbuild.org/docs/python-interpreter-compatibility#changing-the-interpreter-search-path. search_path = ["", ""] + +[python-infer] +# 2.17 is transitioning to a new, faster parser for dependency inference: +use_rust_parser = true From 98ffe0cd62e975ff6122106174652db2a2fb74a5 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Fri, 1 Sep 2023 07:50:05 +1000 Subject: [PATCH 09/26] Check in get-pants.sh script, following doc recommendation (#128) * Check in get-pants.sh script, following doc recommendation * Resolve duplicate owner warning --- .github/workflows/pants.yaml | 2 +- get-pants.sh | 221 +++++++++++++++++++++++++++++++++++ 2 files changed, 222 insertions(+), 1 deletion(-) create mode 100755 get-pants.sh diff --git a/.github/workflows/pants.yaml b/.github/workflows/pants.yaml index acea3a2..77515a4 100644 --- a/.github/workflows/pants.yaml +++ b/.github/workflows/pants.yaml @@ -60,7 +60,7 @@ jobs: run: | # We also smoke test that our release process will work by running `package`. pants package :: - pants run helloworld/main.py + pants run helloworld/:pex_binary - name: Upload pants log uses: actions/upload-artifact@v3 with: diff --git a/get-pants.sh b/get-pants.sh new file mode 100755 index 0000000..56ee4f2 --- /dev/null +++ b/get-pants.sh @@ -0,0 +1,221 @@ +#!/usr/bin/env bash +# Copyright 2023 Pants project contributors (see CONTRIBUTORS.md). +# Licensed under the Apache License, Version 2.0 (see LICENSE). + +set -euo pipefail + +COLOR_RED="\x1b[31m" +COLOR_GREEN="\x1b[32m" +COLOR_YELLOW="\x1b[33m" +COLOR_RESET="\x1b[0m" + +function log() { + echo -e "$@" 1>&2 +} + +function die() { + (($# > 0)) && log "${COLOR_RED}$*${COLOR_RESET}" + exit 1 +} + +function green() { + (($# > 0)) && log "${COLOR_GREEN}$*${COLOR_RESET}" +} + +function warn() { + (($# > 0)) && log "${COLOR_YELLOW}$*${COLOR_RESET}" +} + +function check_cmd() { + local cmd="$1" + command -v "$cmd" > /dev/null || die "This script requires the ${cmd} binary to be on the PATH." +} + +help_url="https://www.pantsbuild.org/docs/getting-help" + +_GC=() + +function gc() { + if (($# > 0)); then + check_cmd rm + _GC+=("$@") + else + rm -rf "${_GC[@]}" + fi +} + +trap gc EXIT + +check_cmd uname + +function calculate_os() { + local os + + os="$(uname -s)" + if [[ "${os}" =~ [Ll]inux ]]; then + echo linux + elif [[ "${os}" =~ [Dd]arwin ]]; then + echo macos + elif [[ "${os}" =~ [Ww]in|[Mm][Ii][Nn][Gg] ]]; then + # Powershell reports something like: Windows_NT + # Git bash reports something like: MINGW64_NT-10.0-22621 + echo windows + else + die "Pants is not supported on this operating system (${os}). Please reach out to us at ${help_url} for help." + fi +} + +OS="$(calculate_os)" + +check_cmd basename +if [[ "${OS}" == "windows" ]]; then + check_cmd pwsh +else + check_cmd curl +fi + +function fetch() { + local url="$1" + local dest_dir="$2" + + local dest + dest="${dest_dir}/$(basename "${url}")" + + if [[ "${OS}" == "windows" ]]; then + pwsh -c "Invoke-WebRequest -OutFile $dest -Uri $url" + else + curl --proto '=https' --tlsv1.2 -sSfL -o "${dest}" "${url}" + fi +} + +if [[ "${OS}" == "macos" ]]; then + check_cmd shasum +else + check_cmd sha256sum +fi + +function sha256() { + if [[ "${OS}" == "macos" ]]; then + shasum --algorithm 256 "$@" + else + sha256sum "$@" + fi +} + +check_cmd mktemp + +function install_from_url() { + local url="$1" + local dest="$2" + + local workdir + workdir="$(mktemp -d)" + gc "${workdir}" + + fetch "${url}.sha256" "${workdir}" + fetch "${url}" "${workdir}" + ( + cd "${workdir}" + sha256 -c --status ./*.sha256 || + die "Download from ${url} did not match the fingerprint at ${url}.sha256" + ) + rm "${workdir}/"*.sha256 + if [[ "${OS}" == "macos" ]]; then + mkdir -p "$(dirname "${dest}")" + install -m 755 "${workdir}/"* "${dest}" + else + install -D -m 755 "${workdir}/"* "${dest}" + fi +} + +function calculate_arch() { + local arch + + arch="$(uname -m)" + if [[ "${arch}" =~ x86[_-]64 ]]; then + echo x86_64 + elif [[ "${arch}" =~ arm64|aarch64 ]]; then + echo aarch64 + else + die "Pants is not supported for this chip architecture (${arch}). Please reach out to us at ${help_url} for help." + fi +} + +check_cmd cat + +function usage() { + cat << EOF +Usage: $0 + +Installs the pants launcher binary. + +You only need to run this once on a machine when you do not have "pants" +available to run yet. + +The pants binary takes care of managing and running the underlying +Pants version configured in "pants.toml" in the surrounding Pants-using +project. + +Once installed, if you want to update your "pants" launcher binary, use +"SCIE_BOOT=update pants" to get the latest release or +"SCIE_BOOT=update pants --help" to learn more options. + +-h | --help: Print this help message. + +-d | --bin-dir: + The directory to install the scie-pants binary in, "~/bin" by default. + +-b | --base-name: + The name to use for the scie-pants binary, "pants" by default. + +-V | --version: + The version of the scie-pants binary to install, the latest version by default. + The available versions can be seen at: + https://github.com/pantsbuild/scie-pants/releases + +EOF +} + +bin_dir="${HOME}/bin" +base_name="pants" +version="latest/download" +while (($# > 0)); do + case "$1" in + --help | -h) + usage + exit 0 + ;; + --bin-dir | -d) + bin_dir="$2" + shift + ;; + --base-name | -b) + base_name="$2" + shift + ;; + --version | -V) + version="download/v$2" + shift + ;; + *) + usage + die "Unexpected argument $1\n" + ;; + esac + shift +done + +ARCH="$(calculate_arch)" +URL="https://github.com/pantsbuild/scie-pants/releases/${version}/scie-pants-${OS}-${ARCH}" +dest="${bin_dir}/${base_name}" + +log "Downloading and installing the pants launcher ..." +install_from_url "${URL}" "${dest}" +green "Installed the pants launcher from ${URL} to ${dest}" +if ! command -v "${base_name}" > /dev/null; then + warn "${dest} is not on the PATH." + log "You'll either need to invoke ${dest} explicitly or else add ${bin_dir} to your shell's PATH." +fi + +green "\nRunning \`pants\` in a Pants-enabled repo will use the version of Pants configured for that repo." +green "In a repo not yet Pants-enabled, it will prompt you to set up Pants for that repo." From 26d55f2772b72944d7f092019e263f5a5d8984d2 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Mon, 13 Nov 2023 13:44:06 +1100 Subject: [PATCH 10/26] Upgrade to Pants 2.18.0 (#130) --- pants.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pants.toml b/pants.toml index 59bdbc4..dfb564f 100644 --- a/pants.toml +++ b/pants.toml @@ -2,7 +2,7 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). [GLOBAL] -pants_version = "2.17.0" +pants_version = "2.18.0" backend_packages.add = [ "pants.backend.build_files.fmt.black", "pants.backend.python", From a8d4bf9859f69fade4c5b43e5a5adbdd9c8b5750 Mon Sep 17 00:00:00 2001 From: Krishnan Chandra <1229365+krishnan-chandra@users.noreply.github.com> Date: Mon, 26 Feb 2024 17:48:50 -0500 Subject: [PATCH 11/26] Upgrade to Pants 2.19.0 (#133) Closes #131 and #132. Upgrade Pants to 2.19, but also fix the export command as specified in #132 and add documentation for lockfile generation as specified in #131. --- README.md | 16 ++++++++--- pants.toml | 2 +- python-default.lock | 66 +++++++++++++++++++++------------------------ 3 files changed, 43 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 098239f..65507d7 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ An example repository to demonstrate Python support in Pants. See [pantsbuild.org](https://www.pantsbuild.org/docs) for much more detailed documentation. -This is only one possible way of laying out your project with Pants. See +This is only one possible way of laying out your project with Pants. See [pantsbuild.org/docs/source-roots#examples](https://www.pantsbuild.org/docs/source-roots#examples) for some other example layouts. @@ -31,8 +31,8 @@ pants help goals # Targets -Targets are a way of setting metadata for some part of your code, such as timeouts for tests and -entry points for binaries. Targets have types like `python_source`, `resources`, and +Targets are a way of setting metadata for some part of your code, such as timeouts for tests and +entry points for binaries. Targets have types like `python_source`, `resources`, and `pex_binary`. They are defined in `BUILD` files. Pants goals can be invoked on targets or directly on source files (which is often more intuitive and convenient). @@ -169,8 +169,16 @@ pants package helloworld/translator:dist ``` pants count-loc '**/*' ``` + +## Generate or update a lockfile containing the dependencies + +``` +pants generate-lockfiles --resolve=python-default +``` + + ## Create virtualenv for IDE integration ``` -pants export :: +pants export --resolve=python-default ``` diff --git a/pants.toml b/pants.toml index dfb564f..0e74a29 100644 --- a/pants.toml +++ b/pants.toml @@ -2,7 +2,7 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). [GLOBAL] -pants_version = "2.18.0" +pants_version = "2.19.0" backend_packages.add = [ "pants.backend.build_files.fmt.black", "pants.backend.python", diff --git a/python-default.lock b/python-default.lock index 10982be..41b799a 100644 --- a/python-default.lock +++ b/python-default.lock @@ -52,47 +52,42 @@ "artifacts": [ { "algorithm": "sha256", - "hash": "29e95c7f6778868dbd49170f98f8818f78f3dc5e0e37c0b1f474e3561b240836", - "url": "https://files.pythonhosted.org/packages/fb/6e/6f83bf616d2becdf333a1640f1d463fef3150e2e926b7010cb0f81c95e88/attrs-22.2.0-py3-none-any.whl" + "hash": "99b87a485a5820b23b879f04c2305b44b951b502fd64be915879d77a7e8fc6f1", + "url": "https://files.pythonhosted.org/packages/e0/44/827b2a91a5816512fcaf3cc4ebc465ccd5d598c45cefa6703fcf4a79018f/attrs-23.2.0-py3-none-any.whl" }, { "algorithm": "sha256", - "hash": "c9227bfc2f01993c03f68db37d1d15c9690188323c067c641f1a35ca58185f99", - "url": "https://files.pythonhosted.org/packages/21/31/3f468da74c7de4fcf9b25591e682856389b3400b4b62f201e65f15ea3e07/attrs-22.2.0.tar.gz" + "hash": "935dc3b529c262f6cf76e50877d35a4bd3c1de194fd41f47a2b7ae8f19971f30", + "url": "https://files.pythonhosted.org/packages/e3/fc/f800d51204003fa8ae392c4e8278f256206e7a919b708eef054f5f4b650d/attrs-23.2.0.tar.gz" } ], "project_name": "attrs", "requires_dists": [ - "attrs[docs,tests]; extra == \"dev\"", + "attrs[tests-mypy]; extra == \"tests-no-zope\"", "attrs[tests-no-zope]; extra == \"tests\"", "attrs[tests]; extra == \"cov\"", + "attrs[tests]; extra == \"dev\"", "cloudpickle; platform_python_implementation == \"CPython\" and extra == \"tests-no-zope\"", - "cloudpickle; platform_python_implementation == \"CPython\" and extra == \"tests_no_zope\"", - "coverage-enable-subprocess; extra == \"cov\"", "coverage[toml]>=5.3; extra == \"cov\"", "furo; extra == \"docs\"", "hypothesis; extra == \"tests-no-zope\"", - "hypothesis; extra == \"tests_no_zope\"", - "mypy<0.990,>=0.971; platform_python_implementation == \"CPython\" and extra == \"tests-no-zope\"", - "mypy<0.990,>=0.971; platform_python_implementation == \"CPython\" and extra == \"tests_no_zope\"", + "importlib-metadata; python_version < \"3.8\"", + "mypy>=1.6; (platform_python_implementation == \"CPython\" and python_version >= \"3.8\") and extra == \"tests-mypy\"", "myst-parser; extra == \"docs\"", + "pre-commit; extra == \"dev\"", "pympler; extra == \"tests-no-zope\"", - "pympler; extra == \"tests_no_zope\"", - "pytest-mypy-plugins; (platform_python_implementation == \"CPython\" and python_version < \"3.11\") and extra == \"tests-no-zope\"", - "pytest-mypy-plugins; (platform_python_implementation == \"CPython\" and python_version < \"3.11\") and extra == \"tests_no_zope\"", + "pytest-mypy-plugins; (platform_python_implementation == \"CPython\" and python_version >= \"3.8\") and extra == \"tests-mypy\"", "pytest-xdist[psutil]; extra == \"tests-no-zope\"", - "pytest-xdist[psutil]; extra == \"tests_no_zope\"", "pytest>=4.3.0; extra == \"tests-no-zope\"", - "pytest>=4.3.0; extra == \"tests_no_zope\"", "sphinx-notfound-page; extra == \"docs\"", "sphinx; extra == \"docs\"", "sphinxcontrib-towncrier; extra == \"docs\"", "towncrier; extra == \"docs\"", - "zope.interface; extra == \"docs\"", - "zope.interface; extra == \"tests\"" + "zope-interface; extra == \"docs\"", + "zope-interface; extra == \"tests\"" ], - "requires_python": ">=3.6", - "version": "22.2" + "requires_python": ">=3.7", + "version": "23.2.0" }, { "artifacts": [ @@ -110,49 +105,48 @@ "project_name": "iniconfig", "requires_dists": [], "requires_python": ">=3.7", - "version": "2" + "version": "2.0.0" }, { "artifacts": [ { "algorithm": "sha256", - "hash": "714ac14496c3e68c99c29b00845f7a2b85f3bb6f1078fd9f72fd20f0570002b2", - "url": "https://files.pythonhosted.org/packages/ed/35/a31aed2993e398f6b09a790a181a7927eb14610ee8bbf02dc14d31677f1c/packaging-23.0-py3-none-any.whl" + "hash": "8c491190033a9af7e1d931d0b5dacc2ef47509b34dd0de67ed209b5203fc88c7", + "url": "https://files.pythonhosted.org/packages/ec/1a/610693ac4ee14fcdf2d9bf3c493370e4f2ef7ae2e19217d7a237ff42367d/packaging-23.2-py3-none-any.whl" }, { "algorithm": "sha256", - "hash": "b6ad297f8907de0fa2fe1ccbd26fdaf387f5f47c7275fedf8cce89f99446cf97", - "url": "https://files.pythonhosted.org/packages/47/d5/aca8ff6f49aa5565df1c826e7bf5e85a6df852ee063600c1efa5b932968c/packaging-23.0.tar.gz" + "hash": "048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5", + "url": "https://files.pythonhosted.org/packages/fb/2b/9b9c33ffed44ee921d0967086d653047286054117d584f1b1a7c22ceaf7b/packaging-23.2.tar.gz" } ], "project_name": "packaging", "requires_dists": [], "requires_python": ">=3.7", - "version": "23" + "version": "23.2" }, { "artifacts": [ { "algorithm": "sha256", - "hash": "74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3", - "url": "https://files.pythonhosted.org/packages/9e/01/f38e2ff29715251cf25532b9082a1589ab7e4f571ced434f98d0139336dc/pluggy-1.0.0-py2.py3-none-any.whl" + "hash": "7db9f7b503d67d1c5b95f59773ebb58a8c1c288129a88665838012cfb07b8981", + "url": "https://files.pythonhosted.org/packages/a5/5b/0cc789b59e8cc1bf288b38111d002d8c5917123194d45b29dcdac64723cc/pluggy-1.4.0-py3-none-any.whl" }, { "algorithm": "sha256", - "hash": "4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159", - "url": "https://files.pythonhosted.org/packages/a1/16/db2d7de3474b6e37cbb9c008965ee63835bba517e22cdb8c35b5116b5ce1/pluggy-1.0.0.tar.gz" + "hash": "8c85c2876142a764e5b7548e7d9a0e0ddb46f5185161049a79b7e974454223be", + "url": "https://files.pythonhosted.org/packages/54/c6/43f9d44d92aed815e781ca25ba8c174257e27253a94630d21be8725a2b59/pluggy-1.4.0.tar.gz" } ], "project_name": "pluggy", "requires_dists": [ - "importlib-metadata>=0.12; python_version < \"3.8\"", "pre-commit; extra == \"dev\"", "pytest-benchmark; extra == \"testing\"", "pytest; extra == \"testing\"", "tox; extra == \"dev\"" ], - "requires_python": ">=3.6", - "version": "1" + "requires_python": ">=3.8", + "version": "1.4.0" }, { "artifacts": [ @@ -170,7 +164,7 @@ "project_name": "py", "requires_dists": [], "requires_python": "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7", - "version": "1.11" + "version": "1.11.0" }, { "artifacts": [ @@ -248,7 +242,7 @@ "wincertstore==0.2; sys_platform == \"win32\" and extra == \"ssl\"" ], "requires_python": ">=3.6", - "version": "56.2" + "version": "56.2.0" }, { "artifacts": [ @@ -291,8 +285,8 @@ } ], "path_mappings": {}, - "pex_version": "2.1.108", - "pip_version": "20.3.4-patched", + "pex_version": "2.1.148", + "pip_version": "23.1.2", "prefer_older_binary": false, "requirements": [ "ansicolors==1.1.8", From f37c500e4f4e0c67e29aa9434b1b414f333bdd79 Mon Sep 17 00:00:00 2001 From: APL <17802877+andrelegault@users.noreply.github.com> Date: Fri, 15 Mar 2024 00:02:12 -0400 Subject: [PATCH 12/26] fix path to pants.log (#134) The log file is in workdir, according to https://github.com/pantsbuild/pants/blob/44a06c5825e294757fb1dfe5920ea4b81db56023/src/python/pants/init/logging.py#L232 The path referred to in the docs is preceded by workdir: https://github.com/pantsbuild/pants/blob/44a06c5825e294757fb1dfe5920ea4b81db56023/docs/docs/using-pants/using-pants-in-ci.mdx#L240 --- .github/workflows/pants.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pants.yaml b/.github/workflows/pants.yaml index 77515a4..c167e42 100644 --- a/.github/workflows/pants.yaml +++ b/.github/workflows/pants.yaml @@ -65,5 +65,5 @@ jobs: uses: actions/upload-artifact@v3 with: name: pants-log - path: .pants.d/pants.log + path: .pants.d/workdir/pants.log if: always() # We want the log even on failures. From 55cf90bc4a1e4ccc47749aa39d299b5dace79adc Mon Sep 17 00:00:00 2001 From: Kaushik-Iyer <84177184+Kaushik-Iyer@users.noreply.github.com> Date: Thu, 18 Apr 2024 05:51:55 +0530 Subject: [PATCH 13/26] Upgrade to Pants 2.20.0 (#135) --- pants.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pants.toml b/pants.toml index 0e74a29..f5b38ae 100644 --- a/pants.toml +++ b/pants.toml @@ -2,7 +2,7 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). [GLOBAL] -pants_version = "2.19.0" +pants_version = "2.20.0" backend_packages.add = [ "pants.backend.build_files.fmt.black", "pants.backend.python", From 5081a3a0a945ea479baf6017055a5177d1577d9d Mon Sep 17 00:00:00 2001 From: Michael Seifert Date: Thu, 16 May 2024 00:31:51 +0200 Subject: [PATCH 14/26] Update GitHub actions to most recent versions (#136) --- .github/workflows/pants.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pants.yaml b/.github/workflows/pants.yaml index c167e42..7638798 100644 --- a/.github/workflows/pants.yaml +++ b/.github/workflows/pants.yaml @@ -23,11 +23,11 @@ jobs: matrix: python-version: [3.9] steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - uses: pantsbuild/actions/init-pants@v5-scie-pants + - uses: pantsbuild/actions/init-pants@v8 # This action bootstraps pants and manages 2-3 GHA caches. # See: github.com/pantsbuild/actions/tree/main/init-pants/ with: From ccb79d67ed1371890e1b5cde7fc461a143ec5138 Mon Sep 17 00:00:00 2001 From: SJ Date: Wed, 29 May 2024 09:33:32 -0400 Subject: [PATCH 15/26] Upgrade to Pants 2.21.0 (#137) --- pants.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pants.toml b/pants.toml index f5b38ae..2c95ae7 100644 --- a/pants.toml +++ b/pants.toml @@ -2,7 +2,7 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). [GLOBAL] -pants_version = "2.20.0" +pants_version = "2.21.0" backend_packages.add = [ "pants.backend.build_files.fmt.black", "pants.backend.python", From 7f64e7737f98a53d51daf6a6def2767997b82742 Mon Sep 17 00:00:00 2001 From: SJ Date: Fri, 7 Jun 2024 08:38:05 -0400 Subject: [PATCH 16/26] Fixed broken/outdated docs links (#138) --- .github/workflows/pants.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pants.yaml b/.github/workflows/pants.yaml index 7638798..9a70ddb 100644 --- a/.github/workflows/pants.yaml +++ b/.github/workflows/pants.yaml @@ -1,7 +1,7 @@ # Copyright 2020 Pants project contributors. # Licensed under the Apache License, Version 2.0 (see LICENSE). -# See https://pants.readme.io/docs/using-pants-in-ci for tips on how to set up your CI with Pants. +# See https://www.pantsbuild.org/2.21/docs/using-pants/using-pants-in-ci for tips on how to set up your CI with Pants. name: Pants @@ -45,7 +45,7 @@ jobs: # Note that named_caches and lmdb_store falls back to partial restore keys which # may give a useful partial result that will save time over completely clean state, # but will cause the cache entry to grow without bound over time. - # See https://pants.readme.io/docs/using-pants-in-ci for tips on how to periodically clean it up. + # See https://www.pantsbuild.org/2.21/docs/using-pants/using-pants-in-ci for tips on how to periodically clean it up. # Alternatively you change gha-cache-key to ignore old caches. - name: Check BUILD files run: | From fb191bbf51249c663ab181dedcbe02155cfaa62c Mon Sep 17 00:00:00 2001 From: Tom Dyas Date: Thu, 31 Oct 2024 08:14:48 +0900 Subject: [PATCH 17/26] upgrade to Pants v2.23.0rc1 + other fixes (#139) * upgrade to Pants v2.23.0rc1 * update get-pants.sh binary * update commands in README.md to those that work --- README.md | 6 +++++- get-pants.sh | 4 ++-- pants.toml | 8 ++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 65507d7..d991362 100644 --- a/README.md +++ b/README.md @@ -139,10 +139,14 @@ pants test helloworld/translator/translator_test.py -- -k test_unknown_phrase # ## Create a PEX binary +The `package` goal requires specifying a target which can be packaged. In this case, the there is a `pex_binary` target with the name `pex_binary` in the `helloworld/BUILD` file. + ``` -pants package helloworld/main.py +pants package helloworld:pex_binary ``` +The pex file is output to `dist/helloworld/pex_binary.pex` and can be executed directly. + ## Run a binary directly ``` diff --git a/get-pants.sh b/get-pants.sh index 56ee4f2..cae178e 100755 --- a/get-pants.sh +++ b/get-pants.sh @@ -163,7 +163,7 @@ Once installed, if you want to update your "pants" launcher binary, use -h | --help: Print this help message. -d | --bin-dir: - The directory to install the scie-pants binary in, "~/bin" by default. + The directory to install the scie-pants binary in, "~/.local/bin" by default. -b | --base-name: The name to use for the scie-pants binary, "pants" by default. @@ -176,7 +176,7 @@ Once installed, if you want to update your "pants" launcher binary, use EOF } -bin_dir="${HOME}/bin" +bin_dir="${HOME}/.local/bin" base_name="pants" version="latest/download" while (($# > 0)); do diff --git a/pants.toml b/pants.toml index 2c95ae7..6e821a5 100644 --- a/pants.toml +++ b/pants.toml @@ -2,7 +2,7 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). [GLOBAL] -pants_version = "2.21.0" +pants_version = "2.23.0rc1" backend_packages.add = [ "pants.backend.build_files.fmt.black", "pants.backend.python", @@ -25,7 +25,7 @@ root_patterns = ["/"] # The default interpreter constraints for code in this repo. Individual targets can override # this with the `interpreter_constraints` field. See # https://www.pantsbuild.org/docs/python-interpreter-compatibility. - +# # Modify this if you don't have Python 3.9 on your machine. # This can be a range, such as [">=3.8,<3.11"], but it's usually recommended to restrict # to a single minor version. @@ -44,7 +44,3 @@ resolves = { python-default = "python-default.lock"} # problematic system Pythons. See # https://www.pantsbuild.org/docs/python-interpreter-compatibility#changing-the-interpreter-search-path. search_path = ["", ""] - -[python-infer] -# 2.17 is transitioning to a new, faster parser for dependency inference: -use_rust_parser = true From ec548ae2deef08bd1e0cc1a597cc1b0c7905bc85 Mon Sep 17 00:00:00 2001 From: Benjy Weinberger Date: Tue, 26 Nov 2024 17:56:54 -0800 Subject: [PATCH 18/26] Upgrade Pants to 2.23.0 (#141) --- .github/workflows/pants.yaml | 6 +++--- pants.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pants.yaml b/.github/workflows/pants.yaml index 9a70ddb..1a77656 100644 --- a/.github/workflows/pants.yaml +++ b/.github/workflows/pants.yaml @@ -1,7 +1,7 @@ # Copyright 2020 Pants project contributors. # Licensed under the Apache License, Version 2.0 (see LICENSE). -# See https://www.pantsbuild.org/2.21/docs/using-pants/using-pants-in-ci for tips on how to set up your CI with Pants. +# See https://www.pantsbuild.org/stable/docs/using-pants/using-pants-in-ci for tips on how to set up your CI with Pants. name: Pants @@ -45,7 +45,7 @@ jobs: # Note that named_caches and lmdb_store falls back to partial restore keys which # may give a useful partial result that will save time over completely clean state, # but will cause the cache entry to grow without bound over time. - # See https://www.pantsbuild.org/2.21/docs/using-pants/using-pants-in-ci for tips on how to periodically clean it up. + # See https://www.pantsbuild.org/stable/docs/using-pants/using-pants-in-ci for tips on how to periodically clean it up. # Alternatively you change gha-cache-key to ignore old caches. - name: Check BUILD files run: | @@ -62,7 +62,7 @@ jobs: pants package :: pants run helloworld/:pex_binary - name: Upload pants log - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: pants-log path: .pants.d/workdir/pants.log diff --git a/pants.toml b/pants.toml index 6e821a5..fad9bb4 100644 --- a/pants.toml +++ b/pants.toml @@ -2,7 +2,7 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). [GLOBAL] -pants_version = "2.23.0rc1" +pants_version = "2.23.0" backend_packages.add = [ "pants.backend.build_files.fmt.black", "pants.backend.python", From 29e160e3c52549e2b4dd39db4e48bd254634174e Mon Sep 17 00:00:00 2001 From: Noam Elfanbaum <4347848+noamelf@users.noreply.github.com> Date: Thu, 12 Dec 2024 04:31:47 +0200 Subject: [PATCH 19/26] Update README.md with newer changed-dependents command (#142) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d991362..3cc3c1d 100644 --- a/README.md +++ b/README.md @@ -70,10 +70,10 @@ You can run on all changed files: pants --changed-since=HEAD lint ``` -You can run on all changed files, and any of their "dependees": +You can run on all changed files, and any of their "dependents": ``` -pants --changed-since=HEAD --changed-dependees=transitive test +pants --changed-since=HEAD --changed-dependents=transitive test ``` ## Target specifications From 6a64ed3cba18c171b4f624df4bc29e2f32592b07 Mon Sep 17 00:00:00 2001 From: cburroughs Date: Tue, 4 Feb 2025 10:59:54 -0500 Subject: [PATCH 20/26] Upgrade to Pants 2.24.0 (#143) --- pants.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pants.toml b/pants.toml index fad9bb4..27b816b 100644 --- a/pants.toml +++ b/pants.toml @@ -2,7 +2,7 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). [GLOBAL] -pants_version = "2.23.0" +pants_version = "2.24.0" backend_packages.add = [ "pants.backend.build_files.fmt.black", "pants.backend.python", From 45b3f7b59f58ddc5d02528c8e3e5f5259b755f25 Mon Sep 17 00:00:00 2001 From: Benjy Weinberger Date: Wed, 12 Feb 2025 11:29:52 -0800 Subject: [PATCH 21/26] Upgrade to Ubuntu 24.04 in CI. (#144) --- .github/workflows/pants.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pants.yaml b/.github/workflows/pants.yaml index 1a77656..9b8cab4 100644 --- a/.github/workflows/pants.yaml +++ b/.github/workflows/pants.yaml @@ -11,14 +11,14 @@ jobs: org-check: name: Check GitHub Organization if: ${{ github.repository_owner == 'pantsbuild' }} - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 steps: - name: Noop run: "true" build: name: Perform CI Checks needs: org-check - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 strategy: matrix: python-version: [3.9] From 603f4a4b30c1cf4d349500776e841beae2d588ca Mon Sep 17 00:00:00 2001 From: Tom Dyas Date: Fri, 7 Mar 2025 00:16:00 -0500 Subject: [PATCH 22/26] upgrade Pants to v2.25.0rc0 (#145) Upgrade to v2.25.0rc0. --- pants.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pants.toml b/pants.toml index 27b816b..937067c 100644 --- a/pants.toml +++ b/pants.toml @@ -2,7 +2,7 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). [GLOBAL] -pants_version = "2.24.0" +pants_version = "2.25.0rc0" backend_packages.add = [ "pants.backend.build_files.fmt.black", "pants.backend.python", From 6fd803f4ec49a668264c05ed01a84c3444a71a93 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Tue, 1 Apr 2025 13:43:32 +1100 Subject: [PATCH 23/26] Upgrade to Pants 2.25.0 (#146) --- pants.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pants.toml b/pants.toml index 937067c..44b230f 100644 --- a/pants.toml +++ b/pants.toml @@ -2,7 +2,7 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). [GLOBAL] -pants_version = "2.25.0rc0" +pants_version = "2.25.0" backend_packages.add = [ "pants.backend.build_files.fmt.black", "pants.backend.python", From ee9a500a51022119c49a414227c6bfa114c4c7af Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Mon, 5 May 2025 15:25:32 +1000 Subject: [PATCH 24/26] Upgrade to Pants 2.26.0 (#147) --- pants.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pants.toml b/pants.toml index 44b230f..3edccd3 100644 --- a/pants.toml +++ b/pants.toml @@ -2,7 +2,7 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). [GLOBAL] -pants_version = "2.25.0" +pants_version = "2.26.0" backend_packages.add = [ "pants.backend.build_files.fmt.black", "pants.backend.python", From fcee05543e252062fcb5b97ec627ba8457173641 Mon Sep 17 00:00:00 2001 From: Benjy Weinberger Date: Thu, 2 Oct 2025 10:40:34 -0700 Subject: [PATCH 25/26] Upgrade to Pants 2.28.0 (#149) --- pants.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pants.toml b/pants.toml index 3edccd3..cbe1e2e 100644 --- a/pants.toml +++ b/pants.toml @@ -2,7 +2,7 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). [GLOBAL] -pants_version = "2.26.0" +pants_version = "2.28.0" backend_packages.add = [ "pants.backend.build_files.fmt.black", "pants.backend.python", From bb97aad3d3fb392fda805d32ed7806293da835b8 Mon Sep 17 00:00:00 2001 From: Chris Burroughs Date: Thu, 9 Oct 2025 23:06:40 -0400 Subject: [PATCH 26/26] Upgrade to Pants 2.29.0 (#150) --- .flake8 | 10 +- .github/workflows/pants.yaml | 2 +- helloworld/greet/greeting.py | 5 +- pants.toml | 6 +- python-default.lock | 173 ++++++++++++++++++++++++----------- 5 files changed, 133 insertions(+), 63 deletions(-) diff --git a/.flake8 b/.flake8 index 160c1b8..cf5d05d 100644 --- a/.flake8 +++ b/.flake8 @@ -1,5 +1,9 @@ [flake8] +# E203 -> whitespace before ':' (conflicts with Black) +# E231 -> Bad trailing comma (conflicts with Black) +# E501 -> line too long (conflicts with Black) + extend-ignore: - E203, # whitespace before ':' (conflicts with Black) - E231, # Bad trailing comma (conflicts with Black) - E501, # line too long (conflicts with Black) + E203, + E231, + E501, diff --git a/.github/workflows/pants.yaml b/.github/workflows/pants.yaml index 9b8cab4..ceb31af 100644 --- a/.github/workflows/pants.yaml +++ b/.github/workflows/pants.yaml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-24.04 strategy: matrix: - python-version: [3.9] + python-version: [3.12] steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 diff --git a/helloworld/greet/greeting.py b/helloworld/greet/greeting.py index 6a5eb1a..70c7675 100644 --- a/helloworld/greet/greeting.py +++ b/helloworld/greet/greeting.py @@ -3,11 +3,10 @@ from __future__ import annotations +import importlib.resources import json import random -import pkg_resources - from helloworld.translator.translator import LanguageTranslator @@ -19,7 +18,7 @@ def __init__( translations if translations is not None else json.loads( - pkg_resources.resource_string(__name__, "translations.json") + importlib.resources.read_text(__name__, "translations.json") ) ) self._translator = LanguageTranslator(self._translations) diff --git a/pants.toml b/pants.toml index cbe1e2e..9c62618 100644 --- a/pants.toml +++ b/pants.toml @@ -2,7 +2,7 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). [GLOBAL] -pants_version = "2.28.0" +pants_version = "2.29.0" backend_packages.add = [ "pants.backend.build_files.fmt.black", "pants.backend.python", @@ -26,10 +26,10 @@ root_patterns = ["/"] # this with the `interpreter_constraints` field. See # https://www.pantsbuild.org/docs/python-interpreter-compatibility. # -# Modify this if you don't have Python 3.9 on your machine. +# Modify this if you don't have Python 3.13 on your machine. # This can be a range, such as [">=3.8,<3.11"], but it's usually recommended to restrict # to a single minor version. -interpreter_constraints = ["==3.9.*"] +interpreter_constraints = ["==3.12.*"] # Enable the "resolves" mechanism, which turns on lockfiles for user code. See # https://www.pantsbuild.org/docs/python-third-party-dependencies. This also adds the diff --git a/python-default.lock b/python-default.lock index 41b799a..4f755f2 100644 --- a/python-default.lock +++ b/python-default.lock @@ -4,9 +4,9 @@ // // --- BEGIN PANTS LOCKFILE METADATA: DO NOT EDIT OR REMOVE --- // { -// "version": 3, +// "version": 4, // "valid_for_interpreter_constraints": [ -// "CPython==3.9.*" +// "CPython==3.12.*" // ], // "generated_with_requirements": [ // "ansicolors==1.1.8", @@ -17,7 +17,9 @@ // "manylinux": "manylinux2014", // "requirement_constraints": [], // "only_binary": [], -// "no_binary": [] +// "no_binary": [], +// "excludes": [], +// "overrides": [] // } // --- END PANTS LOCKFILE METADATA --- @@ -27,6 +29,8 @@ "allow_wheels": true, "build_isolation": true, "constraints": [], + "elide_unused_requires_dist": false, + "excluded": [], "locked_resolves": [ { "locked_requirements": [ @@ -52,101 +56,120 @@ "artifacts": [ { "algorithm": "sha256", - "hash": "99b87a485a5820b23b879f04c2305b44b951b502fd64be915879d77a7e8fc6f1", - "url": "https://files.pythonhosted.org/packages/e0/44/827b2a91a5816512fcaf3cc4ebc465ccd5d598c45cefa6703fcf4a79018f/attrs-23.2.0-py3-none-any.whl" + "hash": "427318ce031701fea540783410126f03899a97ffc6f61596ad581ac2e40e3bc3", + "url": "https://files.pythonhosted.org/packages/77/06/bb80f5f86020c4551da315d78b3ab75e8228f89f0162f2c3a819e407941a/attrs-25.3.0-py3-none-any.whl" }, { "algorithm": "sha256", - "hash": "935dc3b529c262f6cf76e50877d35a4bd3c1de194fd41f47a2b7ae8f19971f30", - "url": "https://files.pythonhosted.org/packages/e3/fc/f800d51204003fa8ae392c4e8278f256206e7a919b708eef054f5f4b650d/attrs-23.2.0.tar.gz" + "hash": "75d7cefc7fb576747b2c81b4442d4d4a1ce0900973527c011d1030fd3bf4af1b", + "url": "https://files.pythonhosted.org/packages/5a/b0/1367933a8532ee6ff8d63537de4f1177af4bff9f3e829baf7331f595bb24/attrs-25.3.0.tar.gz" } ], "project_name": "attrs", "requires_dists": [ - "attrs[tests-mypy]; extra == \"tests-no-zope\"", - "attrs[tests-no-zope]; extra == \"tests\"", - "attrs[tests]; extra == \"cov\"", - "attrs[tests]; extra == \"dev\"", - "cloudpickle; platform_python_implementation == \"CPython\" and extra == \"tests-no-zope\"", + "cloudpickle; platform_python_implementation == \"CPython\" and extra == \"benchmark\"", + "cloudpickle; platform_python_implementation == \"CPython\" and extra == \"cov\"", + "cloudpickle; platform_python_implementation == \"CPython\" and extra == \"dev\"", + "cloudpickle; platform_python_implementation == \"CPython\" and extra == \"tests\"", + "cogapp; extra == \"docs\"", "coverage[toml]>=5.3; extra == \"cov\"", "furo; extra == \"docs\"", - "hypothesis; extra == \"tests-no-zope\"", - "importlib-metadata; python_version < \"3.8\"", - "mypy>=1.6; (platform_python_implementation == \"CPython\" and python_version >= \"3.8\") and extra == \"tests-mypy\"", + "hypothesis; extra == \"benchmark\"", + "hypothesis; extra == \"cov\"", + "hypothesis; extra == \"dev\"", + "hypothesis; extra == \"tests\"", + "mypy>=1.11.1; (platform_python_implementation == \"CPython\" and python_version >= \"3.10\") and extra == \"benchmark\"", + "mypy>=1.11.1; (platform_python_implementation == \"CPython\" and python_version >= \"3.10\") and extra == \"cov\"", + "mypy>=1.11.1; (platform_python_implementation == \"CPython\" and python_version >= \"3.10\") and extra == \"dev\"", + "mypy>=1.11.1; (platform_python_implementation == \"CPython\" and python_version >= \"3.10\") and extra == \"tests\"", + "mypy>=1.11.1; (platform_python_implementation == \"CPython\" and python_version >= \"3.10\") and extra == \"tests-mypy\"", "myst-parser; extra == \"docs\"", - "pre-commit; extra == \"dev\"", - "pympler; extra == \"tests-no-zope\"", - "pytest-mypy-plugins; (platform_python_implementation == \"CPython\" and python_version >= \"3.8\") and extra == \"tests-mypy\"", - "pytest-xdist[psutil]; extra == \"tests-no-zope\"", - "pytest>=4.3.0; extra == \"tests-no-zope\"", + "pre-commit-uv; extra == \"dev\"", + "pympler; extra == \"benchmark\"", + "pympler; extra == \"cov\"", + "pympler; extra == \"dev\"", + "pympler; extra == \"tests\"", + "pytest-codspeed; extra == \"benchmark\"", + "pytest-mypy-plugins; (platform_python_implementation == \"CPython\" and python_version >= \"3.10\") and extra == \"benchmark\"", + "pytest-mypy-plugins; (platform_python_implementation == \"CPython\" and python_version >= \"3.10\") and extra == \"cov\"", + "pytest-mypy-plugins; (platform_python_implementation == \"CPython\" and python_version >= \"3.10\") and extra == \"dev\"", + "pytest-mypy-plugins; (platform_python_implementation == \"CPython\" and python_version >= \"3.10\") and extra == \"tests\"", + "pytest-mypy-plugins; (platform_python_implementation == \"CPython\" and python_version >= \"3.10\") and extra == \"tests-mypy\"", + "pytest-xdist[psutil]; extra == \"benchmark\"", + "pytest-xdist[psutil]; extra == \"cov\"", + "pytest-xdist[psutil]; extra == \"dev\"", + "pytest-xdist[psutil]; extra == \"tests\"", + "pytest>=4.3.0; extra == \"benchmark\"", + "pytest>=4.3.0; extra == \"cov\"", + "pytest>=4.3.0; extra == \"dev\"", + "pytest>=4.3.0; extra == \"tests\"", "sphinx-notfound-page; extra == \"docs\"", "sphinx; extra == \"docs\"", "sphinxcontrib-towncrier; extra == \"docs\"", - "towncrier; extra == \"docs\"", - "zope-interface; extra == \"docs\"", - "zope-interface; extra == \"tests\"" + "towncrier; extra == \"docs\"" ], - "requires_python": ">=3.7", - "version": "23.2.0" + "requires_python": ">=3.8", + "version": "25.3.0" }, { "artifacts": [ { "algorithm": "sha256", - "hash": "b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374", - "url": "https://files.pythonhosted.org/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl" + "hash": "9deba5723312380e77435581c6bf4935c94cbfab9b1ed33ef8d238ea168eb760", + "url": "https://files.pythonhosted.org/packages/2c/e1/e6716421ea10d38022b952c159d5161ca1193197fb744506875fbb87ea7b/iniconfig-2.1.0-py3-none-any.whl" }, { "algorithm": "sha256", - "hash": "2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3", - "url": "https://files.pythonhosted.org/packages/d7/4b/cbd8e699e64a6f16ca3a8220661b5f83792b3017d0f79807cb8708d33913/iniconfig-2.0.0.tar.gz" + "hash": "3abbd2e30b36733fee78f9c7f7308f2d0050e88f0087fd25c2645f63c773e1c7", + "url": "https://files.pythonhosted.org/packages/f2/97/ebf4da567aa6827c909642694d71c9fcf53e5b504f2d96afea02718862f3/iniconfig-2.1.0.tar.gz" } ], "project_name": "iniconfig", "requires_dists": [], - "requires_python": ">=3.7", - "version": "2.0.0" + "requires_python": ">=3.8", + "version": "2.1.0" }, { "artifacts": [ { "algorithm": "sha256", - "hash": "8c491190033a9af7e1d931d0b5dacc2ef47509b34dd0de67ed209b5203fc88c7", - "url": "https://files.pythonhosted.org/packages/ec/1a/610693ac4ee14fcdf2d9bf3c493370e4f2ef7ae2e19217d7a237ff42367d/packaging-23.2-py3-none-any.whl" + "hash": "29572ef2b1f17581046b3a2227d5c611fb25ec70ca1ba8554b24b0e69331a484", + "url": "https://files.pythonhosted.org/packages/20/12/38679034af332785aac8774540895e234f4d07f7545804097de4b666afd8/packaging-25.0-py3-none-any.whl" }, { "algorithm": "sha256", - "hash": "048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5", - "url": "https://files.pythonhosted.org/packages/fb/2b/9b9c33ffed44ee921d0967086d653047286054117d584f1b1a7c22ceaf7b/packaging-23.2.tar.gz" + "hash": "d443872c98d677bf60f6a1f2f8c1cb748e8fe762d2bf9d3148b5599295b0fc4f", + "url": "https://files.pythonhosted.org/packages/a1/d4/1fc4078c65507b51b96ca8f8c3ba19e6a61c8253c72794544580a7b6c24d/packaging-25.0.tar.gz" } ], "project_name": "packaging", "requires_dists": [], - "requires_python": ">=3.7", - "version": "23.2" + "requires_python": ">=3.8", + "version": "25.0" }, { "artifacts": [ { "algorithm": "sha256", - "hash": "7db9f7b503d67d1c5b95f59773ebb58a8c1c288129a88665838012cfb07b8981", - "url": "https://files.pythonhosted.org/packages/a5/5b/0cc789b59e8cc1bf288b38111d002d8c5917123194d45b29dcdac64723cc/pluggy-1.4.0-py3-none-any.whl" + "hash": "e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746", + "url": "https://files.pythonhosted.org/packages/54/20/4d324d65cc6d9205fabedc306948156824eb9f0ee1633355a8f7ec5c66bf/pluggy-1.6.0-py3-none-any.whl" }, { "algorithm": "sha256", - "hash": "8c85c2876142a764e5b7548e7d9a0e0ddb46f5185161049a79b7e974454223be", - "url": "https://files.pythonhosted.org/packages/54/c6/43f9d44d92aed815e781ca25ba8c174257e27253a94630d21be8725a2b59/pluggy-1.4.0.tar.gz" + "hash": "7dcc130b76258d33b90f61b658791dede3486c3e6bfb003ee5c9bfb396dd22f3", + "url": "https://files.pythonhosted.org/packages/f9/e2/3e91f31a7d2b083fe6ef3fa267035b518369d9511ffab804f839851d2779/pluggy-1.6.0.tar.gz" } ], "project_name": "pluggy", "requires_dists": [ + "coverage; extra == \"testing\"", "pre-commit; extra == \"dev\"", "pytest-benchmark; extra == \"testing\"", "pytest; extra == \"testing\"", "tox; extra == \"dev\"" ], - "requires_python": ">=3.8", - "version": "1.4.0" + "requires_python": ">=3.9", + "version": "1.6.0" }, { "artifacts": [ @@ -248,19 +271,59 @@ "artifacts": [ { "algorithm": "sha256", - "hash": "939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc", - "url": "https://files.pythonhosted.org/packages/97/75/10a9ebee3fd790d20926a90a2547f0bf78f371b2f13aa822c759680ca7b9/tomli-2.0.1-py3-none-any.whl" + "hash": "cb55c73c5f4408779d0cf3eef9f762b9c9f147a77de7b258bef0a5628adc85cc", + "url": "https://files.pythonhosted.org/packages/6e/c2/61d3e0f47e2b74ef40a68b9e6ad5984f6241a942f7cd3bbfbdbd03861ea9/tomli-2.2.1-py3-none-any.whl" + }, + { + "algorithm": "sha256", + "hash": "8d57ca8095a641b8237d5b079147646153d22552f1c637fd3ba7f4b0b29167a8", + "url": "https://files.pythonhosted.org/packages/03/b8/152c68bb84fc00396b83e7bbddd5ec0bd3dd409db4195e2a9b3e398ad2e3/tomli-2.2.1-cp312-cp312-macosx_11_0_arm64.whl" + }, + { + "algorithm": "sha256", + "hash": "cd45e1dc79c835ce60f7404ec8119f2eb06d38b1deba146f07ced3bbc44505ff", + "url": "https://files.pythonhosted.org/packages/18/87/302344fed471e44a87289cf4967697d07e532f2421fdaf868a303cbae4ff/tomli-2.2.1.tar.gz" + }, + { + "algorithm": "sha256", + "hash": "4a8f6e44de52d5e6c657c9fe83b562f5f4256d8ebbfe4ff922c495620a7f6cea", + "url": "https://files.pythonhosted.org/packages/52/e1/f8af4c2fcde17500422858155aeb0d7e93477a0d59a98e56cbfe75070fd0/tomli-2.2.1-cp312-cp312-macosx_10_13_x86_64.whl" }, { "algorithm": "sha256", - "hash": "de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f", - "url": "https://files.pythonhosted.org/packages/c0/3f/d7af728f075fb08564c5949a9c95e44352e23dee646869fa104a3b2060a3/tomli-2.0.1.tar.gz" + "hash": "db2b95f9de79181805df90bedc5a5ab4c165e6ec3fe99f970d0e302f384ad222", + "url": "https://files.pythonhosted.org/packages/5c/51/51c3f2884d7bab89af25f678447ea7d297b53b5a3b5730a7cb2ef6069f07/tomli-2.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl" + }, + { + "algorithm": "sha256", + "hash": "b82ebccc8c8a36f2094e969560a1b836758481f3dc360ce9a3277c65f374285e", + "url": "https://files.pythonhosted.org/packages/9c/de/6b432d66e986e501586da298e28ebeefd3edc2c780f3ad73d22566034239/tomli-2.2.1-cp312-cp312-musllinux_1_2_x86_64.whl" + }, + { + "algorithm": "sha256", + "hash": "400e720fe168c0f8521520190686ef8ef033fb19fc493da09779e592861b78c6", + "url": "https://files.pythonhosted.org/packages/9e/6e/fa2b916dced65763a5168c6ccb91066f7639bdc88b48adda990db10c8c0b/tomli-2.2.1-cp312-cp312-musllinux_1_2_aarch64.whl" + }, + { + "algorithm": "sha256", + "hash": "40741994320b232529c802f8bc86da4e1aa9f413db394617b9a256ae0f9a7f77", + "url": "https://files.pythonhosted.org/packages/ab/df/bfa89627d13a5cc22402e441e8a931ef2108403db390ff3345c05253935e/tomli-2.2.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl" + }, + { + "algorithm": "sha256", + "hash": "02abe224de6ae62c19f090f68da4e27b10af2b93213d36cf44e6e1c5abd19fdd", + "url": "https://files.pythonhosted.org/packages/b4/04/885d3b1f650e1153cbb93a6a9782c58a972b94ea4483ae4ac5cedd5e4a09/tomli-2.2.1-cp312-cp312-musllinux_1_2_i686.whl" + }, + { + "algorithm": "sha256", + "hash": "4e340144ad7ae1533cb897d406382b4b6fede8890a03738ff1683af800d54192", + "url": "https://files.pythonhosted.org/packages/c8/d6/fc9267af9166f79ac528ff7e8c55c8181ded34eb4b0e93daa767b8841573/tomli-2.2.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl" } ], "project_name": "tomli", "requires_dists": [], - "requires_python": ">=3.7", - "version": "2.0.1" + "requires_python": ">=3.8", + "version": "2.2.1" }, { "artifacts": [ @@ -284,9 +347,12 @@ "platform_tag": null } ], + "only_builds": [], + "only_wheels": [], + "overridden": [], "path_mappings": {}, - "pex_version": "2.1.148", - "pip_version": "23.1.2", + "pex_version": "2.55.2", + "pip_version": "24.2", "prefer_older_binary": false, "requirements": [ "ansicolors==1.1.8", @@ -295,7 +361,7 @@ "types-setuptools<58,>=56.2.0" ], "requires_python": [ - "==3.9.*" + "CPython==3.12.*" ], "resolver_version": "pip-2020-resolver", "style": "universal", @@ -304,5 +370,6 @@ "mac" ], "transitive": true, - "use_pep517": null + "use_pep517": null, + "use_system_time": false }