Daniel Moser
Feb 15th, 2017
2nd IAG Python Boot Camp
Table of contents
Python is a FREE language where simplicity matters. Thus, it should be easy to have (ie., download) published codes and also, publish your own code.
Standardizing the names:
This talk is complemented by this one: from otherswork import wheel: looking for useful Python packages.
import this
Answer: if you satisfy one of these 3 conditions:
Never run python from a package folder!
Answer: one of two ways:
"pip is a package management system used to install and manage software packages written in Python."
pip install _package_ # --user : local install (no admin rights) # -U or --upgrade : upgrade existing installation # --no-deps : no install of dependencies packages (useful for upgrade) # --install-option="--prefix=$PREFIX_PATH" redirects the install
pip in embedded in 2.7.9+. If you have an updated version of Python and don't find it, run this command:
python -m ensurepip
Remember: pip installs binaries in addition to the modules. Add this installation path to your $PATH (in unix, is is $HOME/.local/bin).
WARNING: Never combine sudo with --user! Otherwise you will face critical permission problems for your packages!
Many more from pip can be learned!
Answer: In the Python Package Index: PyPi!!!
"The Python Package Index (aka ``PyPI`` -- formerly known as the "Cheese Shop") is the preferred hub for publishing Python packages and modules. Python's standard library supports code uploads to PyPI through its ``distutils`` module."
Answer: do this check list:
This check list is not to discourage you. It's to encourage you to do these things, because in the long run they really are worth it (believe me!)
That's a very good question!
Look the iagpyboot module example! (It should be at https://github.com/IIPBC/Material ...)
Here you have a MWE (minimal working example):
#!/usr/bin/env python # -*- coding:utf-8 -*- """ Writing the Setup Script https://docs.python.org/2/distutils/setupscript.html """ from setuptools import setup # , find_packages # from distutils.core import setup setup(name='iagpyboot', version='0.2', description='IAG Python Boot Camp example', author='Daniel Moser', author_email='moser@usp.br', url='http://iagpyboot.wixsite.com/pbc2017', packages=['iagpyboot'], )
Answer: Read Test PyPi Server!
[distutils] index-servers= pypi testpypi [testpypi] repository = https://testpypi.python.org/pypi username = iagpyboot password = IAGpbc2017 [pypi] repository = https://pypi.python.org/pypi username = <your user name goes here> password = <your password goes here>
python setup.py register -r https://testpypi.python.org/pypi
python setup.py sdist upload -r https://testpypi.python.org/pypi
Answer: Once your project is on the server, test that you can install your package from TestPyPi:
pip install -i https://testpypi.python.org/pypi <package name>
Good luck publishing your code!