-
Notifications
You must be signed in to change notification settings - Fork 67
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
♻️ REFACTOR: Source package metadata from PyPI #201
Conversation
Oh and it also adds reading of PEP621 compliant pyproject.toml, FYI, the latest flit + pip versions now support editable builds with no (I've now implemented it in https://github.com/aiidateam/aiida-firecrest, and it's working great) |
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.
Thanks @chrisjsewell !
If I were to play devil's advocate, instead of needing to fetch just the build file from the repo, we now need to fetch both from PyPI and from the repo...
I agree, however, that it is a step in the right direction - we want to show the properties of the published packages (if available); showing updated data from the repository that conflicts with the info on PyPI is undesirable.
I just have one main change request, after this happy to merge
aiida_registry/fetch_metadata.py
Outdated
|
||
Currently the entry points are always read from the build, | ||
since PyPI JSON does not include entry points, | ||
and so we would need to download and read the wheel file. |
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.
should we open an issue for this then?
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.
Yep 👍 (see the comment I just made)
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 now fixed 😄
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.
great! Would you mind updating the comment as well?
plugins.json
Outdated
@@ -6,49 +6,56 @@ | |||
"pip_url": "aiida-core", | |||
"plugin_info": "https://raw.githubusercontent.com/aiidateam/aiida-core/master/setup.json", | |||
"code_home": "https://github.com/aiidateam/aiida-core", | |||
"documentation_url": "https://aiida-core.readthedocs.io/" | |||
"documentation_url": "https://aiida-core.readthedocs.io/", | |||
"pypi_name": "aiida-core" |
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.
Correct me if I'm wrong but I don't think this additional field is necessary.
As described in the README, the pip_url
will contain either the package name or a URL to the repo.
One can argue about whether that is the best solution, but it has been in place since a while, so I suggest you simply get the package name from there.
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.
Yep sure, will just have to add a bit of logic that decides if it is a pypi name (and so we can source metadata from there) or an external url (so we can only use the plugin_info
url for metadata)
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.
Ok fixed in 03f09bd
(#201)
But yeh, as you said, the repo data is not what we should be referencing; it should be the latest release. |
Ok now you don't 😝 The entry points are fetched from the PyPI tested the speed, and there is really not that much difference: $ time aiida-registry fetch --no-fetch-pypi
...
aiida-registry fetch --no-fetch-pypi 23.48s user 0.57s system 27% cpu 1:26.61 total
$ time aiida-registry fetch --fetch-pypi
...
aiida-registry fetch --fetch-pypi 26.97s user 0.92s system 25% cpu 1:47.67 total (and obviously this does not include request caching) |
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.
thanks Chris!
can you still update the comment; then it should be good to go.
I trust that you checked that the fetched metadata is at least as complete as before.
aiida_registry/fetch_metadata.py
Outdated
|
||
Currently the entry points are always read from the build, | ||
since PyPI JSON does not include entry points, | ||
and so we would need to download and read the wheel file. |
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.
great! Would you mind updating the comment as well?
yep it is indeed 👍 |
done |
This refactor makes it so that package data is primarily sourced from PyPI,
if a
if thepypi_name
key is presentpip_url
points to a PyPI package,with a fallback to the repository build file (
setup.json
,setup.cfg
,pyproject.toml
).(a) this ensures the released metadata is shown (not unreleased, development metadata),
and (b) this handles dynamic metadata, such as the version in
flit
andsetup.cfg
.Currently, the entry points are always read from the build file,since PyPI JSON does not include entry points,
and so we would need to download and read the wheel file to obtain them.
when the
bdist_wheel
is available on PyPI, it is downloaded and the entry-points extracted from itI diffed the original
plugin_metadata.json
to the new, and everything looked correct,except for one thing:
The
aiida_version
isnull
for some more packages.This is because PyPI only extracts/stores
requires_dist
data, if abdist_wheel
distribution is available (see https://www.python.org/dev/peps/pep-0491/).This is essentially a bug with those packages (and we should warn them),
since all best practice build frontends (https://github.com/pypa/build,
flit publish
,poetry publish
)build both the sdist and the wheel.
Therefore, there is now a new report warning for this:
WARNING: No bdist_wheel available for PyPI release