-
Notifications
You must be signed in to change notification settings - Fork 131
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
Implement extras_require #181
Changes from 1 commit
026907a
79c0aea
8ec6ee2
56963de
2610078
49a915d
8ea9461
197d9b9
ef29b91
6073e75
5e23c1d
50d21fe
6dfbece
dbb0a4f
217876f
4f1a6ee
102e4e4
a6adf99
8371081
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,12 +67,23 @@ requires | |
"configparser; python_version == '2.7'" | ||
] | ||
|
||
extras-require | ||
Lists of packages needed for every optional feature. The requirements | ||
are specified in the same format as for ``requires``. The requirements of | ||
the two reserved extras ``test`` and ``doc`` as well as the extra ``dev`` | ||
are installed by ``flit install``. For example: | ||
|
||
.. code-block:: toml | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will emit sphinx warning message: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, we could add |
||
|
||
[tool.flit.metadata.extras-require] | ||
test = ["pytest>=2.7.3", "pytest-cov"] | ||
doc = ["sphinx"] | ||
|
||
dev-requires | ||
Packages that are required for development. This field is in the same format | ||
as ``requires``. | ||
Packages that are required for development, other than the ones belonging to | ||
the extras ``test`` and ``doc``. This field is in the same format as ``requires``. | ||
|
||
These are not (yet) encoded in the wheel, but are used when doing | ||
``flit install``. | ||
These are installed by ``flit install`` and encoded in the wheel as extra ``dev``. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would make this undocumented (or maybe leave it for now but mark it as deprecated). The canonical way will become |
||
description-file | ||
A path (relative to the .toml file) to a file containing a longer description | ||
of your package to show on PyPI. This should be written in `reStructuredText | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -227,17 +227,23 @@ class Metadata: | |
requires_external = () | ||
provides_extra = () | ||
|
||
metadata_version="2.1" | ||
metadata_version = "2.1" | ||
|
||
# this is part of metadata spec 2, we are using it for installation but it | ||
# doesn't actually get written to the metadata file | ||
# metadata spec 2 | ||
dev_requires = () | ||
extras_require = {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metadata 2.0 was dropped, and metadata 2.1 is much closer to the 1.x formats. This metadata class is meant to closely represent the metadata we actually write/upload, so I'd rather add the extra requirements to The |
||
|
||
def __init__(self, data): | ||
self.name = data.pop('name') | ||
self.version = data.pop('version') | ||
self.author_email = data.pop('author_email') | ||
self.summary = data.pop('summary') | ||
self.extras_require = data.pop('extras_require', {}) | ||
dev_requires = data.pop('dev_requires', None) | ||
if dev_requires is not None: | ||
self.extras_require['dev'] = dev_requires | ||
explicit_extras = data.pop('provides_extra', ()) | ||
self.provides_extra = list(set(explicit_extras) | self.extras_require.keys()) | ||
for k, v in data.items(): | ||
assert hasattr(self, k), "data does not have attribute '{}'".format(k) | ||
setattr(self, k, v) | ||
|
@@ -280,6 +286,10 @@ def write_metadata_file(self, fp): | |
for req in self.requires_dist: | ||
fp.write('Requires-Dist: {}\n'.format(req)) | ||
|
||
for extra, reqs in self.extras_require.items(): | ||
for req in reqs: | ||
fp.write('Requires-Dist: {}; extra == "{}"\n'.format(req, extra)) | ||
|
||
for url in self.project_urls: | ||
fp.write('Project-URL: {}\n'.format(url)) | ||
|
||
|
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 would like the user facing name for this field to be
requires-extra
orrequires-extras
(I don't have a strong preference between these two - thoughts?). I like the symmetry betweenrequires
,requires-python
andrequires-extra[s]
.I think of this like "the package requires these packages, this version of Python, and optionally these further packages for extra features."
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.
requires-extras
andrequires-extra
imply that the package requires the extras. However it’s the extra features that require certain dependencies. So onlyextras-require
says the right thing, don’t you agree?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.
Sorry, I don't. The naming
extras_require
has always felt unintuitive to me.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.
Hm,
requires-extra
makes a little more sense, I’m going for that one then.