My friend just started learning Python and Flask, and is missing a lot of "best practices", e.g., a requirements.txt file.
He has recently asked me for assistance, and to make the project clean, I want to setup a CI service (Travis), but I need to work out this file first.
Since he did not initially have a requirements.txt, all information I can have is his import statements, as well as his output of pip freeze.
As there's no way to distinguish a direct requirement by the project and an indirect requirement by one of the packages, I want to find out all "top-level" packages from the list. A "top-level package" is a package that's not required by another package in the list. For example, urllib3 is required by requests, so when requests is present, urllib3 may better not appear in the final result.
Is there a way to achieve this?
If anyone wants to help me with this specific instance, here's the output of pip freeze:
apturl==0.5.2 arrow==0.12.1 asn1crypto==0.24.0 binaryornot==0.4.4 blinker==1.4 Bootstrap-Flask==1.0.9 Brlapi==0.6.6 certifi==2018.1.18 chardet==3.0.4 Click==7.0 colorama==0.3.7 command-not-found==0.3 configparser==3.5.0 cookiecutter==1.6.0 cryptography==2.1.4 cupshelpers==1.0 decorator==4.1.2 defer==1.0.6 distro-info==0.18 dominate==2.3.5 Flask==1.0.2 Flask-Bootstrap4==4.0.2 Flask-Login==0.4.1 Flask-Mail==0.9.1 Flask-Moment==0.6.0 Flask-SQLAlchemy==2.3.2 Flask-WTF==0.14.2 future==0.17.1 httpie==0.9.8 httplib2==0.9.2 idna==2.6 ipython==5.5.0 ipython-genutils==0.2.0 itsdangerous==1.1.0 Jinja2==2.10 jinja2-time==0.2.0 keyring==10.6.0 keyrings.alt==3.0 language-selector==0.1 launchpadlib==1.10.6 lazr.restfulclient==0.13.5 lazr.uri==1.0.3 louis==3.5.0 macaroonbakery==1.1.3 Mako==1.0.7 MarkupSafe==1.1.0 mysqlclient==1.3.14 netifaces==0.10.4 oauth==1.0.1 olefile==0.45.1 pexpect==4.2.1 pickleshare==0.7.4 Pillow==5.1.0 poyo==0.4.2 prompt-toolkit==1.0.15 protobuf==3.0.0 pycairo==1.16.2 pycrypto==2.6.1 pycups==1.9.73 Pygments==2.2.0 pygobject==3.26.1 pymacaroons==0.13.0 PyNaCl==1.1.2 pyRFC3339==1.0 python-apt==1.6.3 python-dateutil==2.7.5 python-debian==0.1.32 pytz==2018.3 pyxdg==0.25 PyYAML==3.12 reportlab==3.4.0 requests==2.18.4 requests-unixsocket==0.1.5 ruamel.yaml==0.15.34 SecretStorage==2.3.1 simplegeneric==0.8.1 simplejson==3.13.2 six==1.11.0 SQLAlchemy==1.2.14 system-service==0.3 systemd-python==234 traitlets==4.3.2 ubuntu-drivers-common==0.0.0 ufw==0.35 unattended-upgrades==0.1 urllib3==1.22 usb-creator==0.3.3 visitor==0.1.3 wadllib==1.3.2 wcwidth==0.1.7 Werkzeug==0.14.1 whichcraft==0.5.2 WTForms==2.2.1 xkit==0.0.0 zope.interface==4.3.2 and here are the import statements, with an additional pymysql he told me.
import os from flask import * from flask_bootstrap import Bootstrap from flask_moment import Moment from flask_wtf import FlaskForm from wtforms import * from wtforms.validators import * from flask_sqlalchemy import SQLAlchemy from flask_mail import Mail, Message from werkzeug.security import generate_password_hash,check_password_hash from flask_login import login_required , login_user,login_fresh,login_url,LoginManager,UserMixin,logout_user
pip→ check if everything works → usepip freezepip freezeinrequirements.txtisn't a good idea. Therefore, I want a minimum and maintainable list.requirements.txtfile for any project based on imports.