Skip to content

Conversation

@briantoby
Copy link
Collaborator

@briantoby briantoby commented Sep 12, 2025

This branch avoids populating the importers and exporters init.py files and it will also load importers from a user's ~/.GSASII/ports/ directories ( = "ex" or "im"). It should also simply reject a file with Python errors rather than prevent GSAS-II from running.

  • Documentation for "how to write an im/exporter (which is somewhere) needs an update to match these changes

@briantoby briantoby requested a review from tacaswell September 12, 2025 17:28
@briantoby briantoby self-assigned this Sep 12, 2025
@briantoby briantoby added Needed GSAS-II Inadequacies Done? Probably complete, but not yet closed labels Sep 12, 2025
@tacaswell
Copy link
Collaborator

The best path here is to use entry points to allow registration of additional importers/exporters, but looking at a given folder is reasonable.

I do not think supporting users dropping .py files into the installation is a good idea and the __init__.py should reflect the static nature of what is in the package. Having users drop files in the installed environment has a couple of problems with how packaging is notionally supposed to work:

  • if gsas-ii is installed in an environment where the user does not have write access or is otherwise shared between users
  • if the user is using pixi and has gsas-ii as a dependency, pixi may re-create the environment losing the extra file

This is also counter how the overall theory of how package managers view the world in that there are some parts of the file system the user owns and some parts of the file system that the package manager owns. Once GSAS-II is installed by a package manager (which is the end goal!) which ever manager it is then will own ./imports and we should not be telling users to dump stuff there.

@briantoby
Copy link
Collaborator Author

briantoby commented Sep 12, 2025

but looking at a given folder is reasonable.

I can see your argument that software should be installed as supplied (except by developers), but would you have a problem with allowing customization by looking for additional modules in ~/.GSASII/imports/ or ~/.GSASII/exports/? I have put the init files back, but left the capability for customization. I could imagine that at some point in the future we might not include some not-very-widely used importers in the standard distribution to cut down on the size of menus, but we could make "outtakes" available so people can easily use them if needed.

@tacaswell
Copy link
Collaborator

would you have a problem with allowing customization by looking for additional modules in ~/.GSASII/imports/ or ~/.GSASII/exports/?

This is what I meant by "...but looking at a given folder is reasonable.". It puts user-controlled extensions solidly in a space controlled only by the users.

@briantoby briantoby merged commit ed7075e into main Sep 15, 2025
12 of 24 checks passed
@briantoby briantoby deleted the autoImportCode branch September 15, 2025 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Done? Probably complete, but not yet closed Needed GSAS-II Inadequacies

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants