Developing Python Packages
James Fulton
Climate informatics researcher
mymodule.py
:# These imported packages are dependencies
import numpy as np
import pandas as pd
...
from setuptools import setup, find_packages
setup(
...
install_requires=['pandas', 'scipy', 'matplotlib'],
)
from setuptools import setup, find_packages setup( ... install_requires=[
'pandas>=1.0',
'scipy==1.1',
'matplotlib>=2.2.1,<3'
], )
from setuptools import setup, find_packages setup( ... install_requires=[
'pandas>=1.0', # good 'scipy==1.1', # bad 'matplotlib>=2.2.1,<3' # good ], )
from setuptools import setup, find_packages
setup(
...
python_requires='>=2.7, !=3.0.*, !=3.1.*',
)
pip freeze
alabaster==0.7.12
appdirs==1.4.4
argh==0.26.2
...
wrapt==1.11.2
yapf==0.29.0
zipp==3.1.0
Save package requirements to a file
pip freeze > requirements.txt
Install requirements from file
pip install -r requirements.txt
mysklearn/
|-- mysklearn
| |-- __init__.py
| |-- preprocessing
| | |-- __init__.py
| | |-- normalize.py
| | |-- standardize.py
| |-- regression
| | |-- __init__.py
| | |-- regression.py
| |-- utils.py
|-- setup.py
|-- requirements.txt <-- developer environment
Developing Python Packages