diff --git a/pipreqs/pipreqs.py b/pipreqs/pipreqs.py index 24eeeb7..7d05a86 100644 --- a/pipreqs/pipreqs.py +++ b/pipreqs/pipreqs.py @@ -105,6 +105,11 @@ def get_all_imports( for root, dirs, files in walk: dirs[:] = [d for d in dirs if d not in ignore_dirs] + ipynb_files = [fn for fn in files if os.path.splitext(fn)[1] == ".ipynb"] + + for ipynb_file in ipynb_files: + os.system("ipython nbconvert --to script " + str(ipynb_file)) + candidates.append(os.path.basename(root)) files = [fn for fn in files if os.path.splitext(fn)[1] == ".py"] @@ -130,6 +135,11 @@ def get_all_imports( logging.error("Failed on file: %s" % file_name) raise exc + # Clean up created .py files from .ipynb files + + for ipynb_file in ipynb_files: + os.remove(ipynb_file.replace("ipynb", "py")) + # Clean up imports for name in [n for n in raw_imports if n]: # Sanity check: Name could have been None if the import diff --git a/requirements.txt b/requirements.txt index 959d1b7..6730091 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,5 @@ wheel==0.23.0 Yarg==0.1.9 -docopt==0.6.2 \ No newline at end of file +docopt==0.6.2 +ipython==8.4.0 +nbconvert==7.0.0 \ No newline at end of file diff --git a/tests/_data_ignore/requirements.txt b/tests/_data_ignore/requirements.txt new file mode 100644 index 0000000..4e1e92d --- /dev/null +++ b/tests/_data_ignore/requirements.txt @@ -0,0 +1,12 @@ +asposestorage==1.0.2 +beautifulsoup4==4.11.1 +boto==2.49.0 +docopt==0.6.2 +Flask==1.1.2 +ipython==8.4.0 +nose==1.3.7 +peewee==3.15.1 +pyflakes==2.3.1 +requests==2.28.1 +SQLAlchemy==1.4.32 +ujson==5.1.0