Skip to content

Commit

Permalink
Setup script as proper python package
Browse files Browse the repository at this point in the history
  • Loading branch information
MawKKe committed Sep 2, 2021
1 parent 1710560 commit 373a927
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 3 deletions.
13 changes: 10 additions & 3 deletions copy_tree_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def argument_regex(option, regex=PATT):
return l[0], {"codec": l[1], "ext": l[2], "bitrate": l[3]}


def main(argv):
def parse_args(argv):
p = argparse.ArgumentParser(description="Copy directory structure and files, " +
"possibly filtering and/or mapping (converting) from one format to another")

Expand All @@ -124,7 +124,11 @@ def main(argv):
help="max_workers value (defaults to your cpu count)", type=int)

#args = p.parse_args(argv[1:])
args = p.parse_args()
args = p.parse_args(argv[1:])

return args

def _main(args):

#print(args)
#return 0
Expand Down Expand Up @@ -161,6 +165,9 @@ def main(argv):

return 0

def main():
sys.exit(_main(parse_args(sys.argv)))

if __name__ == "__main__":
sys.exit(main(sys.argv))
main()

7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[build-system]
requires = [
"setuptools>=42",
"wheel",
]

build-backend = "setuptools.build_meta"
6 changes: 6 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[pytest]
flake8-ignore =
E251 # unexpected spaces around keyword
E221 # multiple spaces before operator
F401 # unused imports
flake8-max-line-length = 100
3 changes: 3 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pytest==6.2.5
pytest-cov==2.12.1
pytest-flake8==1.0.7
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[metadata]
license_files = LICENSE
44 changes: 44 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from setuptools import setup, find_packages
import pkg_resources
import pathlib

here = pathlib.Path(__file__).parent.resolve()

long_description = (here / 'README.md').read_text(encoding='utf-8')

requirements = []

extras_require = {
'dev': [
'pytest',
'pytest-cov',
'pytest-flake8'
]
}

if __name__ == "__main__":
setup(
name="copy-tree-map",
version='0.1.0',
description='Clone a directory tree while possibly filtering and/or transforming files',
long_description=long_description,
long_description_content_type='text/markdown',
url='https://github.com/MawKKe/copy-tree-map',
author='Markus H (MawKKe)',
author_email='[email protected]',
license='Apache 2.0',
package_date={'': ['LICENSE']},
py_modules=["copy_tree_map"],
entry_points={
'console_scripts': {
'copy-tree-map=copy_tree_map:main'
}
},
python_requires='>=3.5, <4',
install_requires=requirements,
extras_require=extras_require,
project_urls={
'Bug reports': 'https://github.com/MawKKe/copy-tree-map/issues',
'Source': 'https://github.com/MawKKe/copy-tree-map'
},
)
18 changes: 18 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[tox]
# NOTE: old py36, py39 etc don't seem to work with newer tox (> 3.24.0 ?)
envlist = python{3.5,3.6,3.7,3.8,3.9},lint,coverage

[testenv]
deps = -rrequirements-dev.txt
commands =
pytest tests {posargs}

[testenv:lint]
usedevelop = True
commands =
pytest --flake8 copy_tree_map.py

[testenv:coverage]
usedevelop = True
commands =
pytest --cov copy_tree_map --cov-report=term-missing tests {posargs}

0 comments on commit 373a927

Please sign in to comment.