Skip to content

Support --with-data-copy as environment variable #1605

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

Closed
jeroen opened this issue Feb 17, 2021 · 19 comments
Closed

Support --with-data-copy as environment variable #1605

jeroen opened this issue Feb 17, 2021 · 19 comments

Comments

@jeroen
Copy link
Contributor

jeroen commented Feb 17, 2021

Can I do the same as --with-data-copy by setting an environment variable rather than a configure flag?

When building thousands of packages, in a complex pipeline, it is very tricky to customize the build commands for individual packages. But we can easily set global environment variables on the build server.

I am already setting PROJ_LIB but from what I understand, there is no variable that does the equivalent of --with-data-copy? I was first assuming that --with-data-copy=yes was implicit when static linking but I see that is not the case. cf: #1583 (comment)

@rsbivand
Copy link
Member

Shall I try this for rgdal to test a template for others? Do you have a suggested name, like:
_WITH_PROJ_GDAL_DATA_COPY ? Do you have a standard prefix?

@jeroen
Copy link
Contributor Author

jeroen commented Feb 17, 2021

Thank you yes that would be great. The name doesn't matter for me, I think the autoconf convention is to omit the with part for envvar names, e.g. just PROJ_GDAL_DATA_COPY=TRUE

@rsbivand
Copy link
Member

Here is a local copy of the rgdal source package, built with PROJ_LIB=/usr/local/share/proj PROJ_GDAL_DATA_COPY=TRUE R CMD build pkg. I watched the /tmp install needed for building the vignettes, and /gdal and /proj were there. Should be revision 1124 when R-Forge runs.

rgdal_1.5-24.tar.gz

@jeroen
Copy link
Contributor Author

jeroen commented Feb 17, 2021

Hmm I trigged a build from the svn, but I don't think it worked. You can see the output here: https://github.com/r-universe/r-forge/runs/1919687390 (on the right hand under "Inspect check output").

Maybe the test autoconf line should simply be if test ${PROJ_GDAL_DATA_COPY} ; so without the = TRUE so that we simply test if the variable is set, because I am not sure if shell equates "TRUE" to TRUE.

@jeroen
Copy link
Contributor Author

jeroen commented Feb 17, 2021

Actually on Linux it shows this, not sure if that is related

checking for proj_context_create in -lproj... yes
checking Using GDAL < 3 with PROJ >= 6... no
checking PROJ version >= 4.8.0... yes
checking PROJ: proj.db found and readable... yes
./configure: line 3348: test: =: unary operator expected

@rsbivand
Copy link
Member

rsbivand commented Feb 17, 2021

No, I don't think so. The section with data_copy starts at 4014. Maybe you picked up a transient state, not 1124?

On the package source, running:

PROJ_LIB=/usr/local/share/proj PROJ_GDAL_DATA_COPY=TRUE ./configure

I see:

...
checking proj.h usability... yes
checking proj.h presence... yes
checking for proj.h... yes
checking for proj_context_create in -lproj... yes
checking Using GDAL < 3 with PROJ >= 6... no
checking PROJ version >= 4.8.0... yes
checking PROJ: proj.db found and readable... yes
configure: "PROJ_GDAL_DATA_COPY used."
configure: Copy data for:
cp: cannot create directory '': No such file or directory
configure:   PROJ.4: /usr/local/share/proj
cp: cannot create directory '': No such file or directory
configure:   GDAL: /usr/local/share/gdal
configure: Package CPP flags:  -I/usr/local/include -DPROJ_H_API
configure: Package LIBS:  -L/usr/local/lib -lgdal -L/usr/local/lib -lproj 
configure: creating ./config.status
config.status: creating src/Makevars

which is as expected, as ${R_PACKAGE_DIR} is not set.

I just committed revision 1125, using test -n ${PROJ_GDAL_DATA_COPY} instead, and 1126 removing a bashism elsewhere.

@jeroen
Copy link
Contributor Author

jeroen commented Feb 17, 2021

Thank you, it seems to work now:

checking Using GDAL < 3 with PROJ >= 6... no
checking PROJ version >= 4.8.0... yes
checking PROJ: proj.db found and readable... yes
configure: "PROJ_GDAL_DATA_COPY used."
configure: Copy data for:
configure:   PROJ.4: /usr/local/share/proj
configure:   GDAL: /usr/local/share/gdal
configure: Package CPP flags:  -I/usr/local/include -I/usr/local/lib/pkgconfig/../../include -DPROJ_H_API
configure: Package LIBS:  -L/usr/local/lib -lgdal -lbz2 -ljson-c -lfreexl -lgeos_c -lgeos -lwebp -lodbc -lodbcinst -lltdl -lexpat -lpthread -lopenjp2 -lnetcdf -lhdf5_hl -lhdf5 -lsz -lgif -ljpeg -lgeotiff -lpng -lpq -lpgport -lpgcommon -lssl -lcrypto -lldap -lzstd -llzma -lsqlite3 -lproj -lsqlite3 -ltiff -lz -lpthread -ldl -lspatialite -lrttopo -ldap -ldapserver -ldapclient -lpcre -lminizip -lcurl -lxml2 -liconv -lpthread -dynamic -Wl,-search_paths_first -lkrb5 -framework CoreFoundation -framework Security -framework OpenCL -L/usr/local/lib/pkgconfig/../../lib -lproj -lsqlite3 -ltiff -lcurl -ljpeg -lz
configure: creating ./config.status
config.status: creating src/Makevars

And the binary package now contains the gdal and proj directories.

@jeroen
Copy link
Contributor Author

jeroen commented Feb 17, 2021

@edzer could you copy the rgdal configure script to sf so that I can test if that resolves the issues?

@rsbivand
Copy link
Member

Up to revision 1128 - the message said PROJ.4, which is misleading, now PROJ.

@edzer
Copy link
Member

edzer commented Feb 18, 2021

This gives a problem on macos R-oldrel here; the line where this happened was last edited by @rsbivand here - Roger would you mind taking a look at what might be happening there?

@rsbivand
Copy link
Member

No idea at all. What GDAL/PROJ versions are involved - GEOS 3.8.1, GDAL 3.1.4 and PROJ 6.3.1 (Nick Tate had trouble in class with a MacOS sf - is this release or oldrel? sf always fails on check for me locally (I never trust remote CI as you know, the links are effectively just noise because I cannot drill down to the specific failing test) because of lagging spatstat merges (my system is spatstat >= 2.0.0). If you tell me the GDAL/PROJ, I'll try to replicate.

@jeroen
Copy link
Contributor Author

jeroen commented Feb 18, 2021

I'll try to reproduce it locally, but if it only happens for macos-oldrel on r-universe then maybe there is something out of sync on my end, and it may not happen on cran.

Note that r-universe builds and checks a package using dependencies from that same universe if available. You can see this in the check log under "Build and Check for MacOS" that some of the dependency packages are downloaded from r-spatial.r-universe.dev, and the remaining ones from cran.

@edzer
Copy link
Member

edzer commented Feb 18, 2021

The tab "Inspect check output" gives the output of the ./configure step: GDAL 3.2.0, PROJ 7.2.1, GEOS 3.9.0; strange enough I can't reproduce locally with 3.2.1/7.2.1/3.9.0.

@rsbivand
Copy link
Member

Nor any problem here running source("crs.R", echo=TRUE) with:

> sf_extSoftVersion()
          GEOS           GDAL         proj.4 GDAL_with_GEOS     USE_PROJ_H 
       "3.9.1"        "3.2.1"        "7.2.1"         "true"         "true" 

@rsbivand
Copy link
Member

It may be that PROJ is not finding proj.db at runtime, but this should provoke more chaos and the error message would be Cannot find proj.db (tried live). The error is coming from rgdal::show_SRID() and then .Call("P6_SRID_proj",...) I think.

@jeroen
Copy link
Contributor Author

jeroen commented Feb 18, 2021

Maybe what is happening is that the oldrel-macos binaries from CRAN are linked against older versions of gdal/proj, whereas on r-universe we build everything with up-to-date versions.

So there may be some mismatch between the versions of gdal/proj used by the different R packages. In addition, Simon was using a custom built compiler for R 3.6 that had known compatibility issues with libraries built using standard compilers.

All these problems were solved for R-macos 4.0 when they switched to the standard compilers and updated their libraries. So given that R 3.6 will fall of the map in April, I wouldn't worry about it too much.

@rsbivand
Copy link
Member

rsbivand commented Feb 18, 2021

OK, makes sense. Do you have a feel for 4.1 on M1? Will MacOS binary packages be dual-architecture? I see GDAL 2.4.2 and PROJ 5.2.0 for MacOS.

@jeroen
Copy link
Contributor Author

jeroen commented Feb 18, 2021

I think it will just be a separate cran repository and package library. Almost like a separate platform.

The M1 libraries are here but there hasn't been much progress, I doubt it will be ready for R 4.1: https://mac.r-project.org/libs-arm/

@rsbivand
Copy link
Member

Right, recipes is on GDAL 3.1.4, GEOS 3.8.1 and PROJ 6.3.1. I think the libs-arm64 repo is more complete.

@jeroen jeroen closed this as completed Feb 21, 2021
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Sep 20, 2021
# Please note that **rgdal** will be  retired by the end of 2023, plan
  transition to sf/stars/terra  functions using GDAL and  PROJ at your
  earliest convenience.

# Version 1.5-27 (development, rev. 1149-)
* Correcting logic error in check for MXE UCRT builds (temporary)

# Version 1.5-26 (2021-09-15, rev. 1141-1148)
* Mute use of PROJ CDN for MXE UCRT builds (temporary)

* Run autoupdate on configure.ac to handle obsolete AC_HELP_STRING etc.

# Version 1.5-25 (2021-09-08, rev. 1122-1140)
* Add environment variable access to --with-data-copy by
  PROJ_GDAL_DATA_COPY (r-spatial/sf#1605)

* Adaptations for PROJ 8.

* Handle mixed 2D/3D in readOGR():
  (r-spatial/sf#1683)

* Add tweak for UCRT builds.

* Thin examples for spTransform().

# Version 1.5-23 (2021-02-03, rev. 1120-1121)
* Further fallout after removing valgrind issues.

# Version 1.5-22 (2021-02-02, rev. 1106-1119)
* Attempt to remove further valgrind leak in proj6.cpp: PROJcopyEPSG()
  and in ogr_proj.cpp, both wrongly placed object destructors.

* Modified roundtripping all declared projections in ?project examples
  because some listed projections for PROJ >= 5 provoke valgrind
  leakages by returning very large out-of-scope values for input
  coordinates (0, 0); inversion of these is not attempted; some listed
  projections are not projections.

# Version 1.5-21 (2021-01-27, rev. 1093-1105)
* Suggest **rgeos** to write pre-SFS multipolygon objects to avoid
  unpleasant workaround.

* Try to eliminate current valgrind leaks, starting from
  (r-spatial/gstat#82).

* Try to increase robustness to installation with early PROJ 6
  versions, which often lack functionality found necessary later (for
  example visualization order); the code had assumed that this
  function always was available and behaved as it now does. There are
  now graceful failures when not available.

# Version 1.5-19 (2021-01-05, rev. 1083-1092)
* Dan Baston: raster speedups

* PROJ 7.2.1 includes a bug-fix for `+proj=ob_tran` cases that
  required changes in detection and handling of target/source CRS
  reversal,
  https://lists.osgeo.org/pipermail/proj/2020-December/009999.html

# Version 1.5-18 (2020-10-13, rev. 1071-1082)
* condition `tests/test_enforce_xy.R` on PROJ >= 6 and GDAL >= 3
  (email BDR, I forgot to re-check with PROJ-5.2.0/GDAL-2.2.4).

* Adaptation to EPSG 10 database format started (from PROJ 7.2);
  choose DB columns by name not number in vignette.

# Version 1.5-17 (2020-10-08, rev. 1051-1070)
* `"CRS"` instantiation now prefers PROJ: use
  `rgdal::set_prefer_proj(FALSE)` to return to earlier behaviour. It
  seems that access from C/C++ code to mechanisms in PROJ offers more
  depth than going through GDAL to PROJ. This `"CRS"` instantiation in
  **sp** and **raster**; Proj4 and WKT2 strings may differ depending
  on whether instantiation is straight from PROJ or goes via
  GDAL. Confirmed with multiple reverse dependency checks over almost
  900 CRAN packages.

* By default use PROJ function to extract the source CRS from a
  `"BOUNDCRS"`. When `+towgs84=` is given, PROJ and GDAL see the
  apparent source Proj4 string as implicitly implying a coordinate
  operation transforming to target WGS84, leading to the WKT2
  representation being a `"BOUNDCRS"`, not a `"PROJCRS"` or
  `"GEOGCRS"`, and thus causing misunderstandings later in searching
  for the most accurate coordinate operation for a transformation. May
  be controlled by setting the `get_source_if_boundcrs=` in
  `sp::CRS()` from **sp** 1.4-4 (2020-10-07). Confirmed with multiple
  reverse dependency checks over almost 900 CRAN packages.

* Add support for instantiating from `"OGC:CRS84"` to provide a
  guaranteed GIS/visualization axis order WGS84 instantiator
  (preferred to `"EPSG:4326"`).

* Permit empty string in `SRS_string=` argument to `sp::CRS()` and
  functions called by it.

* Use GDAL `ORSIsProjected()` instead of simply looking for
  `"+proj=longlat"` in the Proj4 string representation where possible.

# Version 1.5-16 (2020-08-07, rev. 1047-1050)
* Typo in C code; use `try()` around Area-of-Interest calculation for
  coordinate operations (email BDR, I forgot to re-check with
  PROJ-5.2.0/GDAL-2.2.4).

# Version 1.5-15 (2020-08-04, rev. 1020-1046)
* Add support for instantiating from `"ESRI:"`.

* Add Area-of-Interest to coordinate operation search (reduces the
  number of candidates found in many cases), and use in
  `rgdal::spTransform()` by default (`use_aoi=FALSE` to suppress);
  illustrate in vignette
  https://cran.r-project.org/web/packages/rgdal/vignettes/CRS_projections_transformations.html.

* Harden to condition on PROJ functions only available from 6.2.0;
  block `"+proj=ob_tran` tests for PROJ 6.0.0-6.1.1.

* Support PROJ CDN https://cdn.proj.org for on-demand download of
  transformation grids if requested by user; document in vignette
  https://cran.r-project.org/web/packages/rgdal/vignettes/CRS_projections_transformations.html.

# Version 1.5-12 (2020-06-26, rev. 1007-1019)
* Further corrections to `configure.ac` for older PROJ/GDAL versions

# Version 1.5-10 (2020-06-09, rev. 991-1006)
* Corrections to `configure.ac` for older PROJ/GDAL versions

# Version 1.5-8 (2020-05-28, rev. 846-990)
* Released to match **sp** 1.4.0 (2020-02-21) to 1.4-2 (2020-05-20)
  following months of development adapting to breaking changes in the
  external libraries used here: PROJ and GDAL; see also
  https://cran.r-project.org/web/packages/sp/news.html.

* Expose `options("rgdal_show_exportToProj4_warnings"="none")` to mute
  Proj4 string degradation warnings.

* Add new vignette
  https://cran.r-project.org/web/packages/rgdal/vignettes/CRS_projections_transformations.html.

* CRAN Windows binary uses PROJ >= 6 and GDAL >= 3

* Add PROJ-based CRS comparison: `compare_CRS()`.

* `project()` and `spTransform()` use WKT2 comment if available,
  fallback to Proj4 representation if not.

* List coordinate operations (based on pyproj code): `list_coordOps()`.

* Add `enforce_xy=` arguments to try to ensure that only
  GIS/visualization axis order is present.

* Add `"CRS"` object comment carrying WKT2 (2019) multiline string
  representation on read operations.

* Use `"CRS"` object comment carrying WKT2 (2019) multiline string
  representation on write operations.
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

3 participants