Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

turn on github actions caching of pip environments #773

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

clintonsteiner
Copy link
Collaborator

No description provided.

@clintonsteiner clintonsteiner force-pushed the enableCachingOfPythonEnvsAndPipDownloadCaches branch from 41ca210 to dd9dcf8 Compare January 7, 2025 14:51
Copy link
Owner

@akaihola akaihola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder what happened with the CI build, I see no checks run.

Copy link
Owner

@akaihola akaihola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test-future.yml so far only runs by schedule. Could you add

on:  # yamllint disable-line rule:truthy
  schedule:
    - cron: "05 20 * * 6"
  workflow_dispatch:  # Allow manual triggering

so we can trigger it at will on this branch before merging so we can ensure the modified workflow still runs?

@clintonsteiner
Copy link
Collaborator Author

test-future.yml so far only runs by schedule. Could you add

on:  # yamllint disable-line rule:truthy
  schedule:
    - cron: "05 20 * * 6"
  workflow_dispatch:  # Allow manual triggering

so we can trigger it at will on this branch before merging so we can ensure the modified workflow still runs?

done

@akaihola
Copy link
Owner

akaihola commented Jan 7, 2025

Could you add

on:  # yamllint disable-line rule:truthy
  schedule:
    - cron: "05 20 * * 6"
  workflow_dispatch:  # Allow manual triggering

so we can trigger it at will on this branch before merging so we can ensure the modified workflow still runs?
done

It wasn't just as simple as that. I needed to cherry-pick your workflow-dispatch commit to master and push your branch from your fork to my repository.

Anyway, now the workflow ran, and we indeed have a problem:

Run # strict dependency resolution added in pip 20.3
  # strict dependency resolution added in pip 20.3
  # CVE-2021-3572 fixed in pip 21.1
  uv pip install \
    --constraint=constraints-future.txt \
    --upgrade \
    --upgrade-strategy=eager \
    -e '.[test]'
  shell: /usr/bin/bash -e {0}
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.12.8/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.12.8/x64/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.8/x64
    Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.8/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.8/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.12.8/x64/lib
    UV_CACHE_DIR: /home/runner/work/_temp/setup-uv-cache
error: unexpected argument '--upgrade-strategy' found

  tip: a similar argument exists: '--upgrade'

Usage: uv pip install --constraints <CONSTRAINTS> --upgrade <PACKAGE|--requirements <REQUIREMENTS>|--editable <EDITABLE>>

For more information, try '--help'.
Error: Process completed with exit code 2.

Let's try to figure out what the equivalent to pip install --upgrade-strategy=eager is in uv.

@akaihola
Copy link
Owner

akaihola commented Jan 7, 2025

Also apparently distutils used to end up in the environment via pip. I think I've previously migrated from distutils.version.LooseVersion to maybe packaging. Need to look it up.

  import json
  import os
  import urllib.request
  from distutils.version import LooseVersion
  from importlib.metadata import version
  from textwrap import dedent
  
  for linenum, line in enumerate(open("setup.cfg"), 1):
      constraint = line.strip()
      if constraint.startswith("black>="):
          column = line.index("black>=") + 1
          end_column = len(line)
          break
  else:
      raise RuntimeError("black>= line not found in setup.cfg")
  
  response = urllib.request.urlopen(
      'https://pypi.org/pypi/black/json'
  ).read().decode()
  latest_version = max(
      LooseVersion(s)
      for s in json.loads(response)['releases'].keys()
  )
  
  print(
      dedent(
          f"""
          ### :x: Future Black incompatibility? :x:
  
          You could add a maximum version constraint for Black on
          `setup.cfg` line {linenum}, e.g.
          `{constraint},<={latest_version}`
  
          See [#382](/akaihola/darker/issues/382)
          for more information
          """
      ),
      file=open(os.getenv("GITHUB_STEP_SUMMARY"), "a"),
  )
  
  print(
      "::notice "
      "file=setup.cfg,"
      f"line={linenum},"
      f"col={column},"
      f"endColumn={end_column},"
      "title=Future Black incompatibility?::"
      "You could add a maximum version constraint for Black here, "
      f"e.g. {constraint},<={latest_version}"
  )
  shell: /opt/hostedtoolcache/Python/3.12.8/x64/bin/python {0}
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.12.8/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.12.8/x64/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.8/x64
    Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.8/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.8/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.12.8/x64/lib
    UV_CACHE_DIR: /home/runner/work/_temp/setup-uv-cache
Traceback (most recent call last):
  File "/home/runner/work/_temp/f043726e-e943-4df1-a652-c950d5c5aadf.py", line 4, in <module>
    from distutils.version import LooseVersion
ModuleNotFoundError: No module named 'distutils'
Error: Process completed with exit code 1.

@clintonsteiner
Copy link
Collaborator Author

@akaihola the distutils is due to it not installing all the dependencies - needs setuptools installed

@clintonsteiner
Copy link
Collaborator Author

@akaihola Thoughts on a chat about moving fully into pyproject.toml and uv?

@akaihola
Copy link
Owner

akaihola commented Jan 8, 2025

Apparently distutils used to end up in the environment via pip. In other projects I've migrated from distutils.version.LooseVersion to maybe packaging.version.Version, see e.g. darkgray_dev_tools/versions.py. I'll do that here too in a separate PR.

moving fully into pyproject.toml and uv?

Moving away from Setuptools is not yet possible due to dynamic removal of the contributors HTML table from README.rst in setup.py. It's necessary because PyPI can't render it correctly. I haven't yet found a solution using more modern pyproject.toml based build tools. See #806.

@akaihola
Copy link
Owner

akaihola commented Jan 8, 2025

In other projects I've migrated from distutils.version.LooseVersion to maybe packaging.version.Version, see e.g. darkgray_dev_tools/versions.py. I'll do that here too in a separate PR.

See #803.

@akaihola
Copy link
Owner

akaihola commented Jan 8, 2025

@clintonsteiner I merged #803. Could you rebase on master again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants