geoarrow / geoarrow-python

Python implementation of the GeoArrow specification
http://geoarrow.org/geoarrow-python/
Apache License 2.0
59 stars 3 forks source link

geoarrow python metapackage #27

Closed kylebarron closed 11 months ago

kylebarron commented 11 months ago

This is a metapackage for the geoarrow namespace on PyPI. Native namespace packages are implicit upon the fact that there is no __init__.py at the top level of a folder. So if geoarrow.pyarrow publishes a wheel with geoarrow/pyarrow/__init__.py but another package geoarrow publishes a wheel with geoarrow/__init__.py, then geoarrow.pyarrow will never be able to be imported because the latter will shadow the former.

This metapackage prevents someone else from taking the "geoarrow" name on PyPI, which lessens the chance that someone else will publish a Python package that exports geoarrow/__init__.py.

You can build the Python module with

pip install -U build
python -m build .

which will build a tar.gz and a wheel into ./dist.

Then you can verify the output with:

virtualenv env
source ./env/bin/activate
pip install ./dist/geoarrow-0.1.0-py3-none-any.whl

The geoarrow package is installed and visible to pip:

> pip show geoarrow
Name: geoarrow
Version: 0.1.0
Summary: Metapackage for geoarrow namespace.
Home-page:
Author:
Author-email: Kyle Barron <kyle@developmentseed.org>
License:
Location: /Users/kyle/github/geoarrow/geoarrow-python/geoarrow-metapackage/env/lib/python3.11/site-packages
Requires:
Required-by:

But there's no geoarrow folder in site-packages:

> ls ./env/lib/python3.11/site-packages/geoarrow
ls: ./env/lib/python3.11/site-packages/geoarrow: No such file or directory

This means that if I also install geoarrow-pyarrow in the same virtualenv

> pip install ../geoarrow-pyarrow

Now the geoarrow folder in site-packages exists (but crucially does not have __init__.py at the top level):

> ls ./env/lib/python3.11/site-packages/geoarrow
c       pyarrow

and I can import and use geoarrow.pyarrow:

> python
Python 3.11.4 (main, Aug 10 2023, 18:50:38) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import geoarrow.pyarrow
>>> geoarrow.pyarrow.PointType
<class 'geoarrow.pyarrow._type.PointType'>

Closes https://github.com/geoarrow/geoarrow-python/issues/3

codecov[bot] commented 11 months ago

Codecov Report

Merging #27 (097232d) into main (76b19e6) will not change coverage. Report is 1 commits behind head on main. The diff coverage is n/a.

@@           Coverage Diff           @@
##             main      #27   +/-   ##
=======================================
  Coverage   94.25%   94.25%           
=======================================
  Files          10       10           
  Lines        1219     1219           
=======================================
  Hits         1149     1149           
  Misses         70       70           

see 2 files with indirect coverage changes