Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

mauritsvanrees
Copy link
Member

This is the same as the extends option, but then for optional files. The names must be file paths, not URLs. If the path does not exist, it is silently ignored.

This is useful for optionally loading a local.cfg or custom.cfg with options specific for the developer or the server.

I have seen various ways of having local options without checking this into version control:

  • Let git ignore buildout.cfg and have a sample buildout.cfg.in that you copy to buildout.cfg and adapt for the machine.
  • Have a local.cfg that extends buildout.cfg or an alternative like devel.cfg or production.cfg.
  • Let buildout.cfg extend custom.cfg which is not in version control, so you get an error when you don't yet have this file.

When this PR is merged, I intend to use this in the Plone core development buildout.

This is the same as the `extends` option, but then for optional files.
The names must be file paths, not URLs.  If the path does not exist,  it is silently ignored.

This is useful for optionally loading a `local.cfg` or `custom.cfg` with options specific for the developer or the server.

I have seen various ways of having local options without checking this into version control:

* Let git ignore `buildout.cfg` and have a sample `buildout.cfg.in` that you copy to `buildout.cfg` and adapt for the machine.
* Have a `local.cfg` that extends `buildout.cfg` or an alternative like `devel.cfg` or `production.cfg`.
* Let `buildout.cfg` extend `custom.cfg` which is not in version control, so you get an error when you don't yet have this file.

When this PR is merged, I intend to use this in the Plone core development buildout.
@mauritsvanrees mauritsvanrees force-pushed the maurits-optional-extends branch from 8aa75f4 to 0075582 Compare September 23, 2024 22:02
Copy link
Contributor

@icemac icemac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea seems to be interesting. I am not sure whether I'll be going to use it (went without it for > 10 years).

Mabye a message would be handy if the optional file does not exist. Could be rendered only in vebose mode (?).

@mauritsvanrees
Copy link
Member Author

Mabye a message would be handy if the optional file does not exist. Could be rendered only in vebose mode (?).

Good point. I now print a message when not found, regardless of verbosity:

optional-extends file not found: somefile.cfg

It would usually be the first line that is printed. This seems a useful hint for anyone using a Buildout with optional-extends.

@gotcha
Copy link
Member

gotcha commented Sep 26, 2024

Good idea !

Thanks for working on this !

@mauritsvanrees mauritsvanrees merged commit 45ba501 into master Sep 26, 2024
35 checks passed
@mauritsvanrees mauritsvanrees deleted the maurits-optional-extends branch September 26, 2024 20:18
@mauritsvanrees
Copy link
Member Author

Thanks for the reviews. I have released 3.2.0 with this.

mauritsvanrees added a commit to plone/buildout.coredev that referenced this pull request Sep 26, 2024
I added this option in buildout/buildout#665

For inspiration, here is part of my own `local.cfg`:

```
[buildout]
develop +=
    /Users/maurits/community/zest.releaser
auto-checkout +=
    plone.releaser
custom-eggs +=
    pdbpp

allow-picked-versions = true

[remotes]
plone = [email protected]:plone
collective = [email protected]:collective
zope = [email protected]:zopefoundation

[versions]
zest.releaser =
```

Originally the file started with these lines:

```
[buildout]
extends =
   buildout.cfg
```

and then I always ran `bin/buildout -c local.cfg`.
When I then wanted to use `plips/plip-distributions.cfg`, it got tricky because this was in a different directory, so I needed actual changes in git.
Now it works in both cases thanks to the `optional-extends`.
mauritsvanrees added a commit to plone/buildout.coredev that referenced this pull request Oct 1, 2024
I added this option in buildout/buildout#665

For inspiration, here is part of my own `local.cfg`:

```
[buildout]
develop +=
    /Users/maurits/community/zest.releaser
auto-checkout +=
    plone.releaser
custom-eggs +=
    pdbpp

allow-picked-versions = true

[remotes]
plone = [email protected]:plone
collective = [email protected]:collective
zope = [email protected]:zopefoundation

[versions]
zest.releaser =
```

Originally the file started with these lines:

```
[buildout]
extends =
   buildout.cfg
```

and then I always ran `bin/buildout -c local.cfg`.
When I then wanted to use `plips/plip-distributions.cfg`, it got tricky because this was in a different directory, so I needed actual changes in git.
Now it works in both cases thanks to the `optional-extends`.
@distributist
Copy link
Contributor

I just saw this in the pypi release notes. I've been using a workaround for this for a few years now; optional-extends is a great idea. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants