Skip to content

python,python3: Add pypi makefile#10242

Merged
neheb merged 1 commit into
openwrt:masterfrom
jefferyto:pypi-mk
Oct 18, 2019
Merged

python,python3: Add pypi makefile#10242
neheb merged 1 commit into
openwrt:masterfrom
jefferyto:pypi-mk

Conversation

@jefferyto
Copy link
Copy Markdown
Member

Maintainer: me, @commodo
Compile tested: armvirt-64, 2019-10-04 snapshot sdk (tested with python-six, python-twisted)
Run tested: N/A

Description:
This adds pypi.mk, which can be included in Python packages that download their sources from PyPI, to auto-fill various PKG_* variables based on the value of PYPI_NAME.

This makefile should be included after $(TOPDIR)/rules.mk but before $(INCLUDE_DIR)/package.mk (and $(INCLUDE_DIR)/host-build.mk).

Signed-off-by: Jeffery To jeffery.to@gmail.com

@jefferyto
Copy link
Copy Markdown
Member Author

jefferyto commented Oct 14, 2019

This is how I imagine this makefile would be used (using python-six as an example):

include $(TOPDIR)/rules.mk

PKG_NAME:=python-six
PKG_VERSION:=1.12.0
PKG_RELEASE:=2

PYPI_NAME:=six
PKG_HASH:=d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73

PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENSE
PKG_MAINTAINER:=Jeffery To <jeffery.to@gmail.com>, Alexandru Ardelean <ardeleanalex@gmail.com>

HOST_BUILD_DEPENDS:=python3/host

include ../pypi.mk
include $(INCLUDE_DIR)/host-build.mk
include $(INCLUDE_DIR)/package.mk
include ../python-package.mk
include ../python3-package.mk

This needs to be included before package.mk and host-build.mk because it sets PKG_BUILD_DIR and HOST_BUILD_DIR (which are used in package.mk and host-build.mk on include). (I couldn't add to python[3]-package.mk because those need to follow package.mk to override Build/Compile.)

PKG_BUILD_DIR is set in a way so that a custom PKG_UNPACK is no longer necessary. (This is based on a change I submitted to the main repo (openwrt/openwrt@e545fac), which I completely forgot about until a few days ago 🤦‍♂️)

Not having PKG_SOURCE and PKG_SOURCE_URL in the package makefile is a little weird, not sure how everyone feels about that.

I can't believe it took me to so long to think of refactoring these PKG_* variables into a reusable form 🤦‍♂️

Comment thread lang/python/pypi.mk
PKG_SOURCE?=$(PYPI_NAME)-$(PKG_VERSION).$(PYPI_SOURCE_EXT)
PKG_SOURCE_URL?=https://files.pythonhosted.org/packages/source/$(PYPI_NAME_FIRST_LETTER)/$(PYPI_NAME)

PKG_BUILD_DIR:=$(BUILD_DIR)/pypi/$(if $(BUILD_VARIANT),$(PKG_NAME)-$(BUILD_VARIANT)/)$(PYPI_NAME)$(if $(PKG_VERSION),-$(PKG_VERSION))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious, would PKG_SOURCE_SUBDIR be better?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think PKG_SOURCE_SUBDIR is only used when the source is checked out of a repo (git, svn, etc.), not when it is extracted from a tarball?

Comment thread lang/python/pypi.mk Outdated
Comment thread lang/python/pypi.mk Outdated
@commodo
Copy link
Copy Markdown
Contributor

commodo commented Oct 15, 2019

Not having PKG_SOURCE and PKG_SOURCE_URL in the package makefile is a little weird, not sure how everyone feels about that.

I wonder if this interferes with uscan [the tool that emails us telling to upgrade our packages].
If it does, then I am not sure about this change.

@jefferyto
Copy link
Copy Markdown
Member Author

Not having PKG_SOURCE and PKG_SOURCE_URL in the package makefile is a little weird, not sure how everyone feels about that.

I wonder if this interferes with uscan [the tool that emails us telling to upgrade our packages].
If it does, then I am not sure about this change.

I'm not sure... @sdwalker do we need to have PKG_SOURCE and PKG_SOURCE_URL in the actual package makefile?

@sdwalker
Copy link
Copy Markdown
Contributor

Not having PKG_SOURCE and PKG_SOURCE_URL in the package makefile is a little weird, not sure how everyone feels about that.

I wonder if this interferes with uscan [the tool that emails us telling to upgrade our packages].
If it does, then I am not sure about this change.

I'm not sure... @sdwalker do we need to have PKG_SOURCE and PKG_SOURCE_URL in the actual package makefile?

Not for tarballs.
Yes for git packages since PKG_SOURCE_URL is passed to git ls-remote.
uscan scripts don't use PKG_SOURCE.

@jefferyto
Copy link
Copy Markdown
Member Author

@sdwalker Thanks for clarifying - those email notifications are a life-saver 😂

@commodo
Copy link
Copy Markdown
Contributor

commodo commented Oct 18, 2019

I'll admit, I'm a bit fuzzy on how uscan does detection of new packages.
But, if it works with this change, then I don't need to know about it.

Thanks @jefferyto & @sdwalker :)

@neheb
Copy link
Copy Markdown
Contributor

neheb commented Oct 18, 2019

If placement in a Makefile is a concern, this could be useful to add:

https://github.com/openwrt/openwrt/blob/master/include/uclibc%2B%2B.mk#L1

@jefferyto
Copy link
Copy Markdown
Member Author

@commodo I'm glad it occurred to one of us to ask the question 😂

@jefferyto
Copy link
Copy Markdown
Member Author

@neheb I'm not sure I want to stop weird placements, it could be that the makefile author really knows what they are doing or just wants to experiment... Maybe a $(warning ...) or $(info ...) will be enough?

This adds pypi.mk, which can be included in Python packages that
download their sources from PyPI, to auto-fill various PKG_* variables
based on the value of PYPI_NAME.

This makefile should be included after $(TOPDIR)/rules.mk but before
$(INCLUDE_DIR)/package.mk (and $(INCLUDE_DIR)/host-build.mk).

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
@jefferyto
Copy link
Copy Markdown
Member Author

jefferyto commented Oct 18, 2019

Updated with a warning that pypi.mk should be included before package.mk.

@neheb
Copy link
Copy Markdown
Contributor

neheb commented Oct 18, 2019

Merging. if warning is the wrong approach, there is plenty of time to change before version 20.

@neheb neheb merged commit 758865f into openwrt:master Oct 18, 2019
@jefferyto
Copy link
Copy Markdown
Member Author

@commodo @neheb I was thinking of converting most/all packages that download from PyPI to use this makefile... Do you think I should wait until 19.07 is frozen, or just do it now?

@jefferyto jefferyto deleted the pypi-mk branch October 19, 2019 06:07
@neheb
Copy link
Copy Markdown
Contributor

neheb commented Oct 19, 2019

Well, 19.07 has already been branched. I wouldn't bother backporting a change like this. It's fairly cosmetic.

@jefferyto
Copy link
Copy Markdown
Member Author

I wasn't considering backporting this, but using this in master may make cherry picking changes to the 19.07 branch more difficult.

@neheb
Copy link
Copy Markdown
Contributor

neheb commented Oct 19, 2019

I wouldn't worry too much about that.

@BKPepe
Copy link
Copy Markdown
Member

BKPepe commented Nov 2, 2019

I think we should cherry-pick it to openwrt-19.07 as many packages have been converted and newly added packages can not be included openwrt-19.07 without this.

@neheb
Copy link
Copy Markdown
Contributor

neheb commented Nov 2, 2019

Go right ahead. It's a cosmetic change anyway.

@BKPepe
Copy link
Copy Markdown
Member

BKPepe commented Nov 2, 2019

Here you go- 866b42c.

@jefferyto
Copy link
Copy Markdown
Member Author

Thanks @BKPepe - can you cherry pick #10315 as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants