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

Change packaging toolkit to use setuptools-scm #1895

Merged

Conversation

webknjaz
Copy link
Member

@webknjaz webknjaz commented Apr 1, 2019

PR Type

  • Feature Pull Request

Copy link
Contributor

@decentral1se decentral1se left a comment

Choose a reason for hiding this comment

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

Fantastic!

🚀 🚀 🚀

tox.ini Outdated Show resolved Hide resolved
molecule/__init__.py Outdated Show resolved Hide resolved
molecule/__init__.py Outdated Show resolved Hide resolved
setup.py Outdated Show resolved Hide resolved
tox.ini Outdated Show resolved Hide resolved
@webknjaz webknjaz changed the title Change packaging toolkit to use setuptools-scm [WIP] Change packaging toolkit to use setuptools-scm Apr 1, 2019
Copy link
Member

@ssbarnea ssbarnea left a comment

Choose a reason for hiding this comment

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

This change scares the... out of me as it could break a lot and I do not see any business-case (bug) for replacing pbr with something else (like setuptools-scm + python code).

Before seeing such a change I would like to see a bug describing the issue, the proposed solution (not implementation), maybe even some discussions around what we want to fix.

Packaging is one of the most sensible areas and I personally do not want to see molecule installation failing even if someone is trying to install it on system with ancient packaging tools (pip/setuptools/...).

@webknjaz
Copy link
Member Author

webknjaz commented Apr 2, 2019

@ssbarnea pbr itself is a bug. We've been talking about it a lot already. If you want a specific case: it currently generates a totally broken version number from Git tag. And replacing it with something actually working was a public plan for months.

Back to why CI is failing now: we are hitting pypa/pip#6264 now because you've enabled --system-site-packages in tox. I'm trying to make it more resilient, though.

setuptools-scm is battle-tested and pbr is broken by design. I've used both. Does anyone here want to argue about it based on actual experience?

Copy link
Member

@ssbarnea ssbarnea left a comment

Choose a reason for hiding this comment

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

I am not convinced about the pbr broken being broken by design but I will neither defend it forever. As long we can make molecule-with-setuptools-scm work on all platforms where molecule would be used (without having to add extra documentation to ask people to "tune" their systems) I am ok with it.

The only thing I care is to keep molecule being easily installable and consumed, as wheel or from source, with or without a virtualenv. Maybe we could use tox-docker to validate package installation on multiple platforms? (or we could use an ansible playbook too).

setup.cfg Show resolved Hide resolved
tox.ini Show resolved Hide resolved
tox.ini Show resolved Hide resolved
tox.ini Show resolved Hide resolved
@gundalow
Copy link
Contributor

gundalow commented Apr 3, 2019

As long we can make molecule-with-setuptools-scm work on all platforms where molecule would be used (without having to add extra documentation to ask people to "tune" their systems) I am ok with it.

Do we have a full list of all platforms which we can test this PR against?

@ssbarnea
Copy link
Member

ssbarnea commented Apr 3, 2019

Without having a full list I think this makes sense:

  • CentOS 7
  • Fedora 29 (this is base for RHEL 8/CentOS 8)
  • Fedora Rawhide
  • Ubuntu latest stable

On these it need testing with:

  • without virtualenv
  • with isolated virtualenv (not sure if it will work all the way due to missing selinux)
  • with virtualenv with site-packages

Checkpoints:

  • install passes
  • pip check does not report conflicts
  • molecule can be called and is not missing files like templates

tox.ini Outdated Show resolved Hide resolved
tox.ini Show resolved Hide resolved
@tehsmyers
Copy link
Contributor

The multi-platform testing matrix would be useful for testing in any case, both for pbr and for setuptools-scm. That effort would probably warrant its own issue for discussion and a separate pull request.

@webknjaz
Copy link
Member Author

webknjaz commented Apr 3, 2019

As long we can make molecule-with-setuptools-scm work on all platforms

That's what I'm working on now. We'll have a shim emulating missing features, just like I did it for ansible-lint. That's why I set WIP status on this PR. I've hit a few bugs with new tox+setuptools+pip but soon I'll be able to address those.

@webknjaz
Copy link
Member Author

webknjaz commented Apr 3, 2019

The multi-platform testing matrix

If you are suggesting more test jobs, they can be added to Travis to be run on cron or we can use other resources (like GitHub Actions) just for that.

@tehsmyers
Copy link
Contributor

If you are suggesting more test jobs, they can be added to Travis to be run on cron or we can use other resources (like GitHub Actions) just for that.

Yeah, I'm mainly suggesting that while more test jobs is a good idea, I don't think it's something that should block this pull request.

@decentral1se
Copy link
Contributor

decentral1se commented Apr 3, 2019

That effort would probably warrant its own issue for discussion and a separate pull request.

Exactly. Let's please move this discussion off this PR and focus on supporting with reviews.

@webknjaz webknjaz force-pushed the packaging/setuptools-scm-declarative branch from 4f15dcf to bf60fa0 Compare April 7, 2019 09:49
@webknjaz webknjaz dismissed ssbarnea’s stale review April 7, 2019 09:49

feel free to test again

@webknjaz webknjaz changed the title [WIP] Change packaging toolkit to use setuptools-scm Change packaging toolkit to use setuptools-scm Apr 7, 2019
Copy link
Contributor

@decentral1se decentral1se left a comment

Choose a reason for hiding this comment

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

🔥

molecule/__init__.py Show resolved Hide resolved
setup.cfg Outdated Show resolved Hide resolved
setup.cfg Show resolved Hide resolved
setup.cfg Show resolved Hide resolved
setup.py Show resolved Hide resolved
setup.py Show resolved Hide resolved
setup.py Show resolved Hide resolved
setup_requires=['pbr']
)

ALL_STRING_TYPES = tuple(map(type, ('', b'', u'')))
Copy link
Contributor

@decentral1se decentral1se Apr 7, 2019

Choose a reason for hiding this comment

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

Just to note for others, this would all be very scary and signal some major maintenance headaches but it seems to be doing just fine over at https://github.com/ansible/ansible-lint/blob/master/setup.py! So, please take that into consideration when reviewing. Maybe this shim itself needs to be packaged up ... ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, you cannot package this shim. Just because of a chicken/egg problem :)
Of course, you could do even more nasty stuff but I urge you not to.

The right thing to do is to actually upgrade pip/setuptools/python to something better maintainable and if future you can even expect something as magical as https://twitter.com/webKnjaZ/status/1113530472808763394

Copy link
Member Author

Choose a reason for hiding this comment

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

** But I was thinking about making a repo with an example like this...

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, and this version is way more improved over the one used in ansible-lint...

tox.ini Show resolved Hide resolved
setup.py Outdated Show resolved Hide resolved
@webknjaz webknjaz force-pushed the packaging/setuptools-scm-declarative branch 3 times, most recently from f1d9cda to 13667c4 Compare April 8, 2019 21:41
@webknjaz
Copy link
Member Author

webknjaz commented Apr 8, 2019

FTR: interesting things about compat — https://python3statement.org/practicalities/

Copy link
Contributor

@decentral1se decentral1se left a comment

Choose a reason for hiding this comment

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

👍

I haven't done any manual testing of this but it looks good to me now! I know that this has the possibility to resolve a number of issues for the package (and also to push forward re-release 2.20.0 -> 2.20, right!?), so am happy to see this move forward.

@webknjaz webknjaz changed the title Change packaging toolkit to use setuptools-scm [WIP] Change packaging toolkit to use setuptools-scm Apr 9, 2019
@webknjaz

This comment has been minimized.

@ssbarnea
Copy link
Member

ssbarnea commented Apr 9, 2019

Please ignore linter job failure. It's unrelated: yapf got updated within limits which brought us its new view on code formatting. Let's deal with it separately.

Please fix linting as it does make no sense to review code that does not pass CI.

I do not see master as failing and I was not able to replicate any yapf related issue with master code (even with latest 0.26).

Feel free to make a preparatory change related to yapf, if needed.

Copy link
Member

@ssbarnea ssbarnea left a comment

Choose a reason for hiding this comment

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

Fails CI

@tehsmyers
Copy link
Contributor

I do not see master as failing and I was not able to replicate any yapf related issue with master code (even with latest 0.26).

0.26 is not the latest, 0.27 is.

I was able to reproduce the failures on master:

$ git checkout master
$ git pull upstream master
$ pip install -U yapf
$ yapf -d -r molecule/ test/
<observe tons of format changes>

The fixes to this don't belong in this PR, imo.

@webknjaz webknjaz force-pushed the packaging/setuptools-scm-declarative branch from 13667c4 to 33fa9eb Compare April 9, 2019 21:16
@webknjaz webknjaz changed the title [WIP] Change packaging toolkit to use setuptools-scm Change packaging toolkit to use setuptools-scm Apr 9, 2019
@webknjaz webknjaz dismissed ssbarnea’s stale review April 9, 2019 21:24

We are not doing this here.

@webknjaz webknjaz force-pushed the packaging/setuptools-scm-declarative branch from 33fa9eb to cb04425 Compare April 9, 2019 21:27
@webknjaz
Copy link
Member Author

webknjaz commented Apr 9, 2019

Feel free to make a preparatory change related to yapf

Nope. I'm not raising the number of changed files from 12 to 100 here. Sorry. As per explanation @ #1891 I refuse to do non-atomic changes.

@webknjaz webknjaz force-pushed the packaging/setuptools-scm-declarative branch 2 times, most recently from a813237 to 9a58ecc Compare April 9, 2019 21:48
Also:
* 🎨 include a shim to simulate setuptools' ability to read data from
``setup.cfg`` under ancient envs.
* ⬆️ BSpecify project stability in metadata properly
* ⬆️ Bump required tox to v3.8.4
* 🎨 Retrieve Molecule version using pkg_resources
* 🐛 Whitelist find in tox in build-dists
* 🎨 Enable isolated build in tox
* 🔥 Drop Ansible 2.4 factor ref from tox
* ⬆️ Bump setuptools req to v41.0.0
* 🎨 Wire up tox build-dists env into Travis CI
* 🔒 Close ansible#1753 by using package_data

Co-Authored-By: webknjaz <wk.cvs.github@sydorenko.org.ua>
@webknjaz webknjaz force-pushed the packaging/setuptools-scm-declarative branch from 9a58ecc to 418459f Compare April 9, 2019 21:52
@tehsmyers
Copy link
Contributor

Nope. I'm not raising the number of changed files from 12 to 100 here. Sorry. As per explanation @ #1891 I refuse to do non-atomic changes.

Also, as #1911 demonstrates, making those changes would break lint. It's a larger problem, now captured in #1916.

@webknjaz
Copy link
Member Author

webknjaz commented Apr 9, 2019

It seems like everyone who wanted to comment on this change already did it. So I'm merging it with red CI because master is broken and this change doesn't bring it new failures.

@webknjaz webknjaz merged commit 5314ebd into ansible:master Apr 9, 2019
@decentral1se
Copy link
Contributor

Great.

ragingpastry added a commit to ragingpastry/piedpiper-picli that referenced this pull request Apr 10, 2019
Migrate to setuptools-scm and setup.py. This follows on the back
of ansible/molecule#1895. There are so
many different standards for specifying Python dependencies
so we are just going to pick one and stick with it.
All runtime dependencies should be specified in setup.cfg.
All test dependencies should be specified in tox.ini. Since
we are using Tox as our test execution environment we can simply
pin dependencies here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants