When running python -m prismedia.genconfig from a brand new install as documented, we got an error
/home/victor/.pyenv/versions/3.9.1/lib/python3.9/runpy.py:127: RuntimeWarning: 'prismedia.genconfig' found in sys.modules after import of package 'prismedia', but prior to execution of 'prismedia.genconfig'; this may result in unpredictable behaviour
warn(RuntimeWarning(msg))
It appears that it's just a warning, as the files are created, but it misleading and confusing, especially as it's the first thing new user see :-/
After some research, it come from a problem in python3. The module (genconfig.py) and the function inside (genconfig()) have the exact same name, so python throw this warning.
We should update the function name to avoid this.
Hello,
When running `python -m prismedia.genconfig` from a brand new install as documented, we got an error
```
/home/victor/.pyenv/versions/3.9.1/lib/python3.9/runpy.py:127: RuntimeWarning: 'prismedia.genconfig' found in sys.modules after import of package 'prismedia', but prior to execution of 'prismedia.genconfig'; this may result in unpredictable behaviour
warn(RuntimeWarning(msg))
```
It appears that it's just a warning, as the files are created, but it misleading and confusing, especially as it's the first thing new user see :-/
After some research, it come from a problem in python3. The module (genconfig.py) and the function inside (genconfig()) have the exact same name, so python throw this warning.
We should update the function name to avoid this.
The exact problem is in fact that __init__.py import genconfig, while using python with -m already import it as a .py in the root of the project!
So, it's imported two times, which is a problem for python. It was an old behaviour from python 2.6, we may drop it.
Removing the import from init.py avoid the warning, and explicitely calling prismedia.genconfig still works
❯ ls # No files present
❯ python -m prismedia.genconfig # No warning displayed
❯ ls # Files are here
peertube_secret.sample youtube_secret.json.sample
Ok it's a little different from what I thought.
The exact problem is in fact that `__init__.py` import genconfig, while using python with `-m` already import it as a .py in the root of the project!
So, it's imported two times, which is a problem for python. It was an old behaviour from python 2.6, we may drop it.
Removing the import from init.py avoid the warning, and explicitely calling `prismedia.genconfig` still works
```
❯ ls # No files present
❯ python -m prismedia.genconfig # No warning displayed
❯ ls # Files are here
peertube_secret.sample youtube_secret.json.sample
```
While I am on it, I'll improve this genconfig process.
For the moment it's hard to use, not very clear (2 lines of doc between all the others), it creates files with .sample which is confusing if the user miss the "rename them" info, ...
Target:
Improve documentation, more space, more details
Improve function, more verbosity, creates file with no .sample and check if files exist
While I am on it, I'll improve this genconfig process.
For the moment it's hard to use, not very clear (2 lines of doc between all the others), it creates files with `.sample` which is confusing if the user miss the "rename them" info, ...
Target:
* Improve documentation, more space, more details
* Improve function, more verbosity, creates file with no .sample and check if files exist
LecygneNoir
changed title from prismedia.genconfig sends a warning to Improve prismedia.genconfig process and verbosity2 years ago
Hello,
When running
python -m prismedia.genconfig
from a brand new install as documented, we got an errorIt appears that it's just a warning, as the files are created, but it misleading and confusing, especially as it's the first thing new user see :-/
After some research, it come from a problem in python3. The module (genconfig.py) and the function inside (genconfig()) have the exact same name, so python throw this warning.
We should update the function name to avoid this.
Thanks @zykino for the report!
Ok it's a little different from what I thought.
The exact problem is in fact that
__init__.py
import genconfig, while using python with-m
already import it as a .py in the root of the project!So, it's imported two times, which is a problem for python. It was an old behaviour from python 2.6, we may drop it.
Removing the import from init.py avoid the warning, and explicitely calling
prismedia.genconfig
still worksWhile I am on it, I'll improve this genconfig process.
For the moment it's hard to use, not very clear (2 lines of doc between all the others), it creates files with
.sample
which is confusing if the user miss the "rename them" info, ...Target:
prismedia.genconfig sends a warningto Improve prismedia.genconfig process and verbosity 2 years agoClose by #59