Dein Paket portabel machen

Grundlagen der Softwareentwicklung in Python

Adam Spannbauer

Machine Learning Engineer at Eastman

Schritte zur Portabilität

setup.py Datei

requirements.txt Datei

Grundlagen der Softwareentwicklung in Python

Portierbare Paketstruktur

Paketstruktur

Grundlagen der Softwareentwicklung in Python

Inhalt von requirements.txt

arbeiten in work_dir/requirements.txt

# Benötigte Pakete/Versionen
matplotlib
numpy==1.15.4
pycodestyle>=2.4.0

arbeiten mit terminal

datacamp@server:~$ pip install -r requirements.txt
Grundlagen der Softwareentwicklung in Python

Inhalt von setup.py

from setuptools import setup

setup(name='my_package',
      version='0.0.1',
      description='Ein Beispielpaket für DataCamp.',
      author='Adam Spannbauer',
      author_email='[email protected]',
      packages=['my_package'],
      install_requires=['matplotlib',
                        'numpy==1.15.4',
                        'pycodestyle>=2.4.0'])
Grundlagen der Softwareentwicklung in Python

install_requires vs requirements.txt

arbeiten in work_dir/requirements.txt

# Quelle für die Installation angeben
--index-url https://pypi.python.org/simple/

# Benötigte Pakete/Versionen
matplotlib
numpy==1.15.4
pycodestyle>=2.4.0

Dokumentation: install_requires vs requirements files

Grundlagen der Softwareentwicklung in Python

Paket mit pip installieren

datacamp@server:~/work_dir $ pip install .
Building wheels for collected packages: my-package
  Running setup.py bdist_wheel for my-package ... done
Successfully built my-package
Installing collected packages: my-package
Successfully installed my-package-0.0.1
Grundlagen der Softwareentwicklung in Python

Lass uns üben!

Grundlagen der Softwareentwicklung in Python

Preparing Video For Download...