Skip to content

Commit

Permalink
gh-36794: sage --package create --pypi: Create a wheel package by d…
Browse files Browse the repository at this point in the history
…efault if possible

    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes #1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

We change the default of `sage --package create --pypi` to create a
wheel package (if the package has a platform-independent wheel on PyPI)
instead of a normal package (built from source).
This is simpler (no spkg-install.in script, no build dependencies) and a
bit faster.

As an illustration, we change one SPKG, `six`, from normal to wheel.

<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes #12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- #12345: short description why this is a dependency
- #34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: #36794
Reported by: Matthias Köppe
Reviewer(s): Kwankyu Lee, Matthias Köppe
  • Loading branch information
Release Manager committed Dec 12, 2023
2 parents 74122cc + 818468a commit 1c19a98
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
5 changes: 2 additions & 3 deletions build/make/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,8 @@ toolchain-deps:
all-toolchain: base-toolchain
+$(MAKE_REC) toolchain-deps

# All packages needed as a prerequisite to install other Python packages with
# pip or which are otherwise used by the Python build tools; these should be
# given as a prerequisite to any pip-installed packages
# Shorthand for a list of packages sufficient for building and installing
# typical Python packages from source. Wheel packages only need pip.
PYTHON_TOOLCHAIN = setuptools pip setuptools_scm wheel setuptools_wheel

# Trac #32056: Avoid installed setuptools leaking into the build of python3 by uninstalling it.
Expand Down
10 changes: 5 additions & 5 deletions build/pkgs/six/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tarball=six-VERSION.tar.gz
sha1=06fa0bb50f2a4e2917fd14c21e9d2d5508ce0163
md5=a7c927740e4964dd29b72cebfc1429bb
cksum=1693137720
upstream_url=https://pypi.io/packages/source/s/six/six-VERSION.tar.gz
tarball=six-VERSION-py2.py3-none-any.whl
sha1=79e6f2e4f9e24898f1896df379871b9c9922f147
md5=529d7fd7e14612ccde86417b4402d6f3
cksum=2975792266
upstream_url=https://pypi.io/packages/py2.py3/s/six/six-VERSION-py2.py3-none-any.whl
2 changes: 1 addition & 1 deletion build/pkgs/six/dependencies
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
| $(PYTHON_TOOLCHAIN) $(PYTHON)
| pip $(PYTHON)

----------
All lines of this file are ignored except the first.
3 changes: 0 additions & 3 deletions build/pkgs/six/spkg-install.in

This file was deleted.

14 changes: 13 additions & 1 deletion build/sage_bootstrap/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def fix_checksum(self, package_name):
update.fix_checksum()

def create(self, package_name, version=None, tarball=None, pkg_type=None, upstream_url=None,
description=None, license=None, upstream_contact=None, pypi=False, source='normal'):
description=None, license=None, upstream_contact=None, pypi=False, source=None):
"""
Create a package

Expand All @@ -288,6 +288,14 @@ def create(self, package_name, version=None, tarball=None, pkg_type=None, upstre
if '-' in package_name:
raise ValueError('package names must not contain dashes, use underscore instead')
if pypi:
if source is None:
try:
if PyPiVersion(package_name, source='wheel').tarball.endswith('-none-any.whl'):
source = 'wheel'
else:
source = 'normal'
except PyPiError:
source = 'normal'
pypi_version = PyPiVersion(package_name, source=source)
if source == 'normal':
if not tarball:
Expand All @@ -312,6 +320,10 @@ def create(self, package_name, version=None, tarball=None, pkg_type=None, upstre
license = pypi_version.license
if not upstream_contact:
upstream_contact = pypi_version.package_url
if upstream_url and not tarball:
tarball = upstream_url.rpartition('/')[2]
if tarball and source is None:
source = 'normal'
if tarball and not pkg_type:
# If we set a tarball, also make sure to create a "type" file,
# so that subsequent operations (downloading of tarballs) work.
Expand Down
2 changes: 1 addition & 1 deletion build/sage_bootstrap/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def make_parser():
'package_name', default=None, type=str,
help='Package name.')
parser_create.add_argument(
'--source', type=str, default='normal', help='Package source (one of normal, wheel, script, pip)')
'--source', type=str, default=None, help='Package source (one of normal, wheel, script, pip); default depends on provided arguments')
parser_create.add_argument(
'--version', type=str, default=None, help='Package version')
parser_create.add_argument(
Expand Down

0 comments on commit 1c19a98

Please sign in to comment.