mddj 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
mddj-0.0.1/LICENSE.txt ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-present Stephen Rosen <sirosen@globus.org>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
mddj-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,65 @@
1
+ Metadata-Version: 2.1
2
+ Name: mddj
3
+ Version: 0.0.1
4
+ Summary: A CLI for extracting python metadata from packages
5
+ Author-email: Stephen Rosen <sirosen@globus.org>
6
+ License: MIT
7
+ Project-URL: source, https://github.com/sirosen/mddj
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Programming Language :: Python
10
+ Classifier: Programming Language :: Python :: 3.8
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: Implementation :: CPython
16
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
17
+ Requires-Python: >=3.8
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE.txt
20
+
21
+ # mddj
22
+
23
+ Your DJ of MetaData.
24
+
25
+ [![PyPI - Version](https://img.shields.io/pypi/v/mddj.svg)](https://pypi.org/project/mddj)
26
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mddj.svg)](https://pypi.org/project/mddj)
27
+
28
+ -----
29
+
30
+ **Table of Contents**
31
+
32
+ - [Overview](#overview)
33
+ - [Installation](#installation)
34
+ - [Usage](#usage)
35
+ - [License](#license)
36
+
37
+ ## Overview
38
+
39
+ A CLI for interacting with your python package metadata.
40
+
41
+ Supports multiple packaging backends via a uniform interface.
42
+
43
+ ## Installation
44
+
45
+ ```console
46
+ pipx install mddj
47
+ ```
48
+
49
+ ## Usage
50
+
51
+ ### `mddj read`
52
+
53
+ Read metadata from your package by building it to an sdist and then inspecting
54
+ that `sdist`.
55
+
56
+ #### `mddj read requires-python`
57
+
58
+ Show the `Requires-Python` data. Supports specialized options for parsing data
59
+ like `--lower-bound`.
60
+
61
+ See `--help` for details.
62
+
63
+ ## License
64
+
65
+ `flake8-typing-as-t` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
mddj-0.0.1/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # mddj
2
+
3
+ Your DJ of MetaData.
4
+
5
+ [![PyPI - Version](https://img.shields.io/pypi/v/mddj.svg)](https://pypi.org/project/mddj)
6
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mddj.svg)](https://pypi.org/project/mddj)
7
+
8
+ -----
9
+
10
+ **Table of Contents**
11
+
12
+ - [Overview](#overview)
13
+ - [Installation](#installation)
14
+ - [Usage](#usage)
15
+ - [License](#license)
16
+
17
+ ## Overview
18
+
19
+ A CLI for interacting with your python package metadata.
20
+
21
+ Supports multiple packaging backends via a uniform interface.
22
+
23
+ ## Installation
24
+
25
+ ```console
26
+ pipx install mddj
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ ### `mddj read`
32
+
33
+ Read metadata from your package by building it to an sdist and then inspecting
34
+ that `sdist`.
35
+
36
+ #### `mddj read requires-python`
37
+
38
+ Show the `Requires-Python` data. Supports specialized options for parsing data
39
+ like `--lower-bound`.
40
+
41
+ See `--help` for details.
42
+
43
+ ## License
44
+
45
+ `flake8-typing-as-t` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
@@ -0,0 +1,68 @@
1
+ [build-system]
2
+ requires = ["setuptools"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "mddj"
7
+ version = "0.0.1"
8
+ description = 'A CLI for extracting python metadata from packages'
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = { text = "MIT" }
12
+ keywords = []
13
+ authors = [
14
+ { name = "Stephen Rosen", email = "sirosen@globus.org" },
15
+ ]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Programming Language :: Python",
19
+ "Programming Language :: Python :: 3.8",
20
+ "Programming Language :: Python :: 3.9",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: Implementation :: CPython",
25
+ "Programming Language :: Python :: Implementation :: PyPy",
26
+ ]
27
+ dependencies = [
28
+ "importlib_metadata",
29
+ "build",
30
+ "click",
31
+ ]
32
+
33
+ [project.urls]
34
+ source = "https://github.com/sirosen/mddj"
35
+
36
+ [project.scripts]
37
+ mddj = "mddj.cli:main"
38
+
39
+
40
+ [tool.coverage.run]
41
+ parallel = true
42
+ source = ["mddj"]
43
+ [tool.coverage.paths]
44
+ source = [
45
+ "src/",
46
+ "*/site-packages/",
47
+ ]
48
+ [tool.coverage.report]
49
+ show_missing = true
50
+ skip_covered = true
51
+ exclude_lines = [
52
+ # the pragma to disable coverage
53
+ "pragma: no cover",
54
+ # don't complain if tests don't hit unimplemented methods/modes
55
+ "raise NotImplementedError",
56
+ # don't check on executable components of importable modules
57
+ "if __name__ == .__main__.:",
58
+ # mypy-only code segments
59
+ "if t.TYPE_CHECKING:",
60
+ # type-checking overloads
61
+ "@t.overload"
62
+ ]
63
+
64
+ [tool.mypy]
65
+ strict = true
66
+ ignore_missing_imports = true
67
+ disallow_subclassing_any = false
68
+ files = ["src"]
mddj-0.0.1/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ from .cli import main
2
+
3
+ __all__ = ("main",)
@@ -0,0 +1,34 @@
1
+ import contextlib
2
+ import pathlib
3
+ import subprocess
4
+ import sys
5
+ import tempfile
6
+ import typing as t
7
+
8
+ import click
9
+
10
+
11
+ @contextlib.contextmanager
12
+ def ephemeral_sdist(*, capture_build_output: bool = True) -> t.Iterator[pathlib.Path]:
13
+ with tempfile.TemporaryDirectory() as tmpdir:
14
+ try:
15
+ subprocess.run(
16
+ [sys.executable, "-m", "build", "--sdist", "-o", tmpdir],
17
+ check=True,
18
+ capture_output=capture_build_output,
19
+ )
20
+ except subprocess.CalledProcessError as e:
21
+ if capture_build_output:
22
+ click.secho(
23
+ "Encountered errors in build. "
24
+ "Use --no-build-capture to see full details.",
25
+ fg="red",
26
+ err=True,
27
+ )
28
+ click.get_current_context().exit(e.returncode)
29
+
30
+ # now we have an sdist, so let's find it.
31
+ # the package version will be in the name, so we sniff for any .tar.gz file
32
+ # there will only be one file
33
+ sdist_path = next(pathlib.Path(tmpdir).glob("*.tar.gz"))
34
+ yield sdist_path
@@ -0,0 +1,59 @@
1
+ import click
2
+
3
+ from .builder import ephemeral_sdist
4
+ from .readers import read_from_sdist
5
+
6
+
7
+ @click.group("mddj")
8
+ @click.help_option("-h", "--help")
9
+ def main() -> None:
10
+ """MetaData DJ"""
11
+
12
+
13
+ @main.group("read")
14
+ @click.help_option("-h", "--help")
15
+ def read() -> None:
16
+ """Read metadata from the current project."""
17
+
18
+
19
+ @read.command("requires-python")
20
+ @click.help_option("-h", "--help")
21
+ @click.option(
22
+ "--lower-bound",
23
+ is_flag=True,
24
+ help="Show a lower bound rather than the full Requires-Python data.",
25
+ )
26
+ @click.option(
27
+ "--no-build-capture",
28
+ is_flag=True,
29
+ help="Disable capturing of the internal package build output and errors.",
30
+ )
31
+ def read_requires_python(*, lower_bound: bool, no_build_capture: bool) -> None:
32
+ """
33
+ Read the 'Requires-Python' data.
34
+ """
35
+ with ephemeral_sdist(capture_build_output=not no_build_capture) as sdist_path:
36
+ requires_python = read_from_sdist(sdist_path, "Requires-Python")
37
+
38
+ if lower_bound:
39
+ click.echo(find_lower_bound(requires_python))
40
+ else:
41
+ click.echo(requires_python)
42
+
43
+
44
+ def find_lower_bound(req: str) -> str:
45
+ reqs = req.split(",")
46
+ lower_bounds = []
47
+ for r in reqs:
48
+ if r.startswith(">="):
49
+ lower_bounds.append(r[2:])
50
+ elif r.startswith(">"):
51
+ raise RuntimeError(
52
+ "Found a > requirement, rejecting as invalid (use '>=' instead)"
53
+ )
54
+ if len(lower_bounds) > 1:
55
+ raise RuntimeError("Found multiple lower bounds, cannot choose one")
56
+ elif len(lower_bounds) == 0:
57
+ raise RuntimeError("Found no lower bounds")
58
+ else:
59
+ return lower_bounds[0]
@@ -0,0 +1,21 @@
1
+ import pathlib
2
+ import tarfile
3
+
4
+
5
+ def read_from_sdist(sdist_path: pathlib.Path, key: str) -> str:
6
+ """
7
+ Read a key from the PKG-INFO file in an sdist.
8
+ """
9
+ dist_name = sdist_path.name.rsplit(".", 2)[0]
10
+ with tarfile.open(sdist_path, "r:gz") as tf:
11
+ pkg_info_fp = tf.extractfile(f"{dist_name}/PKG-INFO")
12
+ if pkg_info_fp is None:
13
+ raise RuntimeError("Could not find and read PKG-INFO in sdist")
14
+ pkg_info = pkg_info_fp.read().decode()
15
+ try:
16
+ data_line = next(
17
+ line for line in pkg_info.splitlines() if line.startswith(f"{key}:")
18
+ )
19
+ except IndexError:
20
+ raise RuntimeError(f"Could not find '{key}' in PKG-INFO")
21
+ return data_line.partition(":")[2].strip()
@@ -0,0 +1,65 @@
1
+ Metadata-Version: 2.1
2
+ Name: mddj
3
+ Version: 0.0.1
4
+ Summary: A CLI for extracting python metadata from packages
5
+ Author-email: Stephen Rosen <sirosen@globus.org>
6
+ License: MIT
7
+ Project-URL: source, https://github.com/sirosen/mddj
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Programming Language :: Python
10
+ Classifier: Programming Language :: Python :: 3.8
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: Implementation :: CPython
16
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
17
+ Requires-Python: >=3.8
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE.txt
20
+
21
+ # mddj
22
+
23
+ Your DJ of MetaData.
24
+
25
+ [![PyPI - Version](https://img.shields.io/pypi/v/mddj.svg)](https://pypi.org/project/mddj)
26
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mddj.svg)](https://pypi.org/project/mddj)
27
+
28
+ -----
29
+
30
+ **Table of Contents**
31
+
32
+ - [Overview](#overview)
33
+ - [Installation](#installation)
34
+ - [Usage](#usage)
35
+ - [License](#license)
36
+
37
+ ## Overview
38
+
39
+ A CLI for interacting with your python package metadata.
40
+
41
+ Supports multiple packaging backends via a uniform interface.
42
+
43
+ ## Installation
44
+
45
+ ```console
46
+ pipx install mddj
47
+ ```
48
+
49
+ ## Usage
50
+
51
+ ### `mddj read`
52
+
53
+ Read metadata from your package by building it to an sdist and then inspecting
54
+ that `sdist`.
55
+
56
+ #### `mddj read requires-python`
57
+
58
+ Show the `Requires-Python` data. Supports specialized options for parsing data
59
+ like `--lower-bound`.
60
+
61
+ See `--help` for details.
62
+
63
+ ## License
64
+
65
+ `flake8-typing-as-t` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
@@ -0,0 +1,13 @@
1
+ LICENSE.txt
2
+ README.md
3
+ pyproject.toml
4
+ src/mddj/__init__.py
5
+ src/mddj/builder.py
6
+ src/mddj/cli.py
7
+ src/mddj/readers.py
8
+ src/mddj.egg-info/PKG-INFO
9
+ src/mddj.egg-info/SOURCES.txt
10
+ src/mddj.egg-info/dependency_links.txt
11
+ src/mddj.egg-info/entry_points.txt
12
+ src/mddj.egg-info/requires.txt
13
+ src/mddj.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ mddj = mddj.cli:main
@@ -0,0 +1,3 @@
1
+ importlib_metadata
2
+ build
3
+ click
@@ -0,0 +1 @@
1
+ mddj