Best way to reuse just a small set of files from another Open-Source project?

Viewed 206

image that another Open-Source project on Github provides some parts that I would like to reuse in my project, like

  • a few stylesheets,
  • a CSS,
  • a small module, or
  • a LaTeX template.

All I need is a small subset of the other project. Often the scope and functionality of the other project is very far from mine.

What will be the best way to organize this from a practical (assuming the legal perspective is covered by the existing license)? Ideally, merging improvements from the upstream repository and sending pull requests for local improvements I create back to the original project would remain possible.

a) I could add the other Github repository to the requirements.txt of my project, install it and optionally delete all the parts that I do not need after installation in my installation procedure (setup.py etc.). b) I could fork the other Github repository, reduce my fork thereof to the files I need, and add my fork to the requirements of my new project.

I found Linking a single file from another git repository, but his does not really address my needs.

Of course, it is risky to establish a rigid link to the internal organization of another project. But that is not the issue in here.

Any ideas?

1 Answers

If you really need to keep a strong link between some files of a repository and your own project repo, I would:

  • add a fork of the first repository as a submodule inside my own project repository
  • use symlinks inside my project for the few files I need (symlink to the submodule required file)

That way:

  • I can use those files anywhere inside my project
  • each time I modify them, I actually change their content in the submodule repository, which makes it easier to identify the change, and make a pull request
Related