Closed sodul closed 1 year ago
I do not have much prior experience with pyproject.toml and setup.cfg. I had to make some concessions on things that setup.py
was able to perform, especially with the version string, but things seem to work overall.
I was able to test with python 3.11 on macOS and 3.10 through docker:
> docker run -it --entrypoint=/bin/bash -v $(pwd):/green python:3.11
root@04a02e05cae2:/# cd green/
root@04a02e05cae2:/green# pip install -e .
Obtaining file:///green
Installing build dependencies ... done
Checking if build backend supports build_editable ... done
Getting requirements to build editable ... done
Installing backend dependencies ... done
Preparing editable metadata (pyproject.toml) ... done
Collecting colorama
Downloading colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Collecting coverage
Downloading coverage-7.2.3-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (231 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 231.8/231.8 kB 2.6 MB/s eta 0:00:00
Collecting lxml
Downloading lxml-4.9.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (7.2 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.2/7.2 MB 12.1 MB/s eta 0:00:00
Collecting unidecode
Downloading Unidecode-1.3.6-py3-none-any.whl (235 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 235.9/235.9 kB 19.3 MB/s eta 0:00:00
Building wheels for collected packages: green
Building editable for green (pyproject.toml) ... done
Created wheel for green: filename=green-3.4.3-0.editable-py2.py3-none-any.whl size=4949 sha256=0e24d4950924f6c8719cfc45ffffd210670fd0b2583a8ab82ac995a21a1d1d02
Stored in directory: /tmp/pip-ephem-wheel-cache-byr4_9c5/wheels/b5/b4/5f/4a5d30b042601dc195ad2dc33e34811f748dbd440573f8a7fc
Successfully built green
Installing collected packages: unidecode, lxml, coverage, colorama, green
Successfully installed colorama-0.4.6 coverage-7.2.3 green-3.4.3 lxml-4.9.2 unidecode-1.3.6
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
[notice] A new release of pip available: 22.3.1 -> 23.1.1
[notice] To update, run: pip install --upgrade pip
Tested with the python:3.x containers by running pip install -e .; green green
:
The error is:
File "/tmp/pip-build-env-z1stumkg/overlay/lib/python3.6/site-packages/pkg_resources/_vendor/packaging/requirements.py", line 102, in __init__
req = REQUIREMENT.parseString(requirement_string)
File "/tmp/pip-build-env-z1stumkg/overlay/lib/python3.6/site-packages/pkg_resources/_vendor/pyparsing.py", line 1654, in parseString
raise exc
File "/tmp/pip-build-env-z1stumkg/overlay/lib/python3.6/site-packages/pkg_resources/_vendor/pyparsing.py", line 1644, in parseString
loc, tokens = self._parse( instring, 0 )
File "/tmp/pip-build-env-z1stumkg/overlay/lib/python3.6/site-packages/pkg_resources/_vendor/pyparsing.py", line 1402, in _parseNoCache
loc,tokens = self.parseImpl( instring, preloc, doActions )
File "/tmp/pip-build-env-z1stumkg/overlay/lib/python3.6/site-packages/pkg_resources/_vendor/pyparsing.py", line 3417, in parseImpl
loc, exprtokens = e._parse( instring, loc, doActions )
File "/tmp/pip-build-env-z1stumkg/overlay/lib/python3.6/site-packages/pkg_resources/_vendor/pyparsing.py", line 1406, in _parseNoCache
loc,tokens = self.parseImpl( instring, preloc, doActions )
File "/tmp/pip-build-env-z1stumkg/overlay/lib/python3.6/site-packages/pkg_resources/_vendor/pyparsing.py", line 3205, in parseImpl
raise ParseException(instring, loc, self.errmsg, self)
pkg_resources._vendor.pyparsing.ParseException: Expected stringEnd (at char 4), (line:1, col:5)
Since 3.5 and 3.6 are officially deprecated, let me know if you want me to ensure support for them.
I was able to install with 3.5 and 3.6 by hardcoding the install_requires
value.
Unfortunately I can't run green on itself with 3.5 as the test code has 3.6 syntax, f-strings did not exist yet in 3.5.
> docker run -it --entrypoint=/bin/bash -v $(pwd):/green python:3.5
root@9f2547817a80:/# cd green/
root@9f2547817a80:/green# pip install -e .
DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.
Obtaining file:///green
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing wheel metadata ... done
Collecting unidecode
Downloading Unidecode-1.3.6-py3-none-any.whl (235 kB)
|████████████████████████████████| 235 kB 1.4 MB/s
Collecting lxml
Downloading lxml-4.9.2-cp35-cp35m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (5.7 MB)
|████████████████████████████████| 5.7 MB 1.7 MB/s
Collecting coverage
Downloading coverage-5.5-cp35-cp35m-manylinux2010_x86_64.whl (240 kB)
|████████████████████████████████| 240 kB 19.1 MB/s
Collecting colorama
Downloading colorama-0.4.5-py2.py3-none-any.whl (16 kB)
Installing collected packages: unidecode, lxml, coverage, colorama, green
Running setup.py develop for green
Successfully installed colorama-0.4.5 coverage-5.5 green lxml-4.9.2 unidecode-1.3.6
WARNING: You are using pip version 20.2.3; however, version 20.3.4 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
root@9f2547817a80:/green# green green
Traceback (most recent call last):
File "/usr/local/bin/green", line 33, in <module>
sys.exit(load_entry_point('green', 'console_scripts', 'green')())
File "/green/green/cmdline.py", line 89, in main
return _main(argv, testing)
File "/green/green/cmdline.py", line 68, in _main
result = run(test_suite, stream, args, testing)
File "/green/green/runner.py", line 94, in run
parallel_targets = toParallelTargets(suite, args.targets)
File "/green/green/loader.py", line 348, in toParallelTargets
proto_test_list = toProtoTestList(suite)
File "/green/green/loader.py", line 332, in toProtoTestList
toProtoTestList(i, test_list, doing_completions)
File "/green/green/loader.py", line 324, in toProtoTestList
getattr(suite, exception_method.strip())()
File "/green/green/loader.py", line 80, in testFailure
raise ImportError(message)
ImportError: Failed to import green.test.test_integration computed from filename /green/green/test/test_integration.py
Traceback (most recent call last):
File "/green/green/loader.py", line 54, in loadFromModuleFilename
__import__(dotted_module)
File "/green/green/test/test_integration.py", line 29
fh = open(os.path.join(sub_tmpdir, f"test_finalizer{i}.py"), "w")
^
SyntaxError: invalid syntax
I was able to run green green
with python 3.5 by changing the syntax ingreen/test/test_integration.py
:
for i in range(multiprocessing.cpu_count() * 2):
fh = open(os.path.join(sub_tmpdir, "test_finalizer%d.py" % i), "w")
fh.write(
dedent(
"""
import unittest
class Pass%d(unittest.TestCase):
def test_pass%d(self):
pass
def msg():
print("finalizer worked")
""" % (i, i)
)
)
fh.close()
Let me know how you want to handle this:
I'm going to run find . -name '*.py' -exec pyupgrade --py36-plus {} +
for this PR. It is catching a lot of python 2 leftovers, and will update many strings to f-string, amongst other goodies that will make the code more readable.
If you are not against it I'm considering adding mypy to the CI pipeline and start adding type annotation, but in a separate PR. I've found mypy to be very valuable in finding a lot of hidden bugs in our own codebase.
The CI check cannot run python 3.6 on Ubuntu Latest. Considering 3.6 has been deprecated for over a year that's not surprising. I can skip 3.6 on Ubuntu only since it passes on macOS and Windows. Note that 3.7 will be deprecated at the end of June:
https://devguide.python.org/versions/
In case you are wondering about some of the changes decided by pyupgrade
, they are well documented: https://github.com/asottile/pyupgrade
This will bring forward compatibility with newer versions of pip.
Fixes #267
Tested with: