22
loading...
This website collects cookies to deliver better user experience
pip install opencv-python
, a few seconds passed and something magical happened- I was able to use OpenCV; no need to build it from source, no compiler needed, it was definitely breathtaking. I could install any package I wanted and not worry about building it source/ installing or configuring the system variable.You add a setup.py to your module (with relevant configuration of course).
But what if you want python package available to everyone across the globe?
You publish your package on PyPI. (so everyone can pip install your-package-name)
# hello.py
def heythere():
print("hey there")
# setup.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages
setup(
author="Chinmay Shah",
author_email='[email protected]',
classifiers=[
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.7',
],
description="Says hello",
license="MIT license",
include_package_data=True,
name='hello',
version='0.1.0',
zip_safe=False,
)
Setup.py
is what pip
looks for in a given directory. It uses something called setuptools[1] which enables packaging. It contains the name of your package, a brief description of your package, along with author information. And don't fail to mention which python version it's made for. All of this metadata is important..whl
) file; which is an accepted file for package distribution.pkgs
folder.pip
?easyinstall
, even though both are built on top of setuptools. [1]