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

Remove context.py #257

Open
tovrstra opened this issue Jul 4, 2017 · 3 comments
Open

Remove context.py #257

tovrstra opened this issue Jul 4, 2017 · 3 comments
Labels
Milestone

Comments

@tovrstra
Copy link
Member

tovrstra commented Jul 4, 2017

Our context.py is currently our approach to locate installed data files (test data files, basis sets, ...), which we install nicely in the FHS-designated $PREFIX/share directory. (See http://www.pathname.com/fhs/) This has a few problems though:

  1. The solution is non-modular. When we start to split of packages, every single one will have a context.py (if the package has data files).
  2. It duplicates some functionality already present in Python (and setuptools) to access installed data files.
  3. It does not work on .egg installations.

There are a few alternatives:

@tovrstra tovrstra added this to the 3.0.0 milestone Jul 4, 2017
@tovrstra
Copy link
Member Author

tovrstra commented Aug 3, 2017

I've gained some more experience with this. The setuptools option works very well. These are the required steps:

  • Put all files that HORTON or its tests need inside the package directory, e.g. in a data subdirectory.
  • Include all these files in MANIFEST.in
  • Replace distutils to setuptools in setup.py
  • Replace Cython.Distutils by Cython.Build in setup.py
  • Set include_package_data=True when calling the setup function. Remove all other references to data files in setup.py.
  • Remove my_install_data from setup.py
  • Remove horton.context
  • Whenever you need an installed data file in HORTON, use the pkg_resources module, instead of horton.context. The module pkg_resources comes with setuptools. There are two ways of using it:

@tovrstra
Copy link
Member Author

tovrstra commented Aug 3, 2017

P.S. Depending on setuptools is not a big deal. It is omnipresent these days, e.g installed when you have pip.

@tovrstra
Copy link
Member Author

tovrstra commented Aug 3, 2017

A potential drawback is that nosetests does not find the tests when the package is installed as an Egg. The egg can be disabled in setup.py by adding an argument zip_safe=False to the setup() call.

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

No branches or pull requests

1 participant