Makefile i klasyfikatory

Tworzenie pakietów w Pythonie

James Fulton

Climate informatics researcher

Klasyfikatory

  • Metadane pakietu
  • Ułatwiają znalezienie pakietu w PyPI
  • Należy podać
    • Status pakietu
    • Docelowych odbiorców
    • Typ licencji
    • Język
    • Obsługiwane wersje Pythona
  • Więcej klasyfikatorów: https://pypi.org/classifiers

Wewnątrz setup.py pakietu mysklearn

setup(
    ...
    classifiers=[
        'Development Status :: 2 - Pre-Alpha',
        'Intended Audience :: Developers',
        'License :: OSI Approved :: MIT License',
        'Natural Language :: English',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.6',
        'Programming Language :: Python :: 3.7',
        'Programming Language :: Python :: 3.8',
    ],
    ...
)
Tworzenie pakietów w Pythonie

Do czego służą pliki Makefile?

  • Służą do automatyzacji części procesu budowania pakietu
mysklearn/
...
|-- README.md
|-- setup.py
|-- Makefile  <---
...
Tworzenie pakietów w Pythonie

Co zawiera plik Makefile?

Wewnątrz Makefile

...

dist: ## builds source and wheel package
    python3 setup.py sdist bdist_wheel

clean-build: ## remove build artifacts rm -fr build/ rm -fr dist/ rm -fr .eggs/
test: ## run tests quickly with the default Python pytest
release: dist ## package and upload a release twine upload dist/*
Tworzenie pakietów w Pythonie

Jak używać pliku Makefile?

make <function-name>
mysklearn/ <--- przejdź tutaj
...
|-- README.md
|-- setup.py
|-- Makefile  
...
Tworzenie pakietów w Pythonie

Jak używać pliku Makefile?

Aby użyć funkcji dist, wpisz w terminalu

make dist

Wewnątrz Makefile

...

dist: ## builds source and wheel package
    python3 setup.py sdist bdist_wheel

clean-build: ## remove build artifacts
    rm -fr build/
    rm -fr dist/
    rm -fr .eggs/

test: ## run tests quickly with the default Python
    pytest

release: dist ## package and upload a release
    twine upload dist/*
Tworzenie pakietów w Pythonie

Podsumowanie Makefile

make help
clean                remove all build, test, coverage and Python artifacts
clean-build          remove build artifacts
clean-pyc            remove Python file artifacts
clean-test           remove test and coverage artifacts
lint                 check style with flake8
test                 run tests quickly with the default Python
test-all             run tests on every Python version with tox
release              package and upload a release
dist                 builds source and wheel package
install              install the package to the active Python's site-packages
Tworzenie pakietów w Pythonie

Czas na ćwiczenia!

Tworzenie pakietów w Pythonie

Preparing Video For Download...