xraypy / xraylarch

Larch: Applications and Python Library for Data Analysis of X-ray Absorption Spectroscopy (XAS, XANES, XAFS, EXAFS), X-ray Fluorescence (XRF) Spectroscopy and Imaging, and more.
https://xraypy.github.io/xraylarch
Other
127 stars 62 forks source link

Install optional dependencies with "extras" requirements #468

Closed t20100 closed 8 months ago

t20100 commented 9 months ago

What about using setuptools's extras_require to defines optional dependencies?

You could then have e.g., pip install xraylarch[gui], xraylarch[jupyter], xraylarch[dev],... This remains fully compatible with installer scripts, but it would avoid to have copies of the dependencies at different places (the scripts can then call e.g., pip install xraylarch[gui,jupyter]. This is mostly for use with pip.

It would also give a single place where to look for dependencies. Indeed, when updating dependencies in xraylarch conda packaging, it wasn't clear what are the optional dependencies.

maurov commented 9 months ago

@t20100 thanks for proposing this. I am in favor of it. Personally, I would like to get rid of the install_extras command in various places. Installing packages at the runtime is dangerous.

newville commented 9 months ago

@t20100 @maurov Yes, I am in favor of this. Switching to pyproject/setup.cfg has been on my to-do list for a while, and that would make that easier. I think the main questions for me are what are "basic" and what are "extras", but I agree with the concept.

t20100 commented 9 months ago

For the conda packaging, I considered current requirements.txt as the default dependencies since this is enforced by setup.py as install_required dependencies and the rest as "extras" dependencies.

newville commented 9 months ago

@t20100 Yes, I agree. That's not to say we can't change what is listed there ;).

newville commented 8 months ago

@t20100 @maurov OK, I have made progress on setup.cfg with multiple [options.extras_require] paragraphs, and removing all of the code to add packages needed for specific domains at runtime.

I committed to master, but really as a request-for-comments, that setup.cfg has a [larix] option that will require everything needed for wxPython GUIs and for Jupyter notebooks, including ploty and py3dmol. This [larix] is different from [all] in not installing [dev] and [doc] requirements.

I have tested proof-of-concept installations scripts that will eventually do

pip install xraylarch[larix]

For completeness, a plain

pip install xraylarch

will install a pretty bare "xraylarch library", but some might want installed on a server.

At the moment, the xraylarch on PyPI does not have a [larix] target. I would like to tag and push the master branch as 0.9.73 fairly soon (end of the week?) to update these installation scripts.

t20100 commented 8 months ago

This looks great, thanks! It makes it really clear.

maurov commented 8 months ago

@newville it is fine from my side too, thanks! I would then remove the redundant requirements.txt and requirements-extra.txt