Automatically Generating License Data from Python Dependencies

computer-1869236_960_720We all know how important keeping track of your open-source licensing is for the average startup.  While most people think of open-source licenses as all being the same, there are meaningful differences that could have potentially serious legal implications for your code base.  From permissive licenses like MIT or BSD to so-called “reciprocal” or “copyleft” licenses, keeping track of the alphabet soup of dependencies in your source code can be a pain.

Today, we’re releasing pylicense, a simple python module that will add license data as comments directly from your requirements.txt or environment.yml files.


pylicense.py requirements.txt

or

pylicense.py -e environment.yml

Under the covers, it uses xmlrpclib to fetch package data from pypi and looks for the “license” tag or the “License” classifier. The operation is also idempotent so if you’ve already commented the file with the license, it will not add them in.

Starting with an environment.yml file like this

name: website
dependencies:
- astroid=1.3.2=py27_0
- cairo=1.12.18
- cffi=1.1.2=py27_0
- dill=0.2.2=py27_0
....

will yield a file like this one

name: website
dependencies:
- astroid=1.3.2=py27_0  # LGPL
- cairo=1.12.18  # LGPL 2.1, MPL 1.1
- cffi=1.1.2=py27_0  # MIT
- dill=0.2.2=py27_0  # 3-clause BSD
....

The python module is free, and easily installable from github. For more information (including installation and usage), checkout the github page at https://github.com/thedataincubator/pylicense.  For the record, pylicense itself is licensed under the MIT license. Enjoy!

Editor’s Note: The Data Incubator is a data science education company.  We offer a free eight-week Fellowship helping candidates with PhDs and masters degrees enter data science careers.  Companies can hire talented data scientists or enroll employees in our data science corporate training.

Related Blog Posts

Moving From Mechanical Engineering to Data Science

Moving From Mechanical Engineering to Data Science

Mechanical engineering and data science may appear vastly different on the surface. Mechanical engineers create physical machines, while data scientists deal with abstract concepts like algorithms and machine learning. Nonetheless, transitioning from mechanical engineering to data science is a feasible path, as explained in this blog.

Read More »
Data Engineering Project

What Does a Data Engineering Project Look Like?

It’s time to talk about the different data engineering projects you might work on as you enter the exciting world of data. You can add these projects to your portfolio and show the best ones to future employers. Remember, the world’s most successful engineers all started where you are now.

Read More »
open ai

AI Prompt Examples for Data Scientists to Use in 2023

Artificial intelligence (AI) isn’t going to steal your data scientist job! Instead, AI tools like ChatGPT can automate some of the more mundane tasks in your future career, saving you time and energy. To make life easier, here are some data science prompts to get you started.

Read More »