diff mbox

[1/5] python-pyasn: new package

Message ID 1380849129-18517-2-git-send-email-rjbarnet@rockwellcollins.com
State Superseded
Headers show

Commit Message

Ryan Barnett Oct. 4, 2013, 1:12 a.m. UTC
Signed-off-by: Ryan Barnett <rjbarnet@rockwellcollins.com>

---

The definition of CFLAGS/LDFLAGS/LDSHARED is necessary since the
compilation of won't work correctly using either TARGET_CONFIGURE_OPTS
because it won't link against the correct python library. Also using
python-distutilcross doesn't work as the setup.py doesn't understand
the -x option.

---

v1 -> v2
 * Added comment explain why the -I and -L options are needed
   which is the same comment as PyCrypto package.
 * Added PYTHONPATH definition to the install target command
 * Added host-version of PyAsn since PySNMP-apps will not be able to
   find the installed version of PyASN and try to install it.
---
 package/Config.in                    |    1 +
 package/python-pyasn/Config.in       |   13 ++++++
 package/python-pyasn/python-pyasn.mk |   73 ++++++++++++++++++++++++++++++++++
 3 files changed, 87 insertions(+), 0 deletions(-)
 create mode 100644 package/python-pyasn/Config.in
 create mode 100644 package/python-pyasn/python-pyasn.mk

Comments

Danomi Manchego Oct. 4, 2013, 2:27 a.m. UTC | #1
Ryan,

On Thu, Oct 3, 2013 at 9:12 PM, Ryan Barnett
<rjbarnet@rockwellcollins.com> wrote:
> +               CFLAGS="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include" \
> +               CXX="$(TARGET_CXX)" \
> +               CXXFLAGS="$(TARGET_CXXFLAGS) -I$(STAGING_DIR)/usr/include" \
> +               LDSHARED="$(TARGET_CC) -shared" \
> +               LDFLAGS="$(TARGET_LDFLAGS) -L$(STAGING_DIR)/lib -L$(STAGING_DIR)/usr/lib" \
> +       $(HOST_DIR)/usr/bin/python setup.py build_ext \
> +       --include-dirs=$(STAGING_DIR)/usr/include/python$(PYTHON_VERSION_MAJOR) \
> +       )

I'm curious as to why the mix of -I and --include-dirs.  I.e., why not
three -I's, or one --include-dirs=path1:path2:path3?  Is there a
difference?

I'm also wondering if all of these packages should have
CROSS_COMPILING=yes ... several of the python patches go through pains
to introduce CROSS_COMPILING, presumably there is a reason why.

No objections, just wondering ...

Danomi -
Ryan Barnett Oct. 4, 2013, 2:09 p.m. UTC | #2
Danomi,

Danomi Manchego <danomimanchego123@gmail.com> wrote on 
10/03/2013 09:27:56 PM:

> Ryan,
> 
> On Thu, Oct 3, 2013 at 9:12 PM, Ryan Barnett
> <rjbarnet@rockwellcollins.com> wrote:
> > +               CFLAGS="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include" 
\
> > +               CXX="$(TARGET_CXX)" \
> > +               CXXFLAGS="$(TARGET_CXXFLAGS) 
-I$(STAGING_DIR)/usr/include" \
> > +               LDSHARED="$(TARGET_CC) -shared" \
> > +               LDFLAGS="$(TARGET_LDFLAGS) -L$(STAGING_DIR)/lib -L$
> (STAGING_DIR)/usr/lib" \
> > +       $(HOST_DIR)/usr/bin/python setup.py build_ext \
> > +       --include-dirs=$(STAGING_DIR)/usr/include/python$
> (PYTHON_VERSION_MAJOR) \
> > +       )
> 
> I'm curious as to why the mix of -I and --include-dirs.  I.e., why not
> three -I's, or one --include-dirs=path1:path2:path3?  Is there a
> difference?

The --include-dirs part is left over from copy and paste from 
python-serial.mk
which I used for my base. I like using --include-dirs to point all my 
include
paths so I will move the include path from CFLAGS= down to --include-dirs=
 
> I'm also wondering if all of these packages should have
> CROSS_COMPILING=yes ... several of the python patches go through pains
> to introduce CROSS_COMPILING, presumably there is a reason why.

I thought introducing CROSS_COMPILING in the python patches is meant for 
cross compiling python itself since it is modifying the setup.py in python 

itself.

These are the first python packages that I'm trying to get to cross 
compile.
I've tried using the CROSS_COMPILING flag and it doesn't appear to do
anything so I'm not exactly sure how setting that in the environment will
help in these packages?

If you or somebody else has more familiarity with python cross compiling
modules can explain how this will help, I'm open to changing how these
packages are built.

Finally, I've tried the suggestions that Arnout that gave for the 
python-ipy but those suggestions didn't work.

> No objections, just wondering ...
> 
> Danomi -

Thanks,
-Ryan
diff mbox

Patch

diff --git a/package/Config.in b/package/Config.in
index b7fdb89..3592cb7 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -396,6 +396,7 @@  source "package/python-meld3/Config.in"
 source "package/python-netifaces/Config.in"
 source "package/python-nfc/Config.in"
 source "package/python-protobuf/Config.in"
+source "package/python-pyasn/Config.in"
 source "package/python-pygame/Config.in"
 source "package/python-pyparsing/Config.in"
 source "package/python-pyro/Config.in"
diff --git a/package/python-pyasn/Config.in b/package/python-pyasn/Config.in
new file mode 100644
index 0000000..a352fe4
--- /dev/null
+++ b/package/python-pyasn/Config.in
@@ -0,0 +1,13 @@ 
+config BR2_PACKAGE_PYTHON_PYASN
+	bool "python-pyasn"
+	depends on BR2_PACKAGE_PYTHON
+	depends on BR2_INSTALL_LIBSTDCPP
+	help
+	  PyASN is a Python extension module that enables you to
+	  perform very fast IP address to Autonomous System Number
+	  lookups.
+
+	  https://code.google.com/p/pyasn/
+
+comment "python-pyasn requires C++ support in toolchain"
+        depends on !BR2_INSTALL_LIBSTDCPP
diff --git a/package/python-pyasn/python-pyasn.mk b/package/python-pyasn/python-pyasn.mk
new file mode 100644
index 0000000..bfad659
--- /dev/null
+++ b/package/python-pyasn/python-pyasn.mk
@@ -0,0 +1,73 @@ 
+################################################################################
+#
+# python-pyasn
+#
+################################################################################
+
+PYTHON_PYASN_VERSION = 1.2
+PYTHON_PYASN_SOURCE  = PyASN-$(PYTHON_PYASN_VERSION).zip
+PYTHON_PYASN_SITE    = https://pyasn.googlecode.com/files
+PYTHON_PYASN_LICENSE = LGPL
+
+PYTHON_PYASN_DEPENDENCIES = python
+HOST_PYTHON_PYASN_DEPENDENCIES = host-python
+
+#############
+# Target
+#############
+define PYTHON_PYASN_EXTRACT_CMDS
+	unzip -d $(@D) $(DL_DIR)/$(PYTHON_PYASN_SOURCE)
+	mv $(@D)/PyASN-$(PYTHON_PYASN_VERSION)/* $(@D)
+	$(RM) -r $(@D)/PyASN-$(PYTHON_PYASN_VERSION)
+endef
+
+# The additional -I and -L are needed to ensure that the $(STAGING_DIR)
+# header and library files are pulled. Otherwise the distutils package before
+# the ones that the distutils package will find the headers/libraries that are
+# located at $(HOST_DIR)/usr.
+define PYTHON_PYASN_BUILD_CMDS
+	(cd $(@D); \
+		CC="$(TARGET_CC)" \
+		CFLAGS="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include" \
+		CXX="$(TARGET_CXX)" \
+		CXXFLAGS="$(TARGET_CXXFLAGS) -I$(STAGING_DIR)/usr/include" \
+		LDSHARED="$(TARGET_CC) -shared" \
+		LDFLAGS="$(TARGET_LDFLAGS) -L$(STAGING_DIR)/lib -L$(STAGING_DIR)/usr/lib" \
+	$(HOST_DIR)/usr/bin/python setup.py build_ext \
+	--include-dirs=$(STAGING_DIR)/usr/include/python$(PYTHON_VERSION_MAJOR) \
+	)
+	(cd $(@D); $(HOST_DIR)/usr/bin/python setup.py build)
+endef
+
+# PYTHONPATH definition is need for install since an error could
+# be thrown about installing to location that isn't in PYTHONPATH
+define PYTHON_PYASN_INSTALL_TARGET_CMDS
+	(cd $(@D); \
+		PYTHONPATH=$(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/site-packages \
+	$(HOST_DIR)/usr/bin/python setup.py install --prefix=$(TARGET_DIR)/usr)
+endef
+
+#############
+# Host
+#############
+define HOST_PYTHON_PYASN_EXTRACT_CMDS
+	unzip -d $(@D) $(DL_DIR)/$(PYTHON_PYASN_SOURCE)
+	mv $(@D)/PyASN-$(PYTHON_PYASN_VERSION)/* $(@D)
+	$(RM) -r $(@D)/PyASN-$(PYTHON_PYASN_VERSION)
+endef
+
+define HOST_PYTHON_PYASN_BUILD_CMDS
+	(cd $(@D); \
+	$(HOST_DIR)/usr/bin/python setup.py build_ext \
+	)
+	(cd $(@D); $(HOST_DIR)/usr/bin/python setup.py build)
+endef
+
+define HOST_PYTHON_PYASN_INSTALL_TARGET_CMDS
+	(cd $(@D); \
+	$(HOST_DIR)/usr/bin/python setup.py install --prefix=$(TARGET_DIR)/usr)
+endef
+
+
+$(eval $(generic-package))
+$(eval $(host-generic-package))