Skip to content

Commit

Permalink
black: setup
Browse files Browse the repository at this point in the history
  • Loading branch information
ultrabug committed Sep 28, 2018
1 parent 1dca8a0 commit 1bddc3d
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 48 deletions.
43 changes: 23 additions & 20 deletions fastentrypoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
'''
"""
Monkey patch setuptools to write faster console_scripts with this format:
import sys
Expand All @@ -35,10 +35,11 @@
(c) 2016, Aaron Christianson
http://github.com/ninjaaron/fast-entry_points
'''
"""
from setuptools.command import easy_install
import re
TEMPLATE = '''\

TEMPLATE = """\
# -*- coding: utf-8 -*-
# EASY-INSTALL-ENTRY-SCRIPT: '{3}','{4}','{5}'
__requires__ = '{3}'
Expand All @@ -49,7 +50,7 @@
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit({2}())'''
sys.exit({2}())"""


@classmethod
Expand All @@ -62,15 +63,15 @@ def get_args(cls, dist, header=None): # noqa: D205,D400
# pylint: disable=E1101
header = cls.get_header()
spec = str(dist.as_requirement())
for type_ in 'console', 'gui':
group = type_ + '_scripts'
for type_ in "console", "gui":
group = type_ + "_scripts"
for name, ep in dist.get_entry_map(group).items():
# ensure_safe_name
if re.search(r'[\\/]', name):
if re.search(r"[\\/]", name):
raise ValueError("Path separators not allowed in script names")
script_text = TEMPLATE.format(
ep.module_name, ep.attrs[0], '.'.join(ep.attrs),
spec, group, name)
ep.module_name, ep.attrs[0], ".".join(ep.attrs), spec, group, name
)
# pylint: disable=E1101
args = cls._get_script_args(type_, name, header, script_text)
for res in args:
Expand All @@ -86,27 +87,29 @@ def main():
import re
import shutil
import sys
dests = sys.argv[1:] or ['.']
filename = re.sub('\.pyc$', '.py', __file__)

dests = sys.argv[1:] or ["."]
filename = re.sub("\.pyc$", ".py", __file__)

for dst in dests:
shutil.copy(filename, dst)
manifest_path = os.path.join(dst, 'MANIFEST.in')
setup_path = os.path.join(dst, 'setup.py')
manifest_path = os.path.join(dst, "MANIFEST.in")
setup_path = os.path.join(dst, "setup.py")

# Insert the include statement to MANIFEST.in if not present
with open(manifest_path, 'a+') as manifest:
with open(manifest_path, "a+") as manifest:
manifest.seek(0)
manifest_content = manifest.read()
if 'include fastentrypoints.py' not in manifest_content:
manifest.write(('\n' if manifest_content else '') +
'include fastentrypoints.py')
if "include fastentrypoints.py" not in manifest_content:
manifest.write(
("\n" if manifest_content else "") + "include fastentrypoints.py"
)

# Insert the import statement to setup.py if not present
with open(setup_path, 'a+') as setup:
with open(setup_path, "a+") as setup:
setup.seek(0)
setup_content = setup.read()
if 'import fastentrypoints' not in setup_content:
if "import fastentrypoints" not in setup_content:
setup.seek(0)
setup.truncate()
setup.write('import fastentrypoints\n' + setup_content)
setup.write("import fastentrypoints\n" + setup_content)
57 changes: 29 additions & 28 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import os
import sys

module_path = os.path.join(
os.path.dirname(os.path.realpath(__file__)), 'py3status')
module_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "py3status")
sys.path.insert(0, module_path)
from version import version # noqa e402

sys.path.remove(module_path)


Expand All @@ -23,37 +23,38 @@ def read(fname):


setup(
name='py3status',
name="py3status",
version=version,
author='Ultrabug',
author_email='[email protected]',
description='py3status: an extensible i3status wrapper written in python',
long_description=read('README.rst'),
extras_require={'gevent': ['gevent >= 1.1']},
url='https://github.com/ultrabug/py3status',
download_url='https://github.com/ultrabug/py3status/tags',
license='BSD',
platforms='any',
author="Ultrabug",
author_email="[email protected]",
description="py3status: an extensible i3status wrapper written in python",
long_description=read("README.rst"),
extras_require={"gevent": ["gevent >= 1.1"]},
url="https://github.com/ultrabug/py3status",
download_url="https://github.com/ultrabug/py3status/tags",
license="BSD",
platforms="any",
packages=find_packages(),
include_package_data=True,
install_requires=[],
entry_points={
'console_scripts': [
'py3status = py3status:main',
'py3-cmd = py3status.command:send_command',
"console_scripts": [
"py3status = py3status:main",
"py3-cmd = py3status.command:send_command",
]
},
classifiers=[
'License :: OSI Approved :: BSD License',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Software Development :: Libraries :: Python Modules',
], )
"License :: OSI Approved :: BSD License",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Topic :: Software Development :: Libraries :: Python Modules",
],
)

0 comments on commit 1bddc3d

Please sign in to comment.