Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unsure of correct path for PROJ_DIR on ubuntu #97

Closed
grant-humphries opened this issue Nov 17, 2016 · 5 comments
Closed

unsure of correct path for PROJ_DIR on ubuntu #97

grant-humphries opened this issue Nov 17, 2016 · 5 comments

Comments

@grant-humphries
Copy link

grant-humphries commented Nov 17, 2016

I'm attempting to use an existing install of proj.4 (libproj-dev) on Ubuntu 16.04 as the c library source for pyproj, but I'm having trouble determining the path that I need to set the PROJ_DIR environment variable to. For my proj.4 install the folder that has the files 'espg', 'esri', 'nad27', etc. is /usr/share/proj and I've set the environment variable to that path and then run:

pip install -vvv pyproj

the build succeeds, but based on the output that is generated I'm not sure that it's using my proj.4 install as it doesn't name the paths where library's files are located. Is there a way to check the proj.4 that pyproj is using? I've also tried setting PROJ_DIR to /lib/ as the README suggests, and the build succeeds then as well, but in that case it seems even less likely that it would be using the previously installed proj.4 as none of the files are stored under /lib rather they're all under /usr. Here's the output from pip when PROJ_DIR is set to /usr/share/proj:

Collecting pyproj
  1 location(s) to search for versions of pyproj:
  * https://pypi.python.org/simple/pyproj/
  Getting page https://pypi.python.org/simple/pyproj/
  Looking up "https://pypi.python.org/simple/pyproj/" in the cache
  No cache entry available
  Starting new HTTPS connection (1): pypi.python.org
  "GET /simple/pyproj/ HTTP/1.1" 200 666
  Updating cache with response from "https://pypi.python.org/simple/pyproj/"
  Caching b/c date exists and max-age > 0
  Analyzing links from page https://pypi.python.org/simple/pyproj/
    Found link https://pypi.python.org/packages/0d/db/5fa6fe77a2f04c8b7ffb9d1661587114145324199dd273e2d7079655cf77/pyproj-1.8.1.tar.gz#md5=1b28a593e5868e314cd07f4d291ab1a3 (from https://pypi.python.org/simple/pyproj/), version: 1.8.1
    Found link https://pypi.python.org/packages/29/72/5c1888c4948a0c7b736d10e0f0f69966e7c0874a660222ed0a2c2c6daa9f/pyproj-1.9.5.1.tar.gz#md5=027345e3c033fa400e0e64a1c80d34c9 (from https://pypi.python.org/simple/pyproj/), version: 1.9.5.1
    Found link https://pypi.python.org/packages/3f/9c/bb7cbce5d5453066d63750399e6a74ef8a5e2d2d89c02e6d0ac7ce0ea8fe/pyproj-1.8.1a.tar.gz#md5=389fa3457d5332d54ff209afcea7ca4f (from https://pypi.python.org/simple/pyproj/), version: 1.8.1a
    Found link https://pypi.python.org/packages/50/a6/87d081407287534106a38033daf8c00763a99f054bb3015423515e480e95/pyproj-1.9.4.tar.gz#md5=b0a060465b117dd6c1b37e14f22382aa (from https://pypi.python.org/simple/pyproj/), version: 1.9.4
    Found link https://pypi.python.org/packages/cd/4e/0bcb33a08ba07f483dfcb8ffc58c02bb2883d14dc81d9da8c4da02efc1b5/pyproj-1.8.0.tar.gz#md5=d4aff8a45639ac64ebfc4d84ad72a869 (from https://pypi.python.org/simple/pyproj/), version: 1.8.0
    Found link https://pypi.python.org/packages/e5/d5/bdbe10850da198238cb693019993827e920421eca5d662166f84f3928db6/pyproj-1.9.5.tar.gz#md5=3446a23f1c9de4827b31996ff213c5a3 (from https://pypi.python.org/simple/pyproj/), version: 1.9.5
    Found link https://pypi.python.org/packages/f9/7f/ee337f570e4c3ef4593709dcb63e813c359184ede249c4f79b761186bd08/pyproj-1.9.3.tar.gz#md5=ad0ac0602b6373c4203b4d0774445694 (from https://pypi.python.org/simple/pyproj/), version: 1.9.3
  Using version 1.9.5.1 (newest of versions: 1.8.0, 1.8.1, 1.9.3, 1.9.4, 1.9.5, 1.9.5.1)
  Looking up "https://pypi.python.org/packages/29/72/5c1888c4948a0c7b736d10e0f0f69966e7c0874a660222ed0a2c2c6daa9f/pyproj-1.9.5.1.tar.gz" in the cache
  No cache entry available
  "GET /packages/29/72/5c1888c4948a0c7b736d10e0f0f69966e7c0874a660222ed0a2c2c6daa9f/pyproj-1.9.5.1.tar.gz HTTP/1.1" 200 4424543
  Downloading pyproj-1.9.5.1.tar.gz (4.4MB)
  Downloading from URL https://pypi.python.org/packages/29/72/5c1888c4948a0c7b736d10e0f0f69966e7c0874a660222ed0a2c2c6daa9f/pyproj-1.9.5.1.tar.gz#md5=027345e3c033fa400e0e64a1c80d34c9 (from https://pypi.python.org/simple/pyproj/)
    99% |████████████████████████████████| 4.4MB 8.5MB/s eta 0:00:01  Updating cache with response from "https://pypi.python.org/packages/29/72/5c1888c4948a0c7b736d10e0f0f69966e7c0874a660222ed0a2c2c6daa9f/pyproj-1.9.5.1.tar.gz"
  Caching due to etag
    100% |████████████████████████████████| 4.4MB 294kB/s 
  Running setup.py (path:/tmp/pip-build-hwoOXH/pyproj/setup.py) egg_info for package pyproj
    Running command python setup.py egg_info
    PROJ_DIR is set, using existing proj4 installation..
    running egg_info
    creating pip-egg-info/pyproj.egg-info
    writing pip-egg-info/pyproj.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/pyproj.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/pyproj.egg-info/dependency_links.txt
    writing manifest file 'pip-egg-info/pyproj.egg-info/SOURCES.txt'
    warning: manifest_maker: standard file '-c' not found

    reading manifest file 'pip-egg-info/pyproj.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching 'src/*diff'
    writing manifest file 'pip-egg-info/pyproj.egg-info/SOURCES.txt'
  Source in /tmp/pip-build-hwoOXH/pyproj has version 1.9.5.1, which satisfies requirement pyproj from https://pypi.python.org/packages/29/72/5c1888c4948a0c7b736d10e0f0f69966e7c0874a660222ed0a2c2c6daa9f/pyproj-1.9.5.1.tar.gz#md5=027345e3c033fa400e0e64a1c80d34c9
Building wheels for collected packages: pyproj
  Running setup.py bdist_wheel for pyproj ...   Destination directory: /tmp/tmpa4xXCApip-wheel-
  Running command /home/ubuntu/venv/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-hwoOXH/pyproj/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpa4xXCApip-wheel- --python-tag cp27
  PROJ_DIR is set, using existing proj4 installation..
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-2.7
  creating build/lib.linux-x86_64-2.7/pyproj
  copying lib/pyproj/datadir.py -> build/lib.linux-x86_64-2.7/pyproj
  copying lib/pyproj/__init__.py -> build/lib.linux-x86_64-2.7/pyproj
  running build_ext
  building 'pyproj._proj' extension
  creating build/temp.linux-x86_64-2.7
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/share/proj/include -I/usr/include/python2.7 -c _proj.c -o build/temp.linux-x86_64-2.7/_proj.o
  x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/_proj.o -L/usr/share/proj/lib -L/usr/share/proj/lib64 -Wl,-R/usr/share/proj/lib -Wl,-R/usr/share/proj/lib64 -lproj -o build/lib.linux-x86_64-2.7/pyproj/_proj.so
  installing to build/bdist.linux-x86_64/wheel
  running install
  running install_lib
  creating build/bdist.linux-x86_64
  creating build/bdist.linux-x86_64/wheel
  creating build/bdist.linux-x86_64/wheel/pyproj
  copying build/lib.linux-x86_64-2.7/pyproj/datadir.py -> build/bdist.linux-x86_64/wheel/pyproj
  copying build/lib.linux-x86_64-2.7/pyproj/_proj.so -> build/bdist.linux-x86_64/wheel/pyproj
  copying build/lib.linux-x86_64-2.7/pyproj/__init__.py -> build/bdist.linux-x86_64/wheel/pyproj
  running install_egg_info
  running egg_info
  writing lib/pyproj.egg-info/PKG-INFO
  writing top-level names to lib/pyproj.egg-info/top_level.txt
  writing dependency_links to lib/pyproj.egg-info/dependency_links.txt
  warning: manifest_maker: standard file '-c' not found

  reading manifest file 'lib/pyproj.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  warning: no files found matching 'src/*diff'
  writing manifest file 'lib/pyproj.egg-info/SOURCES.txt'
  Copying lib/pyproj.egg-info to build/bdist.linux-x86_64/wheel/pyproj-1.9.5.1-py2.7.egg-info
  running install_scripts
  creating build/bdist.linux-x86_64/wheel/pyproj-1.9.5.1.dist-info/WHEEL
done
  Stored in directory: /home/ubuntu/.cache/pip/wheels/85/dd/2f/d1ed07a507c7adb330cda0afcc96cae8e9abb4d85bbb788bdf
  Removing source in /tmp/pip-build-hwoOXH/pyproj
Successfully built pyproj
Installing collected packages: pyproj

Successfully installed pyproj-1.9.5.1
@grant-humphries
Copy link
Author

Looking at this project's setup.py I gathered that path that PROJ_DIR is set to needs to have subfolders called 'lib' and 'include' so given where my proj.4 is installed that makes me think /usr may be the proper path to set the variable. However I gave PROJ_DIR that value and ran pip install -vvv pyproj, but the output from pip was identical to when I had the variable set to /usr/share/proj so I'm still not clear as to whether my proj.4 installation is being used

@micahcochran
Copy link
Collaborator

There are two additional undocumented environment variables: PROJ_LIBDIR and PROJ_INCDIR.

PROJ_LIBDIR - this is the path PROJ_DIR + '/lib' and PROJ_DIR + '/lib64'
PROJ_INCDIR - this is the path PROJ_DIR + '/include'

If set in the environment, that setting will be used over the defaults.

If you want to see where pyproj data files are installed, print the variable: pyproj.pyproj_datadir

@grant-humphries
Copy link
Author

Thanks for getting back to me. FWIW these are install locations of my proj.4 package:

/usr
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig/proj.pc
/usr/lib/x86_64-linux-gnu/libproj.la
/usr/lib/x86_64-linux-gnu/libproj.a
/usr/include
/usr/include/org_proj4_PJ_Type.h
/usr/include/projects.h
/usr/include/org_proj4_PJ.h
/usr/include/geodesic.h
/usr/include/org_proj4_Projections.h
/usr/include/proj_api.h
/usr/share
/usr/share/doc
/usr/share/doc/libproj-dev
/usr/share/doc/libproj-dev/copyright
/usr/share/man
/usr/share/man/man3
/usr/share/man/man3/pj_init.3.gz
/usr/share/man/man3/geodesic.3.gz
/usr/lib/x86_64-linux-gnu/libproj.so
/usr/share/doc/libproj-dev/changelog.Debian.gz
/usr/share/doc/libproj-dev/NEWS.Debian.gz
/usr/share/man/man3/proj.3.gz

Do you have a recommendation as to how I should set the environment variables? It looks like setting PROJ_DIR to /usr would be about right, but there is no lib64 directory on my system. Maybe set PROJ_DIR to /usr and PROJ_LIBDIR to /usr/lib/x86_64-linux-gnu?

For a previous install I had PROJ_DIR set to /usr/share/proj and pyproj.data_dir was set to /usr/share/proj/share/proj

@micahcochran
Copy link
Collaborator

If you set PROJ_DIR to /usr for the library portion it would default to adding the directories /usr/lib and /usr/lib64 to search for the library.

Actually for Ubuntu 16.04 if you are using a default installation of PROJ.4, I'd recommend installing the Ubuntu repository package for pyproj.
$ apt install pyproj
Probably want to install it with administrative privileges, (sudo).
The Debian GIS maintainer, Bas, keeps on top of packaging.

@grant-humphries
Copy link
Author

I don't want to install this to my system python, so that solution isn't ideal for me. Thanks for your responses though, it sounds like pointing PROJ_DIR to /usr may be the correct setting, I'm going to go ahead and close the ticket

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

No branches or pull requests

2 participants