8000 Provide a way to set environment variables outside of code.py · Issue #4212 · adafruit/circuitpython · GitHub
[go: up one dir, main page]

Skip to content

Provide a way to set environment variables outside of code.py #4212

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

Closed
tannewt opened this issue Feb 17, 2021 · 3 comments · Fixed by #6407
Closed

Provide a way to set environment variables outside of code.py #4212

tannewt opened this issue Feb 17, 2021 · 3 comments · Fixed by #6407

Comments

@tannewt
Copy link
Member
tannewt commented Feb 17, 2021

Once we have a way, we can replace secrets.py use with it. os.environ is the common way for sharing secrets in CPython. For example, GitHub Actions secrets are provided as environment variables.

@tannewt tannewt added this to the Long term milestone Feb 17, 2021
@tannewt tannewt changed the title Provide a way to set os.environ outside of code.py Provide a way to set environment variables outside of code.py Mar 22, 2022
@tannewt
Copy link
Member Author
tannewt commented Mar 23, 2022

It'll be simpler to support this through os.getenv(): https://docs.python.org/3/library/os.html#os.getenv Having it be a function will give us more flexibility to run code on access.

Also note the dotenv Python library looks like a really good model. https://github.com/theskumar/python-dotenv It is used to manage environment variables for projects in regular Python with .env files.

@askpatrickw
Copy link

I had some notes on this, looked at other approaches, etc... might be helpful to look at before coding starts.

https://gist.github.com/askpatrickw/610a83c489c6588055f6d1d3fd933fa7

dhalbert pushed a commit that referenced this issue May 26, 2022
os.getenv() will use it (when available) to load variables from
/.env

This will also be useful when we need secrets or config for
CircuitPython outside of the VM (like WiFi credentials.)

Fixes #4212
dhalbert pushed a commit to dhalbert/circuitpython that referenced this issue Aug 9, 2022
Formerly, py/formatfloat would print whole numbers inaccurately with
nonzero digits beyond the decimal place.  This resulted from its strategy
of successive scaling of the argument by 0.1 which cannot be exactly
represented in floating point.  The change in this commit avoids scaling
until the value is smaller than 1, so all whole numbers print with zero
fractional part.

Fixes issue adafruit#4212.

Signed-off-by: Dan Ellis dan.ellis@gmail.com
jepler pushed a commit to jepler/circuitpython that referenced this issue Sep 5, 2022
Formerly, py/formatfloat would print whole numbers inaccurately with
nonzero digits beyond the decimal place.  This resulted from its strategy
of successive scaling of the argument by 0.1 which cannot be exactly
represented in floating point.  The change in this commit avoids scaling
until the value is smaller than 1, so all whole numbers print with zero
fractional part.

Fixes issue adafruit#4212.

Signed-off-by: Dan Ellis dan.ellis@gmail.com
@gitcnd
Copy link
gitcnd commented May 9, 2024

For anyone else arriving here, this appears to be replaced by settings.toml now - see https://learn.adafruit.com/scrolling-countdown-timer/create-your-settings-toml-file and https://docs.circuitpython.org/en/latest/docs/environment.html

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

Successfully merging a pull request may close this issue.

3 participants
0