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

Tidying up sample.env #294

Merged
merged 2 commits into from
Jul 3, 2023
Merged

Conversation

gigamonkey
Copy link
Contributor

I think .env files don't actually support variable expansion so I fixed that and removed a stray export. And I added a comment about running poetry self add poetry-dotenv-plugin which is actually the real point of this PR.

I don't know if the default values I gave for the four DBURL variables are right but they work for me in both the docker composed server and when building the book in the shell created by poetry shell.

@bnmnetp
Copy link
Member

bnmnetp commented Jul 1, 2023

You are correct... I have WEB2PY_CONFIG set in my config.fish / .bashrc file. So that was masking the problem.

@bnmnetp
Copy link
Member

bnmnetp commented Jul 1, 2023

I think we should document this in the developing.rst file

@gigamonkey
Copy link
Contributor Author

Do you understand poetry well enough to say whether running poetry self add poetry-dotenv-plugin has a global affect or just in the project? If you don't know I can try to figure that out and add something to the docs.

@gigamonkey
Copy link
Contributor Author

Hmmm. Seems like poetry self add is doing something to poetry itself so I guess it has a global effect. A quick test of creating a new directory with a pyproject.toml and a .env in it shows that the new poetry shell in that dir does indeed slurp in the variables in the .env file. And this PR on the poetry projects makes it seem like per-project plugins is not a thing yet.

python-poetry/poetry#5740

So I guess that means we can just recommend the plugin as an easy way to deal with the rs project but point out that it is a global choice that maybe you don't want.

Comment on lines +222 to +224
login shell environment (such as a .bashrc file) But you can also set them in
the ``.env`` file and as long as you have a RUNESTONE_PATH set commands like
``rsmanage`` and ``runestone`` will try to read and use those variables.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm a bit confused by this sentence compared to the disclaimer about rsmanage at line 232.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be clear, the thing I was confused about was at 232 where it says:

"As of this writing (June 2023) rsmanage does not know about the .env file so you will have to
set them in your login shell if you want to use rsmanage."

@bnmnetp
Copy link
Member

bnmnetp commented Jul 2, 2023

I have been adding support for .env files directly to rsmanage and runestone so that if you install them from pypi or to a .local installation of python they will try to find a suitable .env file. I like that we can have poetry read it, but that is only going to help if you are in a poetry shell or if you do poetry run rsmanage

@gigamonkey
Copy link
Contributor Author

Where does it look for the .env if you're running it from pypi? (I assume that means if you did a pip install runestone) in RUNESTONE_PATH? That seems useful.

Anyway, it seems to me in the context of the docs for developers I'd assume they'd be running from the repo not from something they installed with pip so it makes sense to support having everything just work if they are in a poetry shell or using poetry to run the commands. Anyway, the mental model for me of, cd into the rs directory, run poetry shell and then everything Just Works is very appealing.

@bnmnetp
Copy link
Member

bnmnetp commented Jul 3, 2023

Yes, RUNESTONE_PATH is used to find the .env file in the root of the rs repo.

Both runestone and rsmanage should be doing this now.

I also like the idea of poetry shell just doing it.

@bnmnetp bnmnetp merged commit 7415586 into RunestoneInteractive:main Jul 3, 2023
@gigamonkey gigamonkey deleted the sample-env branch July 4, 2023 01:09
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.

2 participants