-
Notifications
You must be signed in to change notification settings - Fork 301
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
[Python] Generates .fs.py
when outDir
option is not provided
#3616
Comments
Yes, files are modules in Python so files cannot contain dots in their name (only underscores), since that would Python think there's a submodule when importing them i.e that the name before the dot is a folder and the name after the dot is a file. https://peps.python.org/pep-0008/#package-and-module-names |
Got it. I suppose using |
Using _fs.py would be an option. I didn't think about it at the time. But I suppose it will still not be grouped like above? |
It will in VSCode, you can configure the rule for nesting the file, in this case using the following works: "*.fs": "${basename}_fs.py", If we do implement this feature, I will send a update to Ionide as it is missing others nesting rules. |
@MangelMaxime, the main issue with this, as I understand it, is that it precludes authoring python libraries in F#. all the modules will have _fs suffix for python consumers. |
@smoothdeveloper all the modules will have _fs suffix for python consumers. Not necessarily, if you provide |
Another problem with Python is that all the compiled files must be within the same subdir. If not, then Python cannot import them. That means that e.g imported projects will have to be installed (site-packages, or other sys.path) or we need to use a package manager like e.g Poetry to setup the path relative dependencies to them. Then we enforce the users of Fable to also use Poetry (which we don't do today). We could of course just leave it alone and say that the main program expects to be able to import the dependencies somehow, but then many examples with projet references will fail. https://github.com/fable-compiler/Fable/blob/main/src/Fable.Cli/Main.fs#L163 PS: There's btw a (hidden) feature that if fable lib is set to be in site packages e.g |
@dbrattli, I'm not yet sensibilized with all the ways python works with loading modules, I think people actually update I tried I'd be worried about forcing people to install fable packages (in site-packages) by default (dll hell), or to force usage of I'd rather see a FAQ with guidance how to update If python users adopt fable, and start suggesting better integration with Does that sound reasonable? I'm not a python expert, and for now, loading fable generated code and the fable standard library in both a structure of scripts (in same tree) or jupyter notebook worked without doing anything (I have a pyproject.toml and init.py files at the right locations though). |
Description
Hello @dbrattli,
The python target seems to be the only to not generates
.fs.py
whenoutDir
is not provided.Is there a reason for that or this is just something forgotten / not known at the time ?
It would be nice if we could generate
.fs.py
files as it allows IDE/Editors like VSCode to nest the files together to not pollute too much the explorer.The text was updated successfully, but these errors were encountered: