Package: pip-module-scanner
PIP Module ScannerScans your Python project for all installed third party pip libraries that are used and generates a requirements.txt based output.InstallationInstalling the scanner is easy, either clone the repository and run the script or install it via pip like so:$pipinstallpip-module-scannerUsageUsing the scanner is incredibly simple. Open a terminal and navigate to your project folder, run the script and watch magic happen before your eyes. Example:$cd~/projects/my-awesome-project/
$pip-module-scannerfoo==1.0.0bar==2.1.0baz==0.0.1Specifying a custom pathYou can specify a custom path in which you want to run the script with the-por--pathargument. Example:$pip-module-scanner--path~/projects/my-awesome-project/foo==1.0.0bar==2.1.0baz==0.0.1Writing the output to a fileYou can write the output of the script to a file by using the-oor--outargument. Example:$cd~/projects/my-awesome-project/
$pip-module-scanner-orequirements.txt
$catrequirements.txtfoo==1.0.0bar==2.1.0baz==0.0.1Integrating the code in your projectYou can easily integrate the scanner code in your own project so you can get the output of the scanner yourself or modify the class to suit your own needs. To do this, you can use it like so:frompip_module_scanner.scannerimportScannerscanner=Scanner()scanner.run()# do whatever you want with the results here# example:forlibinscanner.libraries_found:print("Found module%sat version%s"%(lib.key,lib.version))Specifying a path would work like so, make sure to also import theScannerExceptionas it will check if the path you specified is actually a real path:frompip_module_scanner.scannerimportScanner,ScannerExceptiontry:scanner=Scanner(path="~/projects/my-awesome-project/")scanner.run()# do whatever you want with the results here# example:forlibinscanner.libraries_found:print("Found module%sat version%s"%(lib.key,lib.version))exceptScannerExceptionase:print("Error:%s"%str(e))For the one-liner junkies out there (like me) you can also get all libraries with this nifty little one-liner (I'm so considerate)frompip_module_scanner.scannerimportScannerlibs=Scanner().run().libraries_found# Isn't it beautiful?Class definitionspip_module_scanner.scanner.Scanner([string path [, string output]])MethodArgumentTypeRequiredDescription__init__pathstringnoDirectory to recursively scan through, defaults to current working directory.outputstringnoOutput path to write the resutlts fromoutput()torunRuns the scan, output will be stored inlibraries_foundoutputWrites the output to the console or a path specified in the constructorPropertyTypeDescriptionlibraries_foundlist<pip._vendor.pkg_resources.EggInfoDistribution>List of all found pip libraries in your project, result fromScanner.run().LicenseMIT LicenseCopyright (c) 2016 Luke ParisPermission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.