Skip to content

Commit

Permalink
[REF] Deprecate pkg_resources, use importlib & packaging (#121)
Browse files Browse the repository at this point in the history
* [REF] Switch version detection from `pkg_resources` to `importlib,packaging`

* [REQ] Add `packaging` as dependency

* [CI] Install `packaging` before installing package

* [CI] Try installing with `python -m pip`

* [FIX] Try CI with python 3.9

* [FIX] Try installing `packaging` with `apt-get`

* [FIX] Call `pip show`

* [FIX] Try with `python3.10`

* [FIX] String around python version

* [FIX] Try installing `wheel`

* [FIX] Explicitly install `wheel`

Magically seems to fix the import error of `packaging`

* [FIX] Also explicitly install `packaging`

* [FIX] Install `wheels` and `packaging` in RTD

* [FIX] Different install command

* [FIX] Another attempt

* [FIX] Spelling error

* [FIX] Try again

* [FIX] Try with `post_build` option

* [FIX] Use `post_install`

* [FIX] Install `setuptools<=69`

* [FIX] Pin `setuptools`
  • Loading branch information
f-dangel committed Jul 3, 2024
1 parent 4aaec2b commit 84c2ce7
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint-black.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pip wheel packaging
make install-lint
- name: Run black
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-darglint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pip wheel packaging
make install-lint
- name: Run darglint
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-flake8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pip wheel packaging
make install-lint
- name: Run flake8
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-isort.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pip wheel packaging
make install-lint
- name: Run isort
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-pydocstyle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pip wheel packaging
make install-lint
- name: Run pydocstyle
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
python -m pip install setuptools wheel twine packaging
- name: Build and publish
env:
TWINE_USERNAME: __token__
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
python-version: "${{ matrix.python-version }}"
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pip wheel packaging
make install-test
- name: Run test
if: contains('refs/heads/master refs/heads/development', github.ref)
Expand Down
3 changes: 3 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ build:
os: ubuntu-22.04
tools:
python: "3.8"
jobs:
post_install:
- pip install --upgrade pip packaging wheel setuptools==69.5.1

python:
install:
Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ lint =

# Dependencies needed to build/view the documentation (semicolon/line-separated)
docs =
setuptools==69.5.1 # RTD fails with setuptools>=70, see https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/15863
transformers
datasets
matplotlib
Expand Down
11 changes: 6 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
"""

import sys
from importlib.metadata import version

from pkg_resources import VersionConflict, require
from packaging.version import Version
from setuptools import setup

try:
require("setuptools>=38.3")
except VersionConflict:
print("Error: version of setuptools is too old (<38.3)!")
setuptools_version = Version(version("setuptools"))

if setuptools_version < Version("38.3"):
print(f"Error: version of setuptools is too old (<38.3). Got {setuptools_version}.")
sys.exit(1)


Expand Down

0 comments on commit 84c2ce7

Please sign in to comment.