aboutcode-org / python-inspector

Inspect Python code and PyPI package manifests. Resolve Python dependencies.
22 stars 19 forks source link

Dotted Python version not fully supported #167

Open sschuberth opened 10 months ago

sschuberth commented 10 months ago

Although as of version 0.9.3 "dotted" Python versions, like "2.7", should be supported in addition to "27", it seems that at least for analyzing setup.py it's not supported.

Running

python-inspector --setup-py setup.py --python-version 2.7 --operating-system linux --json-pdt -

on any setup.py file gives

Exception: Python version 2..7 is not compatible with setup.py

(Note the double-dot ".." in there), whereas using --python-version 27 succeeds.

sschuberth commented 10 months ago

The problem seems to be that get_python_version_from_env_tag() unconditionally inserts ".". But instead of fixing that, I wonder instead a lookup in PYTHON_DOT_VERSIONS_BY_VER should be used, and if no match is found (if a version already contains a dot), simply fall back to the literal version.

pombredanne commented 10 months ago

Can you try the latest version instead? And if this does not work, can you try this branch https://github.com/nexB/python-inspector/tree/python-dot-version ?

sschuberth commented 10 months ago

Can you try the latest version instead?

I am testing with 0.10.0, I was just stating that it should work starting from 0.9.3 according to the release notes.

And if this does not work, can you try this branch https://github.com/nexB/python-inspector/tree/python-dot-version ?

I'll have a look.

sschuberth commented 10 months ago

I'll have a look.

So, I tried to run ./configure, which is trying to build the wheel for intbitset (although I have the python-intbitset package installed on my Fedora as suggested also for ScanCode), and the build fails:

  Building wheel for intbitset (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [185 lines of output]
      /tmp/pip-install-rpidp35t/intbitset_e129b03c10c44b69b0fc61bbbb1aaabb/setup.py:37: SyntaxWarning: invalid escape sequence '\s'
        version = re.search('__version__\s*=\s*"(?P<version>.*)"\n', f.read()).group("version")
sschuberth commented 10 months ago

can you try this branch https://github.com/nexB/python-inspector/tree/python-dot-version ?

Can this just be merged @pombredanne so I could test it as part of a new release?

pombredanne commented 10 months ago

@sschuberth re:

Can this just be merged @pombredanne so I could test it as part of a new release?

I would prefer not merging broken code... you can test it anyway using: pip install https://github.com/nexB/python-inspector/archive/refs/heads/python-dot-version.tar.gz

sschuberth commented 10 months ago

I would prefer not merging broken code...

Uhm, how about adding test for that which run in CI as part of PR checks?

you can test it anyway using:

Thanks, but how does the source code archive help me if I can't build pythin-inspector at all, see above?