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
11 changes: 11 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
Release notes
=============

3.8.0 (2025-03-25)
------------------

* Stopped using ``pkg_resources``.

* Removed ``--deptree`` flag from redefined ``check`` command, this way of visualizing
a dependency tree is not useful anymore, please use ``uv pip tree`` or hdeps_ instead.


3.7.2 (2025-03-20)
------------------

Expand Down Expand Up @@ -544,3 +553,5 @@ Release notes
.. _report: https://github.com/codrsquad/setupmeta/issues

.. _pip-compile: https://pypi.org/project/pip-tools/

.. _hdeps: https://pypi.org/project/hdeps/
4 changes: 2 additions & 2 deletions docs/versioning.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ here for illustration purposes. In general, you should simply use ``versioning="
(or any other format you like).

You could leverage this ``__version__`` possibility if you have specific use case for that
(like: you'd like to show which version your code is at without using something like
``import pkg_resources``)
(like: you'd like to show which version your code is at without having to do any
dynamic query)


Preconfigured formats
Expand Down
31 changes: 4 additions & 27 deletions setupmeta/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
author: Zoran Simic zoran@simicweb.com
"""

import io
import os
import platform
import re
Expand All @@ -18,14 +17,6 @@

import setuptools

try:
import pkg_resources

except ImportError: # pragma: no cover
warnings.warn("pkg_resources is not available, expect limited functionality", category=RuntimeWarning)
pkg_resources = None


USER_HOME = os.path.expanduser("~") # Used to pretty-print subfolders of ~
DEBUG = os.environ.get("SETUPMETA_DEBUG")
VERSION_FILE = ".setupmeta.version" # File used to work with projects that are in a subfolder of a git checkout
Expand All @@ -40,7 +31,7 @@

# Simplistic parsing of known formats used in requirements.txt
RE_SIMPLE_PIN = re.compile(r"^(%s)\s*==\s*([^;\s]+)\s*(;.*)?$" % PKGID)
RE_WORDS = re.compile(r"[^\w]+")
RE_WORDS = re.compile(r"\W+")
RE_PKG_NAME = re.compile(r"^(%s)$" % PKGID)

ABSTRACT = "abstract"
Expand All @@ -67,19 +58,6 @@ def trace(message):
sys.stderr.flush()


def pkg_req(text):
"""
:param str|None text: Text to parse
:return pkg_resources.Requirement|None: Corresponding parsed requirement, if valid
"""
if text:
try:
return pkg_resources.Requirement(text)

except Exception:
return None


def get_words(text):
if text:
return [s.strip() for s in RE_WORDS.split(text) if s.strip()]
Expand Down Expand Up @@ -170,7 +148,7 @@ def version_components(text):
component = "%s%s" % (qualifier, component)
qualifier = ""

additional.append(component)
additional.append(str(component))

while len(main_triplet) < 3:
main_triplet.append(0)
Expand All @@ -183,7 +161,6 @@ def version_components(text):
additional.append(qualifier)

dirty = "dirty" in additional

return main_triplet[0], main_triplet[1], main_triplet[2], ".".join(additional), distance, dirty


Expand Down Expand Up @@ -316,7 +293,7 @@ def _should_ignore_run_fail(program, args, error):
return False

if args[0] in ("rev-list", "rev-parse") and "HEAD" in args:
# No commits yet, brand new git repo
# No commits yet, brand-new git repo
return error and "revision" in error.lower()

if args[0] == "describe":
Expand Down Expand Up @@ -418,7 +395,7 @@ def readlines(relative_path, limit=0):
try:
result = []
full_path = project_path(relative_path)
with io.open(full_path, "rt") as fh:
with open(full_path, "rt") as fh:
for line in fh:
limit -= 1
if limit == 0:
Expand Down
Loading
Loading