Skip to content

Commit 1211db3

Browse files
committed
Add "setup.py" file.
1 parent fd87c70 commit 1211db3

File tree

3 files changed

+103
-1
lines changed

3 files changed

+103
-1
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ repos:
33
rev: 3.7.8
44
hooks:
55
- id: flake8
6-
exclude: examples
6+
exclude: examples|setup\.py
77
- repo: https://github.com/pre-commit/mirrors-yapf
88
rev: v0.23.0
99
hooks:
1010
- id: yapf
11+
exclude: setup\.py

setup.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# -*- coding: utf-8 -*-
2+
import codecs
3+
from setuptools import setup
4+
5+
packages = \
6+
['colour_checker_detection',
7+
'colour_checker_detection.detection',
8+
'colour_checker_detection.detection.tests']
9+
10+
package_data = \
11+
{'': ['*'],
12+
'colour_checker_detection': ['examples/*',
13+
'resources/colour-checker-detection-examples-datasets/*',
14+
'resources/colour-checker-detection-tests-datasets/*']}
15+
16+
install_requires = \
17+
['colour-science>=0.3.14,<0.4.0', 'opencv-python>=4,<5']
18+
19+
extras_require = \
20+
{'development': ['biblib-simple',
21+
'coverage',
22+
'coveralls',
23+
'flake8',
24+
'invoke',
25+
'jupyter',
26+
'matplotlib',
27+
'mock',
28+
'nose',
29+
'pre-commit',
30+
'pytest',
31+
'restructuredtext-lint',
32+
'sphinx',
33+
'sphinx_rtd_theme',
34+
'sphinxcontrib-bibtex',
35+
'toml',
36+
'twine',
37+
'yapf==0.23'],
38+
'read-the-docs': ['mock', 'numpy', 'sphinxcontrib-bibtex']}
39+
40+
setup(
41+
name='colour-checker-detection',
42+
version='0.1.1',
43+
description='Colour checker detection with Python',
44+
long_description=codecs.open('README.rst', encoding='utf8').read(),
45+
author='Colour Developers',
46+
author_email='colour-developers@colour-science.org',
47+
maintainer='Colour Developers',
48+
maintainer_email='colour-developers@colour-science.org',
49+
url='https://www.colour-science.org/',
50+
packages=packages,
51+
package_data=package_data,
52+
install_requires=install_requires,
53+
extras_require=extras_require,
54+
python_requires='>=3.5,<4.0',
55+
)
56+

tasks.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,51 @@ def build(ctx):
329329

330330
message_box('Building...')
331331
ctx.run('poetry build')
332+
333+
with ctx.cd('dist'):
334+
ctx.run('tar -xvf {0}-{1}.tar.gz'.format(PYPI_PACKAGE_NAME,
335+
APPLICATION_VERSION))
336+
ctx.run('cp {0}-{1}/setup.py ../'.format(PYPI_PACKAGE_NAME,
337+
APPLICATION_VERSION))
338+
339+
ctx.run('rm -rf {0}-{1}'.format(PYPI_PACKAGE_NAME,
340+
APPLICATION_VERSION))
341+
342+
with open('setup.py') as setup_file:
343+
source = setup_file.read()
344+
345+
setup_kwargs = []
346+
347+
def sub_callable(match):
348+
setup_kwargs.append(match)
349+
350+
return ''
351+
352+
template = """
353+
setup({0}
354+
)
355+
"""
356+
357+
source = re.sub('from setuptools import setup',
358+
'import codecs\nfrom setuptools import setup', source)
359+
source = re.sub(
360+
'setup_kwargs = {(.*)}.*setup\\(\\*\\*setup_kwargs\\)',
361+
sub_callable,
362+
source,
363+
flags=re.DOTALL)[:-2]
364+
setup_kwargs = setup_kwargs[0].group(1).splitlines()
365+
for i, line in enumerate(setup_kwargs):
366+
setup_kwargs[i] = re.sub('^\\s*(\'(\\w+)\':\\s?)', ' \\2=', line)
367+
if setup_kwargs[i].strip().startswith('long_description'):
368+
setup_kwargs[i] = (' long_description='
369+
'codecs.open(\'README.rst\', encoding=\'utf8\')'
370+
'.read(),')
371+
372+
source += template.format('\n'.join(setup_kwargs))
373+
374+
with open('setup.py', 'w') as setup_file:
375+
setup_file.write(source)
376+
332377
ctx.run('twine check dist/*')
333378

334379

0 commit comments

Comments
 (0)