Intent
Beyond importing someone else's packages, sometimes it helps to make your own. This will assist in the understanding of how to do so.
I. It helps to have the pep8 compliance package to test.
py -3 -m pip
install pytest
py -3 -m pip
install pytest-pep8
Next step, make sure your module is pip complaint
- cd to your module and run…
- py.test --pep8 vsearch.py
Common Errors Found
- Not having two blank lines between each function
- Not having a white space following a colon
- Using tabs to indent. It prefers 4 blank manual lines
Note the ^ will mark
where in the code it believes things are out of compliance.
Creating setup.py
Textbook example:
from
setuptools import setup
setup(name='vsearch',
version='1.01', description='The Head First Python Search Tools', author='HF
Python 2e', author_email='hfpy2e@gmail.com', url='headfirstlabs.com',
py_modules=['vsearch'],)
Creating README.txt
Just put in whatever
you want. So long as the README exists.
In the command line run as follows:
py -3 setup.py sdist
IV. Install your new module from within it's distribution
Example:
py -3 -m pip install [moduleName]-1.0.zip
V. Now you can run your module. Don't forget to run it as something, or you'll have to call it by what it is. Have fun! :)
No comments:
Post a Comment