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

Optional dependencies #506

Open
FedericoCeratto opened this issue Jun 15, 2018 · 12 comments
Open

Optional dependencies #506

FedericoCeratto opened this issue Jun 15, 2018 · 12 comments

Comments

@FedericoCeratto
Copy link
Member

Optional dependencies are a good way to prevent dependency hell and make packages more modular.

The .nimble file could support traditional (aka required), "recommended" and optional dependencies.

Nimble could install the first two types by default, and provide a flag to skip recommended ones and another one to install both recommended and optional.

At build time, depending on what is available, Nimble could set a define for each dependency e.g. "dep_".

Perhaps this could also be used to install additional examples, manuals, test files, utilities...

Related to #482

@FedericoCeratto
Copy link
Member Author

@dom96 any update on this? https://github.com/FedericoCeratto/nim-httpauth would benefit from it.

@dom96
Copy link
Collaborator

dom96 commented May 3, 2019

How would it benefit?

@krux02
Copy link
Contributor

krux02 commented Sep 6, 2019

Optional dependencies would be a great benefit. Simple example are situations where multiple backends are avaiable for a common interaface, some of them commecial. You don't want to have them all as a forced dependency. DirectX for rendering (no point to install it on Linux). Gurobi for Linear programming (not everybody has $$$). etc

@Araq
Copy link
Member

Araq commented Sep 6, 2019

if and when statements are totally a thing in a .nimble file since it's NimScript...

@FedericoCeratto
Copy link
Member Author

@dom96 httpauth is a good example of a library with multiple backends, and therefore multiple dependencies, where the developer typically wants to use only one.

Encouraging library developers to use forced dependencies by default leads to bloated code, unnecessary dependency conflicts, npm-like security disasters, broken builds due to incompatible or retired libraries.
Nim is especially at risk due to the volatile library ecosystem and the use of static linking. And backward-incompatible compiler releases.

@dom96
Copy link
Collaborator

dom96 commented Sep 8, 2019

My intention wasn't to challenge whether this feature should be implemented, I just want to gather the use cases. I do think it is important even if right now it's relatively low pri.

@iffy
Copy link
Contributor

iffy commented Sep 10, 2020

Another example use case: there might be some requirements that are only required for testing/development of the library, but users of the library don't need them.

@genotrance
Copy link
Contributor

Another example use case: there might be some requirements that are only required for testing/development of the library, but users of the library don't need them.

That's basically #482.

@ringabout
Copy link
Member

ringabout commented Sep 14, 2020

I need optional dependencies too.
Now I use nimble task as a workaround.

task prologue, "install prologue":
  exec "nimble install prologue >= 0.3.6"

task fsnotify, "install fsnotify":
  exec "nimble install fsnotify >= 0.1.0"

task extension, "install all":
  exec "nimble prologue"
  exec "nimble fsnotify" 

I will also use my command tools logue to install these dependencies anywhere.

@capocasa
Copy link

capocasa commented Jan 6, 2021

A hybrid library may have dependencies that are only required for the executable, but not for the library itself. Those dependencies might cause conflicts for users who only require the library.

@disruptek
Copy link

I use...

when not defined(release):
  requires "... some testing stuff ..."

...with the conceit that eventually a package manager might do the right thing.

@FedericoCeratto
Copy link
Member Author

FedericoCeratto commented Jan 7, 2021

To further clarify the use - a developer should be able to list the optional dependencies that can be enabled and disabled across the whole dependency tree without having to read documentation, .nimble files or sources across the whole tree.

E.g. myapplication ==> library 1 --> optional lib 2 ==> lib 3 ==> bulky lib 4 (a thin arrow means optional)

The developer is shown: 2: support USB mug warmer. Requires 3 and 4. and decides not to use the whole subtree. Libs 2, 3, 4 are not used (even if they happen to be in ~/.nimble/pkgs for some reason)

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

No branches or pull requests

9 participants