How am I supposed to generate the lockfile for `de...
# general
a
How am I supposed to generate the lockfile for
default_lockfile_resource
for a plugin? I found this issue, but that tool only supports builtin tools
h
That is up to you as the plugin author - however you generated that lockfile originally I suppose. That script is a convenience for the built in lockfiles, but it’s not doing anything magical. You could create a version of it in your own flow.
a
I didn't have one, it didn't seem to be required until 2.22 😄
h
Oh I see, you never had a lockfile before, and now you must have one? What is this plugin?
a
It's some internal stuff we use to release applications. It just needs itself and boto3
h
So you can look at what that script does, which is just a small convenience wrapper around a Pants command that should work for your case too, no?
Your plugin should provide default requirements for the lockfile
a
But is it just a regular pants lockfile?
h
It is just a regular Pants lockfile, yep
Its only “special” status is that you provide it as an embedded resource, so the user doesn’t have to generate it
but frankly this “convenience” is not worth the trouble, and in the new Python backend I plan to get rid of all this default lockfile machinery.
And make all lockfiles equal citizens
🤗 1
a
It's a bit frustrating since you cannot generate lockfiles without having one 😄
h
Is that true? Huh
Pretty sure you should be able to
The lockfile generation is done by pex which is not installed by lockfile
a
I mean, on pants 2.23, it crashes trying to load the plugin. 🙂
and I think if I disable it, nothing will work since we're using targets it defines
Had to go back to 21
Oh, right, I need
default_requirements
too.
Okay, that seems to work, let's see if it breaks when we try to release something 😄
Thanks
h
Hmm what crashes exactly? What is the stack trace?
Ah, good that you fixed it
a
Copy code
cbirzan@GP3CMXYV9V:~/PycharmProjects/cr_python$ pants generate-lockfiles
17:36:11.21 [INFO] Reading /Users/cbirzan/PycharmProjects/cr_python/.python-version to determine desired version for [python-bootstrap].search_path.
17:36:11.86 [ERROR] [Errno 2] No such file or directory: '/Users/cbirzan/PycharmProjects/cr_python/pants_plugins/ci/release/catapult-release.lock'
Traceback (most recent call last):
  File "/Users/cbirzan/Library/Caches/nce/6faa4322d1df41d032e4938795c6f2c262ab92bb642a9bac1101cb7d1631f9c1/bindings/venvs/2.23.0/lib/python3.9/site-packages/pants/bin/daemon_pants_runner.py", line 133, in single_daemonized_run
    scheduler, options_initializer = self._core.prepare(options_bootstrapper, complete_env)
  File "/Users/cbirzan/Library/Caches/nce/6faa4322d1df41d032e4938795c6f2c262ab92bb642a9bac1101cb7d1631f9c1/bindings/venvs/2.23.0/lib/python3.9/site-packages/pants/pantsd/pants_daemon_core.py", line 130, in prepare
    options = self._options_initializer.options(
  File "/Users/cbirzan/Library/Caches/nce/6faa4322d1df41d032e4938795c6f2c262ab92bb642a9bac1101cb7d1631f9c1/bindings/venvs/2.23.0/lib/python3.9/site-packages/pants/init/options_initializer.py", line 166, in options
    return options_bootstrapper.full_options(build_config, union_membership)
  File "/Users/cbirzan/Library/Caches/nce/6faa4322d1df41d032e4938795c6f2c262ab92bb642a9bac1101cb7d1631f9c1/bindings/venvs/2.23.0/lib/python3.9/site-packages/pants/option/options_bootstrapper.py", line 311, in full_options
    options = self.full_options_for_scopes(
  File "/Users/cbirzan/Library/Caches/nce/6faa4322d1df41d032e4938795c6f2c262ab92bb642a9bac1101cb7d1631f9c1/bindings/venvs/2.23.0/lib/python3.9/site-packages/pants/option/options_bootstrapper.py", line 287, in full_options_for_scopes
    return self._full_options(
  File "/Users/cbirzan/Library/Caches/nce/6faa4322d1df41d032e4938795c6f2c262ab92bb642a9bac1101cb7d1631f9c1/bindings/venvs/2.23.0/lib/python3.9/site-packages/pants/util/memo.py", line 123, in memoize
    result = func(*args, **kwargs)
  File "/Users/cbirzan/Library/Caches/nce/6faa4322d1df41d032e4938795c6f2c262ab92bb642a9bac1101cb7d1631f9c1/bindings/venvs/2.23.0/lib/python3.9/site-packages/pants/option/options_bootstrapper.py", line 271, in _full_options
    ksi.subsystem_cls.register_options_on_scope(options, union_membership)
  File "/Users/cbirzan/Library/Caches/nce/6faa4322d1df41d032e4938795c6f2c262ab92bb642a9bac1101cb7d1631f9c1/bindings/venvs/2.23.0/lib/python3.9/site-packages/pants/option/subsystem.py", line 293, in register_options_on_scope
    for options_info in collect_options_info(cls):
  File "/Users/cbirzan/Library/Caches/nce/6faa4322d1df41d032e4938795c6f2c262ab92bb642a9bac1101cb7d1631f9c1/bindings/venvs/2.23.0/lib/python3.9/site-packages/pants/option/option_types.py", line 30, in collect_options_info
    attr = getattr(cls, attrname)
  File "/Users/cbirzan/Library/Caches/nce/6faa4322d1df41d032e4938795c6f2c262ab92bb642a9bac1101cb7d1631f9c1/bindings/venvs/2.23.0/lib/python3.9/site-packages/pants/option/option_types.py", line 200, in __get__
    return OptionsInfo(self._flag_names, self.get_flag_options(objtype))
  File "/Users/cbirzan/Library/Caches/nce/6faa4322d1df41d032e4938795c6f2c262ab92bb642a9bac1101cb7d1631f9c1/bindings/venvs/2.23.0/lib/python3.9/site-packages/pants/option/option_types.py", line 182, in get_flag_options
    help=_eval_maybe_dynamic(self._help, subsystem_cls),
  File "/Users/cbirzan/Library/Caches/nce/6faa4322d1df41d032e4938795c6f2c262ab92bb642a9bac1101cb7d1631f9c1/bindings/venvs/2.23.0/lib/python3.9/site-packages/pants/option/option_types.py", line 60, in _eval_maybe_dynamic
    return val(subsystem_cls) if inspect.isfunction(val) else val  # type: ignore[no-any-return]
  File "/Users/cbirzan/Library/Caches/nce/6faa4322d1df41d032e4938795c6f2c262ab92bb642a9bac1101cb7d1631f9c1/bindings/venvs/2.23.0/lib/python3.9/site-packages/pants/backend/python/subsystems/python_tool_base.py", line 115, in <lambda>
    help=lambda cls: cls._install_from_resolve_help(),
  File "/Users/cbirzan/Library/Caches/nce/6faa4322d1df41d032e4938795c6f2c262ab92bb642a9bac1101cb7d1631f9c1/bindings/venvs/2.23.0/lib/python3.9/site-packages/pants/backend/python/subsystems/python_tool_base.py", line 85, in _install_from_resolve_help
    package_and_version = cls._default_package_name_and_version()
  File "/Users/cbirzan/Library/Caches/nce/6faa4322d1df41d032e4938795c6f2c262ab92bb642a9bac1101cb7d1631f9c1/bindings/venvs/2.23.0/lib/python3.9/site-packages/pants/backend/python/subsystems/python_tool_base.py", line 228, in _default_package_name_and_version
    lock_bytes = importlib.resources.read_binary(parts.netloc, lockfile_path)
  File "/Users/cbirzan/Library/Caches/nce/bf0cd90204a2cc6da48cae1e4b32f48c9f7031fbe1238c5972104ccb0155d368/cpython-3.9.18+20240107-aarch64-apple-darwin-install_only.tar.gz/python/lib/python3.9/importlib/resources.py", line 126, in read_binary
    with open_binary(package, resource) as fp:
  File "/Users/cbirzan/Library/Caches/nce/bf0cd90204a2cc6da48cae1e4b32f48c9f7031fbe1238c5972104ccb0155d368/cpython-3.9.18+20240107-aarch64-apple-darwin-install_only.tar.gz/python/lib/python3.9/importlib/resources.py", line 91, in open_binary
    return reader.open_resource(resource)
  File "<frozen importlib._bootstrap_external>", line 1055, in open_resource
FileNotFoundError: [Errno 2] No such file or directory: '/Users/cbirzan/PycharmProjects/cr_python/pants_plugins/ci/release/catapult-release.lock'
But, yeah, it's fine, just downgraded and fixed it like that.
Still a bit of a catch22, but I guess this is not very common