daveops.com/pycon2017
dave@forgac.com
@tylerdave
def beautiful_code(): """This code is so beautiful.""" print('Hello, PyCon!')
“I want to share my code!
What do I need to do?”
Code
Package
Documentation
Source Hosting
Tests
CI
License
Contributing
“But I just wanted to share my code!”
and of course there are multiple types of wheels too
a universal wheel is one that contains only python code and is compatible with python 2 and 3
and of course there are multiple types of wheels too
a universal wheel is one that contains only python code and is compatible with python 2 and 3
a pure python wheel is specific to either 2 or 3 but is still only python code
and of course there are multiple types of wheels too
a universal wheel is one that contains only python code and is compatible with python 2 and 3
a pure python wheel is specific to either 2 or 3 but is still only python code
a platform wheel has compiled code so it's specific to a target platform
if you searched online you'd find lots of conflicting information about how to do things
so the way i'd go about packaging was: i'd find a project that seemed to have it together and make a copy
if you searched online you'd find lots of conflicting information about how to do things
so the way i'd go about packaging was: i'd find a project that seemed to have it together and make a copy
and then replace their code with mine and then change the project name in the files
then in 2011 the packaging authority working group was created to take over maintenance of core packaging tools
https://packaging.python.org/
if you searched online you'd find lots of conflicting information about how to do things
so the way i'd go about packaging was: i'd find a project that seemed to have it together and make a copy
and then replace their code with mine and then change the project name in the files
then in 2011 the packaging authority working group was created to take over maintenance of core packaging tools
and they've since worked to make some great improvements to the packaging ecosystem
besides the specification and tooling improvements, another major contribution of the working group is maintenance of the python packaging user guide
“Let's make a package!”
$ cookiecutter cookiecutter-python-package…full_name (default is "Dave Forgac")?email (default is "tylerdave@tylerdave.com")?github_username (default is "tylerdave")?project_name (default is "Example")? Example Packagerepo_name (default is "boilerplate")? Example-Packageproject_short_description (default is "A short description")? Example package for PyCon talk.release_date (default is "2017-05-21")?year (default is "2017")?version (default is "0.1.0")?
.├── data│ └── data_file├── DESCRIPTION.rst├── MANIFEST.in├── README.rst├── sample│ ├── __init__.py│ └── package_data.dat├── setup.cfg├── setup.py└── tests ├── __init__.py └── test_sample.py
.├── data│ └── data_file├── DESCRIPTION.rst├── MANIFEST.in├── README.rst├── sample│ ├── __init__.py│ └── package_data.dat├── setup.cfg├── setup.py└── tests ├── __init__.py └── test_sample.py
.├── data│ └── data_file├── DESCRIPTION.rst├── MANIFEST.in├── README.rst├── sample│ ├── __init__.py│ └── package_data.dat├── setup.cfg├── setup.py└── tests ├── __init__.py └── test_sample.py
.├── data│ └── data_file├── DESCRIPTION.rst├── MANIFEST.in├── README.rst├── sample│ ├── __init__.py│ └── package_data.dat├── setup.cfg├── setup.py└── tests ├── __init__.py └── test_sample.py
.├── data│ └── data_file├── DESCRIPTION.rst├── MANIFEST.in├── README.rst├── sample│ ├── __init__.py│ └── package_data.dat├── setup.cfg├── setup.py└── tests ├── __init__.py └── test_sample.py
.├── data│ └── data_file├── DESCRIPTION.rst├── MANIFEST.in├── README.rst├── sample│ ├── __init__.py│ └── package_data.dat├── setup.cfg├── setup.py└── tests ├── __init__.py └── test_sample.py
from setuptools import setup, find_packages setup( name='Example Package', version='0.1.0', # PEP440-compliant version description='Example package for PyCon talk.', long_description='Displayed on PyPI project page.', url='https://github.com/tylerdave/Example-Package', author='Dave Forgac', author_email='tylerdave@tylerdave.com', packages=find_packages(exclude=['docs', 'tests']) install_requires=['requests'], package_data={ 'sample': ['package_data.dat'] } …
from setuptools import setup, find_packages setup( name='Example Package', version='0.1.0', # PEP440-compliant version description='Example package for PyCon talk.', long_description='Displayed on PyPI project page.', url='https://github.com/tylerdave/Example-Package', author='Dave Forgac', author_email='tylerdave@tylerdave.com', packages=find_packages(exclude=['docs', 'tests']) install_requires=['requests'], package_data={ 'sample': ['package_data.dat'] } …
from setuptools import setup, find_packages setup( name='Example Package', version='0.1.0', # PEP440-compliant version description='Example package for PyCon talk.', long_description='Displayed on PyPI project page.', url='https://github.com/tylerdave/Example-Package', author='Dave Forgac', author_email='tylerdave@tylerdave.com', packages=find_packages(exclude=['docs', 'tests']) install_requires=['requests'], package_data={ 'sample': ['package_data.dat'] } …
from setuptools import setup, find_packages setup( name='Example Package', version='0.1.0', # PEP440-compliant version description='Example package for PyCon talk.', long_description='Displayed on PyPI project page.', url='https://github.com/tylerdave/Example-Package', author='Dave Forgac', author_email='tylerdave@tylerdave.com', packages=find_packages(exclude=['docs', 'tests']) install_requires=['requests'], package_data={ 'sample': ['package_data.dat'] } …
from setuptools import setup, find_packages setup( name='Example Package', version='0.1.0', # PEP440-compliant version description='Example package for PyCon talk.', long_description='Displayed on PyPI project page.', url='https://github.com/tylerdave/Example-Package', author='Dave Forgac', author_email='tylerdave@tylerdave.com', packages=find_packages(exclude=['docs', 'tests']) install_requires=['requests'], package_data={ 'sample': ['package_data.dat'] } …
… entry_points={ 'console_scripts': [ 'hello=example_package.cli:say_hello', ], } license='MIT', classifiers=[ 'Development Status :: 3 - Alpha', 'License :: OSI Approved :: MIT License', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', ])
… entry_points={ 'console_scripts': [ 'hello=example_package.cli:say_hello', ], } license='MIT', classifiers=[ 'Development Status :: 3 - Alpha', 'License :: OSI Approved :: MIT License', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', ])
… entry_points={ 'console_scripts': [ 'hello=example_package.cli:say_hello', ], } license='MIT', classifiers=[ 'Development Status :: 3 - Alpha', 'License :: OSI Approved :: MIT License', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', ])
data_files can specify data outside of your path
scripts can specify an individual script
[bdist_wheel]universal = 1 [flake8]exclude = docs
include LICENSEinclude README.rst recursive-include tests *recursive-exclude * __pycache__recursive-exclude * *.py[co]
===============================Example Package=============================== License: MIT Documentation: https://example.com Usage----- ``sample --help``
./tests
tox.ini
./docs
.travis.yml
HISTORY
or CHANGES
or CHANGELOG
CONTRIBUTING
AUTHORS
“Now let's share our code!”
cd Example-Packagegit initgit add .git commit -m 'initial commit'
tox…OK___________________________ summary __________________________ py27: commands succeeded py34: commands succeeded py35: commands succeeded py36: commands succeeded
git add .git commit -m "add hello pycon functionality"
To git@github.com:tylerdave/Example-Package.git * [new branch] master -> masterBranch master set up to track remote branch masterfrom origin.
https://pypi.python.org/
https://pypi.python.org/
https://testpypi.python.org/
$HOME/.pypirc
[distutils]index-servers=pypi[pypi]repository = https://pypi.python.org/pypiusername = <username>password = <password>
pip install wheel
pip install twine
./setup.py sdist
./setup.py bdist_wheel
or
make dist
twine upload dist/*
pip install example-package
./setup.py develop
or
pip install -e .
daveops.com/pycon2017
dave@forgac.com
@tylerdave
def beautiful_code(): """This code is so beautiful.""" print('Hello, PyCon!')
Keyboard shortcuts
↑, ←, Pg Up, k | Go to previous slide |
↓, →, Pg Dn, Space, j | Go to next slide |
Home | Go to first slide |
End | Go to last slide |
Number + Return | Go to specific slide |
b / m / f | Toggle blackout / mirrored / fullscreen mode |
c | Clone slideshow |
p | Toggle presenter mode |
t | Restart the presentation timer |
?, h | Toggle this help |
Esc | Back to slideshow |