-
-
Notifications
You must be signed in to change notification settings - Fork 15.1k
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
Python: buildPyPIPackage and generated data #16005
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* This function wraps buildPythonPackage and uses pre-fetched data from PyPI to build a package. | ||
*/ | ||
{ buildPythonPackage | ||
, fetchurl | ||
, fetchgit | ||
, lib | ||
}: | ||
|
||
|
||
{ name | ||
, version ? "" | ||
, ... } @ attrs: | ||
|
||
let | ||
pypi-src = fetchgit { | ||
url = "https://github.com/FRidh/srcs-pypi.git"; | ||
rev = "12bc2a4cbcec42a867e4cc2fdef67e76b2c0b169"; | ||
sha256 = "0j3fhfnj36wsm6z3r0mnsr7c90vihi1j61nwdz31dz4y2r0w2vg4"; | ||
}; | ||
|
||
data = import (pypi-src) {inherit name;}; | ||
|
||
# Whether to actually use PyPI | ||
pypi = !(builtins.hasAttr "src" attrs || builtins.hasAttr "srcs" attrs); | ||
|
||
# Use Meta data from PyPI | ||
pypimeta = if pypi then data.meta else {}; | ||
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 is also pretty cool. |
||
|
||
# Version. When specified, use that. | ||
# Otherwise, if src is not given and there is a PyPI source available, then use the latest version available. | ||
version = attrs.version or (if pypi then data.latest_version else ""); | ||
# Use src if given. Otherwise, pick the right version via PyPI. | ||
src = attrs.src or attrs.srcs or (fetchurl data.versions.${version}); | ||
|
||
in buildPythonPackage ( attrs // {name = name + "-" + version; src=src; meta = pypimeta;} ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is fetchgit required here?
The good thing about your github structure is, that it is pretty readable.
We could generate a compressed version of your directory structure for downloading automatically via travis-ci.
Maybe putting all packages with the same prefix into the same file and compress the whole thing with
xz
to reduce the overall size.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.
https://docs.travis-ci.com/user/deployment/releases/
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 GitHub can produce archives for a specific revision we could use
fetchurl
. But, where we really want to go to is fetchTarbal` along with a sha256. That way, Hydra can evaluate it. Without fetchTarball + sha256 Hydra cannot evaluate it. That's the reason why this is on hold. See also my latest mail.Another option to reduce the size is to work with two repositories, one that has a JSON for each package, and another one that has package names along with hashes of the JSON files. This repo we would then refer to from Nixpkgs. It would replace downloading a big file with (possibly many) tiny ones.