Chapter 2
Chapter 2
package
D E V E L O P I N G P Y T H O N PA C K A G E S
James Fulton
Climate informatics researcher
Why should you install your own package?
Inside example_script.py Directory tree for package with subpackages
mysklearn/
|-- __init__.py
|-- preprocessing
| |-- __init__.py
| |-- normalize.py
| |-- standardize.py
|-- regression
| |-- __init__.py
| |-- regression.py
|-- utils.py
James Fulton
Climate informatics researcher
What are dependencies?
Other packages you import inside your package
Inside mymodule.py :
setup(
...
install_requires=['pandas', 'scipy', 'matplotlib'],
)
setup(
...
install_requires=[
'pandas>=1.0',
'scipy==1.1',
'matplotlib>=2.2.1,<3'
],
)
setup(
...
install_requires=[
'pandas>=1.0', # good
'scipy==1.1', # bad
'matplotlib>=2.2.1,<3' # good
],
)
setup(
...
python_requires='>=2.7, !=3.0.*, !=3.1.*',
)
alabaster==0.7.12
appdirs==1.4.4
argh==0.26.2
...
wrapt==1.11.2
yapf==0.29.0
zipp==3.1.0
James Fulton
Climate informatics researcher
Why do I need a license?
To give others permission to use your code
1 https://choosealicense.com
Title
Usage examples
Contributing
License
Used in this course and in the wild Also common in the wild
# mysklearn mysklearn
mysklearn is a package for complete
mysklearn is a package for complete linear
**linear regression** in Python.
regression in python.
You can find out more about this package
on [DataCamp](https://datacamp.com) You can find out more about this package on
DataCamp
# mysklearn mysklearn
mysklearn is a package for complete
mysklearn is a package for complete linear
**linear regression** in Python.
regression in python.
You can find out more about this package
on [DataCamp](https://datacamp.com) You can find out more about this package on
DataCamp
## Installation
You can install this package using
Installation
You can install this package using
# mysklearn mysklearn
mysklearn is a package for complete
mysklearn is a package for complete linear
**linear regression** in Python.
regression in python.
You can find out more about this package
on [DataCamp](https://datacamp.com) You can find out more about this package on
DataCamp
## Installation
You can install this package using
Installation
``` You can install this package using
pip install mysklearn
``` pip install mysklearn
mysklearn/
|-- mysklearn
| |-- __init__.py
| |-- preprocessing
| | |-- ...
| |-- regression
| | |-- ...
| |-- utils.py
|-- setup.py
|-- requirements.txt
|-- LICENSE <--- new files
|-- README.md <--- added to top directory
James Fulton
Climate informatics researcher
PyPI
Python Package Index
1 https://pypi.org/
Wheel distribution - a distribution package which has been processed to make it faster to
install.