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

colcon package versions assume package already installed #374

Closed
rotu opened this issue Aug 27, 2020 · 4 comments
Closed

colcon package versions assume package already installed #374

rotu opened this issue Aug 27, 2020 · 4 comments
Labels
question Further information is requested

Comments

@rotu
Copy link
Contributor

rotu commented Aug 27, 2020

The way colcon package versions are specified relies on having the current module already installed.

colcon-core/setup.cfg

Lines 1 to 3 in caee5e6

[metadata]
name = colcon-core
version = attr: colcon_core.__version__

At build time, we have version = attr: colcon_core.__version__ but there is no guarantee that colcon_core is in the python path at that time,

When you install colcon_core with poetry, this shows up as a ParseVersionError:

C:\Users\dan\Documents\colcon-ws>poetry install
Updating dependencies
Resolving dependencies...

  ParseVersionError

  Unable to parse "attr: colcon_core.__version__".

  at ~\.poetry\lib\poetry\_vendor\py3.8\poetry\core\semver\version.py:206 in parse
      202│         except TypeError:
      203│             match = None
      204│
      205│         if match is None:
    → 206│             raise ParseVersionError('Unable to parse "{}".'.format(text))
      207│
      208│         text = text.rstrip(".")
      209│
      210│         major = int(match.group(1))

This setup is also known to cause trouble with setuptools:

pypa/setuptools#1724

@rotu rotu changed the title colcon version breaks poetry colcon version breaks build tools Aug 27, 2020
@rotu rotu changed the title colcon version breaks build tools colcon package versions breaks build tools Aug 30, 2020
@rotu
Copy link
Contributor Author

rotu commented Aug 30, 2020

see https://packaging.python.org/guides/single-sourcing-package-version/ for some recommended ways to specify the package version which don't have this problem.

@rotu rotu changed the title colcon package versions breaks build tools colcon package versions assume package already installed Aug 30, 2020
@dirk-thomas dirk-thomas added the question Further information is requested label Aug 31, 2020
@dirk-thomas
Copy link
Member

The way colcon package versions are specified relies on having the current module already installed.
...
At build time, we have version = attr: colcon_core.__version__ but there is no guarantee that colcon_core is in the python path at that time,
...
see https://packaging.python.org/guides/single-sourcing-package-version/ for some recommended ways to specify the package version which don't have this problem.

The colcon-core package follows the best practice from the documentation you referenced - described in the note of option 1: using attr: ... in the setup.cfg file. As that documentation mentions you need at least version 46.4.0 of setuptools to not require the imported modules to be available which is why the build-from-source instructions mention that: https://colcon.readthedocs.io/en/released/developer/bootstrap.html#virtual-environment

What version of setuptools do you have when running into this problem? Assuming it is older than the above version does uodating it resolve the problem for you?

@rotu
Copy link
Contributor Author

rotu commented Sep 10, 2020

You’re right - it should work for setuptools 46.4.0. I somehow totally missed that note!

But setuptools is an install_requires and not a setup_requires and has a minimum version of 30.3.0.

setuptools>=30.3.0

I suspect the issue is either that poetry does not implement the special AST analysis or that a clean venv does not have a bleeding edge setuptools. Will investigate deeper.

@rotu
Copy link
Contributor Author

rotu commented Sep 10, 2020

It's a super slippery bug to reproduce, and I'm having trouble pinning it down fully.

I think this might be a bug in poetry in that it takes a shortcut when comparing the package version against that in the lockfile, which bypasses the special behavior of setuptools.

I'm not sure if #381 will resolve the issue fully with poetry but I'll revisit if it doesn't.

@rotu rotu closed this as completed Sep 10, 2020
rotu added a commit to rotu/colcon-core that referenced this issue Sep 10, 2020
Due to issues discussed in colcon#374, colcon-core setup requires setuptools 46.4.0 to install correctly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Development

No branches or pull requests

2 participants