-
-
Notifications
You must be signed in to change notification settings - Fork 185
gh-294: Vendor lib2to3 #302
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One significant packaging-related recommendation, as well as one other minor comment.
@CAM-Gerlach Thanks done! |
Not sure which is the root cause.
|
The I'm pretty sure the failure is unrelated to this PR, anyway :) |
Thank you Alex for checking this issue :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Standard reminder: You can directly apply all the suggestions you want in one go by going to Files changed
-> Clicking Add to batch on each suggestion -> When done, clicking Commit
One thing I forgot to mention—to legally include the lib2to3
code here, you'll need to include the PSF v2 license under which lib2to3
is licensed (as a module added in Python >2.2+ with no documented additional terms) to a LICENSE.txt
file in the vendor
directory (which will get picked up by Setuptools and Wheel automatically), and also add the appropriate license identifier and classifiers to the metadata (which I added review suggestions for). Here is the exact relevant license reproduced from the CPython LICENSE
file:
License text you need to add to a `LICENSE.txt` file in `vendor`
PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
--------------------------------------------
1. This LICENSE AGREEMENT is between the Python Software Foundation
("PSF"), and the Individual or Organization ("Licensee") accessing and
otherwise using this software ("Python") in source or binary form and
its associated documentation.
2. Subject to the terms and conditions of this License Agreement, PSF hereby
grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
analyze, test, perform and/or display publicly, prepare derivative works,
distribute, and otherwise use Python alone or in any derivative version,
provided, however, that PSF's License Agreement and PSF's notice of copyright,
i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Python Software Foundation;
All Rights Reserved" are retained in Python alone or in any derivative version
prepared by Licensee.
3. In the event Licensee prepares a derivative work that is based on
or incorporates Python or any part thereof, and wants to make
the derivative work available to others as provided herein, then
Licensee hereby agrees to include in any such work a brief summary of
the changes made to Python.
4. PSF is making Python available to Licensee on an "AS IS"
basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
INFRINGE ANY THIRD PARTY RIGHTS.
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
6. This License Agreement will automatically terminate upon a material
breach of its terms and conditions.
7. Nothing in this License Agreement shall be deemed to create any
relationship of agency, partnership, or joint venture between PSF and
Licensee. This License Agreement does not grant permission to use PSF
trademarks or trade name in a trademark sense to endorse or promote
products or services of Licensee, or any third party.
8. By copying, installing or otherwise using Python, Licensee
agrees to be bound by the terms and conditions of this License
Agreement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you mentioned wanting to avoid this hack and wanting to install it with pyproject.toml
instead, I thought some more about this and left a comment below explaining how you should be able to avoid all the changes to this file and instead just add lib2to3
it as a dependency to the bm_2to3/pyproject.toml
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What he said.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you mentioned wanting to avoid this hack and wanting to install it with pyproject.toml instead, I thought some more about this and left a comment below explaining how you should be able to avoid all the changes to this file and instead just add lib2to3 it as a dependency to the bm_2to3/pyproject.toml.
What he said.
As I commented on the discord, VCS approach is the most approximated way to handle this, but I will keep the current approach since managing the VCS URL has some issues when we want to modify the codes and the bootstrap(?) problem.
@corona10 If you want to install it from the parent It's not really easily possible to do it truly locally, at least in a standards-conformant, non-hacky/bespoke way. You could add that subdirectory to the package finder to install it as another top-level package, but there's no way to make that conditional on a specific Python version without using a custom, backend-specific dynamic However, there are several options to still approximate this, and what seems the least work and lowest friction is to specify it as a dependency using a VCS URL reference to this online repository, with the appropriate subdirectory, and git tag specified (which to test the PR prior to merging, will need to be the appropriate branch on your fork), and with a PEP 508 marker limiting it to Python 3.13+. I.e., the dependencies = ["pyperf", 'lib2to3 @ https://github.com/python/pyperformance.git@2to3v3.12#subdirectory=pyperformance/data-files/benchmarks/bm_2to3/vendor ; python_version >= "3.13.0a0"'] This requires minimal extra work up front, though it does make development a bit more tedious if you ever want to make changes to Alternatively, you could host it in its own separate repo, but I'm not sure that would really offer much benefit over just using a separate tag for |
Sidenote: You're missing the required [build-system]
requires = ["setuptools>=61"]
build-backend = "setuptools.build_meta" I'm guessing maybe all the other ones might be missing it too, though, so perhaps something to discuss and implement separately. |
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM from me as far as a packaging is concerned 👍
Waiting for @gvanrossum 's final review as the 2to3 author and vendoring suggester. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t have much expertise here, if CAM is okay you can merge it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What he said.
closes: gh-294