Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recommended way of generating docs with dynamic versioning? #115

Open
cmarqu opened this issue Mar 28, 2023 · 6 comments
Open

Recommended way of generating docs with dynamic versioning? #115

cmarqu opened this issue Mar 28, 2023 · 6 comments
Labels
question Further information is requested

Comments

@cmarqu
Copy link
Contributor

cmarqu commented Mar 28, 2023

I am using sphinx-build to generate my documentation, and its conf.py contains a __version__ variable and is set up to be substituted by poetry-dynamic-versioning.
Unfortunately, poetry run is one of the few commands where dynamic versioning is not applied, so I cannot just call poetry run sphinx-build <args>.
Is there a recommended way of running such commands?
I can only think of doing something like git stash save && poetry dynamic-versioning && sphinx-build <args> && git restore . && git stash pop right now (which I noticed does not work correctly when there is nothing to stash; it pops some old stashed code then).

@mtkennerly mtkennerly added the question Further information is requested label Mar 28, 2023
@mtkennerly
Copy link
Owner

Hi! Does this work?

POETRY_DYNAMIC_VERSIONING_COMMANDS=run poetry run sphinx-build <args>

@cmarqu
Copy link
Contributor Author

cmarqu commented Mar 28, 2023

This unfortunately does not revert the version substitution after the command ran (including the changed enable = true to enable = false in pyproject.toml).

@mtkennerly
Copy link
Owner

mtkennerly commented Mar 28, 2023

Hmm, what OS, Python version, and Poetry version are you using? It works for me on Windows 11, Python 3.10.7, and Poetry 1.2.2. I think I remember that issue happening on Linux, though, and I'm not sure if there's anything the plugin can do about it since it has to do with how Poetry invokes the other process.

Code_c40RXesZw1.mp4

@cmarqu
Copy link
Contributor Author

cmarqu commented Mar 29, 2023

This is on RedHat Enterprise Linux 7, Python 3.11.2 and poetry 1.4.1.
I have to admit that I don't quite remember how I installed the plugin though, since poetry self add "poetry-dynamic-versioning[plugin]" had a problem (poetry is trying to install in a location where it can't write, it's not falling back to --user).
I will investigate more.

It would be helpful if there was a debug mode where the plugin reported what it is doing.

I solved my initial problem for now by getting __version__ from the output of poetry version --short.

@mtkennerly
Copy link
Owner

Here's the part of Poetry that prevents the plugin from cleaning up on Linux specifically:

https://github.com/python-poetry/poetry/blob/2b15ce10f02b0c6347fe2f12ae902488edeaaf7c/src/poetry/utils/env.py#L1893-L1894

This was originally identified in #6 when it used os.execvp. Now it's using os.execvpe, which has the same behavior.

I'm not sure if it's a good idea, but the plugin might be able to monkey patch execute (or just _is_windows) when the COMMANDS env var includes run. It may also be worth raising this with the Poetry maintainers since it does interfere with plugins' event listeners.

@mtkennerly
Copy link
Owner

A bit late, but I've just raised this issue in the Poetry repo: python-poetry/poetry#8092

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants