forked from foundit/Piped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
69 lines (57 loc) · 2.43 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Copyright (c) 2010-2011, Found IT A/S and Piped Project Contributors.
# See LICENSE for details.
import os
import sys
from setuptools import setup, find_packages
# When pip installs anything from packages, py_modules, or ext_modules that
# includes a twistd plugin (which are installed to twisted/plugins/),
# setuptools/distribute writes a Package.egg-info/top_level.txt that includes
# "twisted". If you later uninstall Package with `pip uninstall Package`,
# pip removes all of twisted/ instead of just Package's twistd plugins. See
# https://github.com/pypa/pip/issues/355
#
# To work around this problem, we monkeypatch
# setuptools.command.egg_info.write_toplevel_names to not write the line
# "twisted". This fixes the behavior of `pip uninstall Package`. Note that
# even with this workaround, `pip uninstall Package` still correctly uninstalls
# Package's twistd plugins from twisted/plugins/, since pip also uses
# Package.egg-info/installed-files.txt to determine what to uninstall,
# and the paths to the plugin files are indeed listed in installed-files.txt.
try:
from setuptools.command import egg_info
egg_info.write_toplevel_names
except (ImportError, AttributeError):
pass
else:
def _top_level_package(name):
return name.split('.', 1)[0]
def _hacked_write_toplevel_names(cmd, basename, filename):
pkgs = dict.fromkeys(
[_top_level_package(k)
for k in cmd.distribution.iter_distribution_names()
if _top_level_package(k) != 'piped'
]
)
cmd.write_file("top-level names", filename, '\n'.join(pkgs) + '\n')
egg_info.write_toplevel_names = _hacked_write_toplevel_names
here = os.path.abspath(os.path.dirname(__file__))
# add ourselves to the package path so we can get the version from the source tree
sys.path.insert(0, here)
import piped_validation
setup(
name = 'piped.contrib.validation',
license = 'MIT',
author = 'Piped Project Contributors',
author_email = 'piped@librelist.com',
url = 'http://piped.io',
packages = find_packages(where=here) + ['piped.plugins'],
version = str(piped_validation.version),
classifiers = [
'Development Status :: 4 - Beta',
'Environment :: Plugins',
'Framework :: Twisted',
'Operating System :: OS Independent',
],
description = 'FormEncode-like validation processor for Piped.',
install_requires = ['piped', 'formencode', 'setuptools']
)