Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# https://editorconfig.org
root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.py]
indent_style = space
indent_size = 4

[*.{ini,toml}]
indent_style = space
indent_size = 4
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
__pycache__/
.pytest_cache/
/README.rst
/setup.py
*.egg-info
/dist/
44 changes: 44 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Config for Travis CI, tests powered by DepHell.
# https://travis-ci.org/
# https://github.com/dephell/dephell

language: python
dist: xenial

# do not run Travis for PR's twice (as for push and as for PR)
branches:
only:
- master

before_install:
# show a little bit more information about environment
- sudo apt-get install -y tree
- env
- tree
# install DepHell
# https://github.com/travis-ci/travis-ci/issues/8589
- curl -L dephell.org/install | /opt/python/3.7/bin/python
- dephell inspect self
install:
- dephell venv create --env=$ENV --python="/opt/python/$TRAVIS_PYTHON_VERSION/bin/python"
- dephell deps install --env=$ENV
script:
- dephell venv run --env=$ENV

matrix:
include:

- python: "3.5"
env: ENV=pytest

- python: "3.6.7"
env: ENV=pytest

- python: "3.7"
env: ENV=pytest

- python: "3.8-dev"
env: ENV=pytest

- python: "3.7"
env: ENV=flake8
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# dephell_setuptools

Extract meta information from `setup.py`.

Install:

```
python3 -m pip install --user dephell_setuptools
```

CLI:

```
python3 -m dephell_setuptools ./setup.py
```

Lib:

```python
from pathlib import Path
from dephell_setuptools import read_setup

result = read_setup(path=Path('setup.py'))
```
6 changes: 6 additions & 0 deletions dephell_setuptools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""Read metainfo from setup.py
"""
# app
from ._cfg import CfgReader
from ._cmd import CommandReader
from ._constants import FIELDS
Expand All @@ -6,6 +9,9 @@
from ._static import StaticReader


__version__ = '0.1.1'


__all__ = [
'FIELDS',
'read_setup',
Expand Down
1 change: 1 addition & 0 deletions dephell_setuptools/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# app
from ._cli import main


Expand Down
2 changes: 2 additions & 0 deletions dephell_setuptools/_base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# built-in
from pathlib import Path
from typing import Union

# app
from ._constants import FIELDS


Expand Down
7 changes: 5 additions & 2 deletions dephell_setuptools/_cfg.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from copy import deepcopy
# built-in
from configparser import ConfigParser
from copy import deepcopy
from pathlib import Path
from typing import Dict, List, Optional, Union

from setuptools.config import ConfigOptionsHandler, ConfigMetadataHandler
# external
from setuptools.config import ConfigMetadataHandler, ConfigOptionsHandler

# app
from ._base import BaseReader
from ._constants import FIELDS

Expand Down
2 changes: 2 additions & 0 deletions dephell_setuptools/_cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# built-in
import json
import sys

# app
from ._manager import read_setup


Expand Down
2 changes: 2 additions & 0 deletions dephell_setuptools/_cmd.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# built-in
import json
import os
import subprocess
Expand All @@ -7,6 +8,7 @@
from pathlib import Path
from tempfile import NamedTemporaryFile

# app
from ._base import BaseReader
from ._constants import FIELDS

Expand Down
6 changes: 4 additions & 2 deletions dephell_setuptools/_manager.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# built-in
from logging import getLogger
from pathlib import Path
from typing import Any, Callable, Iterable
from typing import Any, Callable, Iterable, Union

# app
from ._cfg import CfgReader
from ._cmd import CommandReader
from ._pkginfo import PkgInfoReader
Expand All @@ -18,7 +20,7 @@


def read_setup(*,
path: Path,
path: Union[str, Path],
error_handler: Callable[[Exception], Any] = logger.exception,
readers: Iterable = ALL_READERS):
result = dict()
Expand Down
2 changes: 2 additions & 0 deletions dephell_setuptools/_pkginfo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# built-in
import json
import subprocess

# app
from ._base import BaseReader


Expand Down
9 changes: 6 additions & 3 deletions dephell_setuptools/_static.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# built-in
import ast
from typing import Any, Dict, List, Optional, Union

from ._cached_property import cached_property
# app
from ._base import BaseReader
from ._cached_property import cached_property


class StaticReader(BaseReader):
Expand Down Expand Up @@ -52,8 +54,9 @@ def _get_call(self, elements) -> Optional[ast.Call]:
def _node_to_value(self, node):
if node is None:
return None
if isinstance(node, ast.Constant):
return node.value
if hasattr(ast, 'Constant'):
if isinstance(node, ast.Constant):
return node.value
if isinstance(node, ast.Str):
return node.s
if isinstance(node, ast.Num):
Expand Down
1 change: 1 addition & 0 deletions dephell_setuptools/distutils_cmd.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# app
from ._cmd import JSONCommand


Expand Down
45 changes: 45 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[tool.dephell.main]
from = {format = "flit", path = "pyproject.toml"}
to = {format = "setuppy", path = "setup.py"}

[tool.dephell.pytest]
from = {format = "flit", path = "pyproject.toml"}
envs = ["main", "dev"]
tests = ["tests"]
command = "python -m pytest tests/"

[tool.dephell.flake8]
from = {format = "pip", path = "requirements-flake.txt"}
python = ">=3.6"
command = "flake8"

# -- FLIT -- #

[tool.flit.metadata]
module="dephell_setuptools"
author="Gram (@orsinium)"
author-email="master_fess@mail.ru"
home-page="https://github.com/dephell/dephell_setuptools"
requires-python=">=3.5"
requires=[
"setuptools",
]
description-file="README.md"
classifiers=[
"Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python",
"Topic :: Software Development :: Libraries :: Python Modules",
]

[tool.flit.metadata.requires-extra]
dev = [
"pkginfo",
"pytest",
]
15 changes: 15 additions & 0 deletions requirements-flake.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
flake8

flake8-alfred # https://github.com/datatheorem/flake8-alfred
flake8-blind-except # https://github.com/elijahandrews/flake8-blind-except
flake8-broken-line # https://github.com/sobolevn/flake8-broken-line
flake8-bugbear # https://github.com/PyCQA/flake8-bugbear
flake8-commas # https://github.com/PyCQA/flake8-commas
flake8-comprehensions # https://github.com/adamchainz/flake8-comprehensions
flake8-debugger # https://github.com/JBKahn/flake8-debugger
flake8-logging-format # https://github.com/globality-corp/flake8-logging-format
flake8-mutable # https://github.com/ebeweber/flake8-mutable
flake8-pep3101 # https://github.com/gforcada/flake8-pep3101
flake8-quotes # https://github.com/zheller/flake8-quotes
flake8-tidy-imports # https://github.com/adamchainz/flake8-tidy-imports
pep8-naming # https://github.com/PyCQA/pep8-naming
27 changes: 27 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[metadata]
description-file = README.md
license_file = LICENSE

[flake8]
max-line-length=120
ignore=E241,C401,C408
exclude=
.tox
.dephell
.pytest_cache
build
setup.py
tests/setups

[isort]
skip=.tox,.pytest_cache,.dephell,tests/setups
line_length=120
combine_as_imports=true
balanced_wrapping=true
lines_after_imports=2
not_skip=__init__.py
multi_line_output=5
import_heading_stdlib=built-in
import_heading_thirdparty=external
import_heading_firstparty=project
import_heading_localfolder=app
2 changes: 2 additions & 0 deletions tests/test_cfg.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# built-in
from pathlib import Path

# project
from dephell_setuptools import CfgReader


Expand Down
2 changes: 2 additions & 0 deletions tests/test_cmd.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# built-in
from pathlib import Path

# project
from dephell_setuptools import CommandReader


Expand Down
2 changes: 2 additions & 0 deletions tests/test_static.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# built-in
from pathlib import Path

# project
from dephell_setuptools import StaticReader


Expand Down