python3.12 has removed setuptools when a virtualenv is created
When i created a new venv with python3.12 and install JJB 6.2.0, the jenkins-jobs test command fails
❯ jenkins-jobs test if_publisher.yml
ERROR:stevedore.extension:Could not load 'delete': No module named 'pkg_resources'
ERROR:stevedore.extension:Could not load 'delete-all': No module named 'pkg_resources'
ERROR:stevedore.extension:Could not load 'get-plugins-info': No module named 'pkg_resources'
ERROR:stevedore.extension:Could not load 'list': No module named 'pkg_resources'
ERROR:stevedore.extension:Could not load 'test': No module named 'pkg_resources'
ERROR:stevedore.extension:Could not load 'update': No module named 'pkg_resources'
Traceback (most recent call last):
File "/Users/tonychia/jjb/venv_312/bin/jenkins-jobs", line 8, in <module>
sys.exit(main())
^^^^^^
File "/Users/tonychia/jjb/venv_312/lib/python3.12/site-packages/jenkins_jobs/cli/entry.py", line 177, in main
jjb = JenkinsJobs(argv)
^^^^^^^^^^^^^^^^^
File "/Users/tonychia/jjb/venv_312/lib/python3.12/site-packages/jenkins_jobs/cli/entry.py", line 60, in __init__
self.parser = create_parser()
^^^^^^^^^^^^^^^
File "/Users/tonychia/jjb/venv_312/lib/python3.12/site-packages/jenkins_jobs/cli/parser.py", line 112, in create_parser
extension_manager.map(parse_subcommand_args, subparser)
File "/Users/tonychia/jjb/venv_312/lib/python3.12/site-packages/stevedore/extension.py", line 276, in map
raise NoMatches('No %s extensions found' % self.namespace)
stevedore.exception.NoMatches: No jjb.cli.subcommands extensions found
When I manually pip install setuptools, then the "jenkins-jobs test if_publisher.yml
" passes.
Can we add setuptools as a dependency to jenkins-jobs-builder so we only need to run one pip install command to install everything in an empty venv?
steps to reproduce:
1) python3.12 -m venv venv_312
2) source venv_312/bin/activate
3) pip list
verify no setuptools package is installed
gh-95299: Do not pre-install setuptools in virtual environments created with venv. This means that distutils, setuptools, pkg_resources, and easy_install will no longer available by default; to access these run pip install setuptools in the activated virtual environment.
4) pip install jenkins-job-builder==6.2.0
5) jenkins-jobs test if_publisher.yml
and observe the error show above
❯ cat if_publisher.yml
- job-template:
name: 'test-job-{variant}'
triggers:
!j2-yaml: |
{% if discard_old_builds|default(false) %}
- timed: "@daily"
{% else %}
- timed: "@weekly"
{% endif %}
{% if variant == "def" %}
- github
{% endif %}
- project:
name: test-project
jobs:
- 'test-job-{variant}':
variant: abc
- 'test-job-{variant}':
variant: def
discard_old_builds: true
6) pip install setuptools
and run jenkins-jobs test if_publisher.yml
observe the issue went away
Tony