Dependency Licence Compatibility: Follow-Up Questions for Package Authors

Picking a licence for your own package is the easy part. The awkward questions arrive later, when you add a dependency under a different licence, vendor a file from another project, or a company asks whether they can ship your library inside a closed product. This page collects the harder follow-ups. It is general education for developers, not legal advice; for anything with money or a contract attached, talk to a lawyer who works with open source.

Mixing licences inside one dependency graph

My MIT package depends on a GPL package. Is that allowed?

Publishing it is allowed; nothing stops you listing a GPL dependency. The question is what your users inherit. If someone distributes an application that combines your code with the GPL library, the GPL's conditions are likely to apply to that combined work. Your MIT label does not shield them. If you want your package to be usable in proprietary products, avoid hard GPL dependencies or make them optional, and say so plainly in the README.

Is Apache-2.0 compatible with the GPL?

The Free Software Foundation considers Apache License 2.0 compatible with GPL version 3, but not with GPL version 2 only. The usual reason given is Apache-2.0's patent termination and indemnity terms, which GPLv2 does not allow as additional restrictions. If a dependency says "GPL-2.0-only", treat combining it with Apache-2.0 code as a red flag worth checking.

What does "file-level copyleft" in MPL-2.0 mean for me?

The Mozilla Public License 2.0 applies its copyleft to the individual files it covers. If you modify an MPL file, those modified files must stay under MPL and their source must be available. Your own separate files can carry a different licence. That makes MPL dependencies far easier to live with than GPL ones for most library authors, as long as you keep the boundary between files clean.

Do devDependencies count?

Tools you only run during development, such as test runners, linters and bundlers, are not normally shipped to your users, so their licences rarely affect your package's licence. The exception is when a build tool injects its own code into your output, for example a runtime helper. Check what actually lands in the published tarball, not what sits in package.json.

Expressing the result in metadata

How do I declare a dual licence?

Use an SPDX licence expression. The Rust ecosystem's common convention is a good model:

// package.json
"license": "MIT OR Apache-2.0"

# Cargo.toml
license = "MIT OR Apache-2.0"

"OR" means the user may choose either licence. "AND" means both apply at once, which is what you want when a package contains files under two licences. Write the expression exactly; tools that build licence reports parse it literally.

What about Python packages?

Newer packaging metadata, described in PEP 639 and the Python Packaging User Guide, lets pyproject.toml carry an SPDX expression in the license key and list the licence files explicitly. Older projects relied on trove classifiers instead. If your build backend supports the newer form, prefer it, and check the guide for the backend version you need.

I copied one file from another project. What do I owe?

Keep that file's original copyright and licence header, keep the upstream licence text somewhere in your repository, and mention the file in a NOTICE or third-party section. If the upstream licence differs from yours, your package now contains two licences and its SPDX expression should reflect that with AND.

When companies get involved

A company asked me to relicense. Can I?

Only for code you hold the rights to. Contributions from other people remain under the licence they were made under unless every contributor agrees or you had a contributor agreement that allows it. Projects that expect to relicense one day tend to set this up early. If you never plan to, say so and save everyone the email.

For definitions of the terms used here, see the glossary; for the official licence texts, the SPDX License List and the Open Source Initiative are the sources to bookmark, and our resources page lists them.