Makefile e classifier

Sviluppare pacchetti Python

James Fulton

Climate informatics researcher

Classifier

  • Metadati per il tuo package
  • Aiutano gli utenti a trovarlo su PyPI
  • Dovresti includere
    • Stato del package
    • Pubblico di riferimento
    • Tipo di licenza
    • Lingua
    • Versioni di Python supportate
  • Esistono molti altri classifier https://pypi.org/classifiers

Dentro setup.py di 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',
    ],
    ...
)
Sviluppare pacchetti Python

A cosa servono i Makefile?

  • Usati per automatizzare parti della build del tuo package
mysklearn/
...
|-- README.md
|-- setup.py
|-- Makefile  <---
...
Sviluppare pacchetti Python

Cosa c'è in un Makefile?

Dentro 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/*
Sviluppare pacchetti Python

Come uso il Makefile?

make <function-name>
mysklearn/ <--- vai qui
...
|-- README.md
|-- setup.py
|-- Makefile  
...
Sviluppare pacchetti Python

Come uso il Makefile?

Per usare la funzione dist, digita nel terminale

make dist

Dentro 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/*
Sviluppare pacchetti Python

Riepilogo 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
Sviluppare pacchetti Python

Esercitiamoci!

Sviluppare pacchetti Python

Preparing Video For Download...