Skip to content

Instantly share code, notes, and snippets.

View ionelmc's full-sized avatar
🙃
wat

Ionel Cristian Mărieș ionelmc

🙃
wat
View GitHub Profile
<html>
<body>
<a href="git+https://github.com/dstufft/packaging.git#egg=packaging-1.0">Thing</a>
</body>
</html>

Forgetting to specify package data.

why

Your package distribution doesn't include static files.

fix

Create a MANIFEST.in.

Listing few file types in MANIFEST.in, then adding some webfonts - only to find out the release you published on PyPI doesn't include them.

why

You duplicated information you already have in the filesystem.

fix

Just recursive-include or graft the whole dir.

20:57 <ionelmc> for #1: brittle parsing, could start failing if someone starts adding stuff without knowing what's in setup.py
20:58 <ionelmc> for #2: pretty robust, assuming you're always using a separate version.py file
20:58 <qwcode> Ivo might have an opinion on a winner
20:59 <Ivo> what what
20:59 <Ivo> oh god, yeah
20:59 <Ivo> there should be one way to do thihngs
20:59 <Ivo> not 7
20:59 <qwcode> regarding the version section in the PUG offering too many solutions, but no winner
20:59 <ionelmc> for #3: regex could fail later, eg: someone changes from single to double quotes or thinks it's a great idea to create the string with % or .format()
20:59 <Ivo> or 6
@ionelmc
ionelmc / .bashrc
Created June 10, 2014 14:46
SCL python alias (SCL it's a RHEL/CentOS thing).
sclpython() {
if [ "$#" = 0 ]; then
scl enable python27 python
else
echo $(
echo python
for i in "$@"; do
printf "%q\n" "$i"
done
) | scl enable python27 -
@ionelmc
ionelmc / .travis.tmpl.yml
Last active December 13, 2015 15:46
This might be outdated. Updated samples here: https://github.com/ionelmc/python-nameless/tree/generative
language: python
python: '3.5'
sudo: false
env:
global:
LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so
matrix:
- TOXENV=check
{% for env, config in tox_environments|dictsort %}
- TOXENV={{ env }}{% if config.cover %},extension-coveralls,coveralls,codecov{% endif %}
[matrix]
python_versions =
2.6
2.7
3.3
3.4
pypy
# syntax:
# alias: dep1 dep2 dep3 !skip_var[glob] &include_var[glob]
@ionelmc
ionelmc / pypi-link
Last active August 29, 2015 14:00
Creates an "alias package".
from tornado import ioloop
from tornado import web
from tornado import gen
from tornado.httpclient import AsyncHTTPClient
from functools import wraps
from inspect import isgeneratorfunction
def error_handling(func):
if isgeneratorfunction(func):
@wraps(func)
from time import sleep
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from tornado.web import Application, asynchronous, RequestHandler
from multiprocessing.pool import ThreadPool
_workers = ThreadPool(10)
def run_background(func, callback, args=(), kwds={}):
def _callback(result):
from functools import partial
class MockTask(object):
def __init__(self, func):
self.func = func
def delay(self, *args, **kwargs):
return MockResult(partial(self.func, *args, **kwargs))
class MockTask(object):
def __init__(self, func):