-
-
Notifications
You must be signed in to change notification settings - Fork 541
PEP-517 source distribution support #954
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
|
Nice! I'll try to find some time to take a proper look at this. (FYI, the initial implementation of PEP 517 in pip won't include a |
Codecov Report
@@ Coverage Diff @@
## master #954 +/- ##
==========================================
- Coverage 92.77% 91.75% -1.02%
==========================================
Files 13 13
Lines 2393 2473 +80
Branches 416 433 +17
==========================================
+ Hits 2220 2269 +49
- Misses 109 137 +28
- Partials 64 67 +3
Continue to review full report at Codecov.
|
|
I'll take a look at this later today -- excited for this! |
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.
left some comments as questions for reviewers, reminders for myself
| config.isolated_build = reader.getbool("isolated_build", False) | ||
| if config.isolated_build is True: | ||
| name = ".package" | ||
| if name not in config.envconfigs: |
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.
the build env name should be configurable
src/tox/package.py
Outdated
| if pkg_requirement.key not in toml_require: | ||
| package_venv.envconfig.deps.append(DepConfig(requirement, None)) | ||
|
|
||
| if not session.setupenv(package_venv): |
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.
here we are recreating the env maybe instead just install new dependencies and finalize again the env
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.
recreate is certainly the safest option here -- does the PEP have any suggestions for this?
src/tox/package.py
Outdated
| build_requires = get_build_requires(build_info, package_venv, session) | ||
| for requirement in build_requires: | ||
| pkg_requirement = pkg_resources.Requirement(requirement) | ||
| if pkg_requirement.key not in toml_require: |
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.
note here we might potentially have a issue that this requirement might differ from the first, maybe check for it and raise if that's the case
src/tox/package.py
Outdated
| build_info.backend_module, | ||
| build_info.backend_object, | ||
| "sdist", | ||
| str(config.distdir).replace("\\", "\\\\"), |
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.
instead of the replace mark the output build directory as a raw string
|
|
||
| @pytest.mark.network | ||
| @need_git | ||
| @pytest.mark.skipif(sys.version_info < (3, 0), reason="flit is Python 3 only") |
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.
in CI instead of skip should raise instead
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.
xfail maybe then?
| @@ -0,0 +1,18 @@ | |||
| import subprocess | |||
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.
@asottile @Nicodeamus stolen this from pip any better way of doing this?
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.
this seems fine, maybe a bit overkill to generalize. pre-commit does a similar thing
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.
actually -- is this even worth it? I don't think we package our tests so you'd have to be running from a git checkout? I guess maybe not for OS vendors 🤔
tox.ini
Outdated
| known_first_party = tox | ||
| known_third_party = apiclient,git,httplib2,oauth2client,packaging,pkg_resources,pluggy,py,pytest,setuptools,six | ||
| known_first_party = tox,tests | ||
| known_third_party = apiclient,git,httplib2,oauth2client,packaging,pkg_resources,pluggy,py,pytest,setuptools,six,tests,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.
@asottile for some reason tests shows up as third party even though it is marked as first party
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.
you'll want to change --application-directories from src to src:. here
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.
A bunch of comments, feel free to dismiss most of them, some of them are just me talking to myself.
I jotted down these notes while going through, some probably (?) need addressing -- not sure:
needs documentation:
isolated_buildsetting.packageenvironment name- maybe an example which shows how to configure the executable for the
.packageenvironment (and/or other useful things to override there?)
question:
- does the
.packageenvironment leak intotox --listenvs(or whatever the option is called) -- (either way) should it? - is
.packagea good enough name to avoid conflicts (probably)? if not maybe.tox-package?
Will wheel support want to make N .package environments -- does this enable that or make it more difficult?
Overall seems fine!
src/tox/_pytestplugin.py
Outdated
| name: { | ||
| "__init__.py": textwrap.dedent( | ||
| """ | ||
| \"\"\" module {} \"\"\" |
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.
probably avoid the escape sequences by making either the inner or outer a triple-single-quoted string
|
|
||
| config.skipsdist = reader.getbool("skipsdist", all_develop) | ||
| config.isolated_build = reader.getbool("isolated_build", False) | ||
| if config.isolated_build is True: |
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 assume the idea with this branch is to make the .package environment user-configurable through tox.ini -- which cases does it make sense for that to be configurable? (alternatively: should tox have an opinion about how they configure the .package environment?)
I can see one usecase, wanted to configure the executable
| report.error("FAIL could not package project - v = {!r}".format(v)) | ||
| path = build_package(config, report, session) | ||
| except tox.exception.InvocationError as exception: | ||
| report.error("FAIL could not package project - v = {!r}".format(exception)) |
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.
<3 ty
| def build_isolated(config, report, session): | ||
| build_info = get_build_info(config.setupdir, report) | ||
| package_venv = session.getvenv(".package") | ||
| package_venv.envconfig.deps_matches_subset = True |
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.
clever, a patch!
| package_venv = session.getvenv(".package") | ||
| package_venv.envconfig.deps_matches_subset = True | ||
|
|
||
| package_venv.envconfig.deps = [DepConfig(r, None) for r in build_info.requires] |
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 we're invariably clobbering deps = here, should we error if the user configured deps in their tox.ini? (might be difficult to implement now that I think about it, due to environment inheritance)
tox-pip-extensions for instance does this if the install_command is manually set (since it patches it out)
tox.ini
Outdated
| known_first_party = tox | ||
| known_third_party = apiclient,git,httplib2,oauth2client,packaging,pkg_resources,pluggy,py,pytest,setuptools,six | ||
| known_first_party = tox,tests | ||
| known_third_party = apiclient,git,httplib2,oauth2client,packaging,pkg_resources,pluggy,py,pytest,setuptools,six,tests,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.
you'll want to change --application-directories from src to src:. here
tests/unit/test_pytest_plugins.py
Outdated
| def linesep_bytes(): | ||
| if isinstance(os.linesep, bytes): | ||
| return os.linesep | ||
| return os.linesep.encode("utf-8") |
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.
can probably just use os.linesep.encode() -- in python2 this'll go through the ASCII encoding .decode().encode() but that's probably fine?
|
|
||
| init_file = tmpdir.join("spam", "spam", "__init__.py") | ||
| assert init_file.read_binary() == b"__version__ = '666'" | ||
| expected = b'""" module spam """' + linesep_bytes() + b"__version__ = '666'" |
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.
hail satan ig
| r"(?P<code>(^((?P=indent) +.*)?\n)+)", | ||
| re.MULTILINE, | ||
| ) | ||
|
|
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.
worth moving all the tests in this PR? is the distinction between "unit" and not actually enforced / definitive / useful? is the extra typing worth it?
| @@ -0,0 +1,18 @@ | |||
| import subprocess | |||
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.
actually -- is this even worth it? I don't think we package our tests so you'd have to be running from a git checkout? I guess maybe not for OS vendors 🤔
Added some: the config flags plus an example page related to packaging.
It probably does, we need to filter it out. Will do and add test for it.
Given that now it's configurable it's good enough I think especially with the
Wheel support will have to do the |
create a ``.package`` virtual environment to perform build operations inside
|
This now is mostly complete. Will merge in on Monday unless we find something significant until then. Will re-read https://www.python.org/dev/peps/pep-0517/ before that to make sure we did not miss anything.
|
|
Better later than never: thank you @gaborbernat for your great work on this and thank you @asottile for reviewing 🎆 🎆 🎆 |
create a
.packagevirtual environment to perform build operations inside@asottile @nicoddemus @obestwalter feel free to take a look at it and try to find holes in it 👍 base implementation there, just need to add documentation and some more tests 💯
FYI @pfmoore (we probably will switch over pip once pip will have pep-517 support and
buildcommand - that being said I find this level a support a bit more generic e.g. python version selection). With this tox should finally allow users to specify their packaging dependencies, and use other than setuptools.Resolves #573 and #820.