PythonPackage: add pypi attribute to infer homepage/url/list_url#17587
PythonPackage: add pypi attribute to infer homepage/url/list_url#17587alalazo merged 7 commits intospack:developfrom
Conversation
24a14c4 to
91497e2
Compare
91497e2 to
36d13e3
Compare
cosmicexplorer
left a comment
There was a problem hiding this comment.
This is a really really awesome direction to see and it made me excited right as I was about to close my laptop! I think this was a very well-executed change.
Separately, broke out #20504 in case that could make this kind of pattern more robust by not pinning packages to the global pypi repo. I don't think that should block this workstream at all, but rather should be considered as part of a separate arc for options and configuration in general.
|
|
||
| if not hasattr(self, 'list_depth'): | ||
| self.list_depth = 0 | ||
|
|
| # However, SourceForge downloads still need to end in '/download'. | ||
| url_regex += r'(\/download)?$' | ||
| url_regex += r'(\/download)?' | ||
| # PyPI adds #sha256=... to the end of the URL |
There was a problem hiding this comment.
Not a blocker and I would have made the same choice, but if I extend this to CRAN/CPAN, I think that point would be a good time to break some of this method out by repo.
There was a problem hiding this comment.
We could make this more generic and use #... but there are so many URL formats that I'm not sure if this is a good idea.
tgamblin
left a comment
There was a problem hiding this comment.
I like everything about this.
| return 'https://pypi.org/project/' + name + '/' | ||
|
|
||
| @property | ||
| def url(self): |
There was a problem hiding this comment.
oh I love this. allows non-pypi packages to keep working just fine.
There was a problem hiding this comment.
Do we want to add:
else:
raise AttributeError('Must define `pypi` or `url`')for these fields? We do this for other mixins like sourceforce/gnu mirrors. But I don't think it's strictly necessary.
lib/spack/spack/url.py
Outdated
| Note: this function is called by `spack versions` and `spack checksum` | ||
| but not by `spack fetch` or `spack install`. |
There was a problem hiding this comment.
@becker33 This is another complaint I have about our current API. The URL processing logic for spack versions/checksum/create and spack fetch/install is almost entirely separate. This leads to a lot of duplication, and a lot of logic that only exists in one or another.
| # https://<hostname>/packages/<two character hash>/<two character hash>/<longer hash>/<download file> | ||
| # e.g. https://pypi.io/packages/c5/63/a48648ebc57711348420670bb074998f79828291f68aebfff1642be212ec/numpy-1.19.4.zip | ||
| # e.g. https://files.pythonhosted.org/packages/c5/63/a48648ebc57711348420670bb074998f79828291f68aebfff1642be212ec/numpy-1.19.4.zip | ||
| # e.g. https://files.pythonhosted.org/packages/c5/63/a48648ebc57711348420670bb074998f79828291f68aebfff1642be212ec/numpy-1.19.4.zip#sha256=141ec3a3300ab89c7f2b0775289954d193cc8edb621ea05f99db9cb181530512 |
There was a problem hiding this comment.
Tested spack create -f with all of the above URLs
| # Peek inside the compressed file. | ||
| if stage.archive_file.endswith('.zip'): | ||
| if (stage.archive_file.endswith('.zip') or | ||
| '.zip#' in stage.archive_file): |
There was a problem hiding this comment.
The archive_file gets saved with the #sha256=... in the filename. If there is a way to fix that on the stage.py side of things, I would prefer that.
|
Okay, I think this is ready for a final review. I would like to update existing Python packages in a follow-up PR if possible. |
|
@cosmicexplorer feel free to submit similar PRs for CRAN and CPAN. I'm going to convert the rest of PyPI URLs to |
I just discovered https://pypi.org/simple/ and PEP 503. This finally allows us to use
spack versionsandspack checksumon PyPI packages properly! For example:Before
After
This PR modifies
PythonPackageto accept apypivariable that defines thehomepage,url, andlist_urlfor every Python package like @alalazo and others have done for GNU/SourceForge/etc. Progress so far:pypivariable toPythonPackagebase classhomepage,url, andlist_urlifpypiis setspack createto setpypiinstead ofurlspack versions/checksum/createsupport for PyPI URLsPythonPackagedocumentationIf this works well, we can do the same for
cran,cpan, and other similar language-specific software repositories.Closes #2281
Closes #2335
Alternative to #2718