Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Runtime dependency on setuptools #215

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

Closed
blaggacao wants to merge 1 commit into commitizen-tools:master from blaggacao:patch-1

Conversation

Copy link
Contributor

@blaggacao blaggacao commented Jul 1, 2020
edited
Loading

Imported here:

import pkg_resources

Types of changes

Please put an x in the box that applies

  • Bugfix

Without it in a pristine python environment:

cz --help
Traceback (most recent call last):
 File "/nix/store/8wvn1d6hfdcribcinn21rzlkvjvzab2p-python3.8-commitizen-1.23.0/bin/.cz-wrapped", line 6, in <module>
 from commitizen.cli import main
 File "/nix/store/k4h5dy9yqdm8gisdmbhzg75m06p1fb9z-python3-3.8.3-env/lib/python3.8/site-packages/commitizen/cli.py", line 9, in <module>
 from commitizen import commands, config
 File "/nix/store/k4h5dy9yqdm8gisdmbhzg75m06p1fb9z-python3-3.8.3-env/lib/python3.8/site-packages/commitizen/commands/__init__.py", line 1, in <module>
 from .bump import Bump
 File "/nix/store/k4h5dy9yqdm8gisdmbhzg75m06p1fb9z-python3-3.8.3-env/lib/python3.8/site-packages/commitizen/commands/bump.py", line 7, in <module>
 from commitizen.commands.changelog import Changelog
 File "/nix/store/k4h5dy9yqdm8gisdmbhzg75m06p1fb9z-python3-3.8.3-env/lib/python3.8/site-packages/commitizen/commands/changelog.py", line 6, in <module>
 from commitizen import changelog, factory, git, out
 File "/nix/store/k4h5dy9yqdm8gisdmbhzg75m06p1fb9z-python3-3.8.3-env/lib/python3.8/site-packages/commitizen/changelog.py", line 33, in <module>
 import pkg_resources

Copy link
Contributor Author

Not sure about the correct version constraint: please amend.

@blaggacao blaggacao changed the title (削除) Runtime tependency on setuptools (削除ここまで) (追記) Runtime dependency on setuptools (追記ここまで) Jul 1, 2020
packaging = ">=19,<21"
tomlkit = "^0.5.3"
jinja2 = "^2.10.3"
setuptools = ">=47.3.1"
Copy link
Contributor Author

@blaggacao blaggacao Jul 1, 2020

Choose a reason for hiding this comment

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

What would be a more appropriate version constraint? (this is latest on pypi as of today)

Copy link
Member

woile commented Jul 1, 2020

Could you provide the full traceback? Thanks!

Copy link
Contributor Author

blaggacao commented Jul 1, 2020
edited
Loading

Could you provide the full traceback? Thanks!

Actually that's the full traceback when running cz --help - What where you expecting? (Or I'm misinterpreting?)

Copy link
Member

woile commented Jul 1, 2020

I was expecting an exception at the end. It's not clear why it fails.
Which OS are you on?

Copy link
Contributor Author

blaggacao commented Jul 1, 2020
edited
Loading

Oh sorry! Might be that I clipped that unintentionally.

The exception was that pkg_resources is not importable.
This modules is made available by setuptools.

In a python environment without setuptools installed this results in an error as per the dependencies declared in the pyproject.toml.

In such a environment, the truth is: setuptools is a runtime dependency because of this import.

The python environment is the one crafted by the following nix expression:

 4 │ mach-nix = import (
 5 │ builtins.fetchGit {
 6 │ url = "https://github.com/DavHau/mach-nix/";
 7 │ ref = "2.0.1";
 8 │ }
 9 │ );
 10 │
 11 │ commitizenPython = mach-nix.mkPython {
 12 │ python = pkgs.python38;
 13 │ requirements = ''
 14 │ commitizen
 15 │ setuptools
 16 │ '';
 17 │ };

What this does:

  1. takes a bare pkgs.python38
  2. adds commitizen (from pypi)
  3. additionally declares (unexposed) dependency setuptools - this is the motivation for this PR

With this setup it works. If I left setuptools undeclared, it would result in the exception.

Hypothesis: In most common standard python environments setuptools might be shipped or available.
But that doesn't change the fact that it still is a runtime dependency.

Copy link
Contributor Author

blaggacao commented Jul 1, 2020
edited
Loading

Note: https://github.com/DavHau/mach-nix/ has it's build in completely resolved dependency graph of all pypi packages (250MB database). This database is published every 12 hours or so and used for static dependency resolution. Since setuptools is not declared, the tool cannot generate the complete runtime closure for commitizen and I have to complement it manually.

Copy link
Contributor Author

blaggacao commented Jul 2, 2020
edited
Loading

@woile Apologies for the noise... Does my latter explanation make sense? I still wonder what an appropriate version of setuptools would be, though.

Copy link
Member

woile commented Jul 2, 2020

Hey, yes, thanks, I gotta research now, I don't want to run in the issue that it doesn't work in a machine which already has setuptools.

Copy link
Contributor Author

Yeah, I understand. I think tagging the lowest possible setuptools version, which also implements pkg_resouces, upwards could be pretty safe.

Copy link
Member

woile commented Jul 26, 2020

We have removed the dependency 🎉 You can try the latest version 💪

blaggacao reacted with hooray emoji

@woile woile closed this Jul 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /