Skip to content

Commit 1f1610f

Browse files
committed
Merge appveyor CI branch
1 parent 41efaf8 commit 1f1610f

3 files changed

Lines changed: 204 additions & 2 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
# python-geosupport [![Python 2.7](https://img.shields.io/badge/python-2.7-blue.svg)](https://www.python.org/downloads/release/python-2714/) [![Python 3.4+](https://img.shields.io/badge/python-3.4+-blue.svg)](https://www.python.org/downloads/release/python-360/) [![PyPI version](https://img.shields.io/pypi/v/python-geosupport.svg)](https://pypi.python.org/pypi/python-geosupport/)
1+
# python-geosupport
22

3-
Python bindings for NYC Planning's [Geosupport Desktop Edition](https://www1.nyc.gov/site/planning/data-maps/open-data/dwn-gde-home.page).
3+
[![Build status](https://ci.appveyor.com/api/projects/status/5uocynec8e3maeeq?svg=true)](https://ci.appveyor.com/project/ishiland/python-geosupport) [![Python 2.7](https://img.shields.io/badge/python-2.7-blue.svg)](https://www.python.org/downloads/release/python-2714/) [![Python 3.4+](https://img.shields.io/badge/python-3.4+-blue.svg)](https://www.python.org/downloads/release/python-360/) [![PyPI version](https://img.shields.io/pypi/v/python-geosupport.svg)](https://pypi.python.org/pypi/python-geosupport/)
44

5+
Python bindings for NYC Planning's [Geosupport Desktop Edition](https://www1.nyc.gov/site/planning/data-maps/open-data/dwn-gde-home.page).
56

67
## Installation
78
### Prerequisites

appveyor.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
version: '1.0.{build}'
2+
3+
environment:
4+
5+
# GEO_VERSION: '18b'
6+
7+
matrix:
8+
# Windows w/64 bit python 3.5
9+
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
10+
PYTHON: "C:\\Python35-x64"
11+
PYTHON_ARCH: "64"
12+
GEO_VERSION: '18b'
13+
14+
# Windows w/64 bit python 2.7
15+
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
16+
PYTHON: "C:\\Python27-x64"
17+
PYTHON_ARCH: "64"
18+
GEO_VERSION: '18b'
19+
20+
# Windows w/32 bit Geo & python 3.5
21+
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
22+
PYTHON: "C:\\Python35"
23+
PYTHON_ARCH: "32"
24+
GEO_VERSION: '18b'
25+
26+
# Windows w/32 bit Geo & python 2.7
27+
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
28+
PYTHON: "C:\\Python27"
29+
PYTHON_ARCH: "32"
30+
GEO_VERSION: '18b'
31+
32+
# Ubuntu - python 3
33+
- APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu
34+
PYTHON: "3.6"
35+
GEO_VERSION: '18b'
36+
37+
# Ubuntu - python 2.7
38+
- APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu
39+
PYTHON: "2.7"
40+
GEO_VERSION: '18b'
41+
42+
# Ubuntu - python 3 w/Geosupport 18c
43+
- APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu
44+
PYTHON: "3.6"
45+
GEO_VERSION: '18c'
46+
47+
# Ubuntu - python 3 w/Geosupport 18d
48+
- APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu
49+
PYTHON: "3.6"
50+
GEO_VERSION: '18d'
51+
52+
53+
init:
54+
- cmd: set PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%
55+
- cmd: "%PYTHON%/python -V"
56+
- cmd: "%PYTHON%/python -c \"import struct;print(8 * struct.calcsize(\'P\'))\""
57+
58+
stack: python %PYTHON%
59+
60+
build_script:
61+
- ps: .\appveyor\build.ps1
62+
63+
test_script:
64+
- python setup.py test
65+
# - pip install -e .[dev]
66+
# - invoke test all
67+
68+

appveyor/build.ps1

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# Variables to help determine new naming convention in download string - currently only testing different geosupport versions in linux
2+
# New naming convention example: linux_geo18d_184.zip
3+
$legacyVersions = @('18a', '18b', '18c')
4+
$subVersions = 'a', 'b', 'c', 'd', 'e', 'f'
5+
$BASE_URL = 'https://www1.nyc.gov/assets/planning/download/zip/data-maps/open-data/'
6+
7+
# DL function modified from https://github.com/ogrisel/python-appveyor-demo/blob/master/appveyor/install.ps1
8+
function Download($filename, $url)
9+
{
10+
$webclient = New-Object System.Net.WebClient
11+
$basedir = $pwd.Path + "//"
12+
$filepath = $basedir + $filename
13+
if (Test-Path $filename)
14+
{
15+
Write-Host "Reusing" $filepath
16+
return $filepath
17+
}
18+
19+
# Download and retry up to 3 times in case of network transient errors.
20+
Write-Host "Downloading" $filename "from" $url
21+
$retry_attempts = 2
22+
for ($i = 0; $i -lt $retry_attempts; $i++) {
23+
try
24+
{
25+
Write-Host "Download attempt" $( $i + 1 )
26+
$webclient.DownloadFile($url, $filepath)
27+
break
28+
}
29+
Catch [Exception]
30+
{
31+
Write-Host "Download Error"
32+
Start-Sleep 1
33+
}
34+
}
35+
if (Test-Path $filepath)
36+
{
37+
Write-Host "File saved at" $filepath
38+
}
39+
else
40+
{
41+
Write-Host "File not downloaded"
42+
# Retry once to get the error message if any at the last try
43+
$webclient.DownloadFile($url, $filepath)
44+
}
45+
return $filepath
46+
}
47+
48+
if ($isWindows)
49+
{
50+
# set download and temp directory names
51+
if ($env:PYTHON_ARCH -eq '64')
52+
{
53+
54+
$LOCALDIR = 'geosupport-install-x64'
55+
$TARGETDIR = 'C:\Program Files\Geosupport Desktop Edition'
56+
$FILENAME = "gde64_$( $env:GEO_VERSION ).zip"
57+
$URL = "$( $BASE_URL )$( $FILENAME )"
58+
}
59+
elseif ($env:PYTHON_ARCH -eq '32')
60+
{
61+
$LOCALDIR = 'geosupport-install-x86'
62+
$TARGETDIR = 'C:\Program Files (x86)\Geosupport Desktop Edition'
63+
$FILENAME = "gde_$( $env:GEO_VERSION ).zip"
64+
$URL = "$( $BASE_URL )$( $FILENAME )"
65+
}
66+
67+
# download
68+
Write-Host "Downloading $env:PYTHON_ARCH bit Geosupport version $env:GEO_VERSION for Windows..."
69+
$DOWNLOAD_FILE = Download $FILENAME $URL
70+
71+
# extract
72+
Write-Host "Extracting..."
73+
unzip $FILENAME -d $LOCALDIR
74+
75+
# delete .zip
76+
rm $FILENAME
77+
78+
# silently install Geosupport Desktop
79+
Write-Host "Installing..."
80+
Start-Process -Wait -FilePath "$( $LOCALDIR )/setup.exe" -Verb runAs -ArgumentList '/s', '/v"/qn"'
81+
82+
# set Geosupport Environmental variables
83+
$env:PATH = "$( $TARGETDIR )\bin;$( $env:PATH )"
84+
$env:GEOFILES = "$( $TARGETDIR )\fls\"
85+
86+
Write-Host "Install complete."
87+
}
88+
89+
elseif ($isLinux)
90+
{
91+
if ($legacyVersions -contains $env:GEO_VERSION)
92+
{
93+
$FILENAME = "gdelx_$( $env:GEO_VERSION ).zip"
94+
}
95+
96+
# determine string if new geosupport download naming convention
97+
else
98+
{
99+
foreach ($version in $subVersions)
100+
{
101+
if ($version -eq $env:GEO_VERSION.Substring(2))
102+
{
103+
$idx = [array]::indexOf($subVersions, $version) + 1
104+
$FILENAME = "linux_geo$( $env:GEO_VERSION )_$($env:GEO_VERSION.Substring(0, 2) )$( $idx ).zip"
105+
}
106+
}
107+
}
108+
109+
# set download string and local directory names
110+
$LOCALDIR = 'geosupport-install-lx'
111+
$URL = "$( $BASE_URL )$( $FILENAME )"
112+
113+
# download
114+
Write-Host "Downloading Geosuport version $env:GEO_VERSION for Linux..."
115+
Download $FILENAME $URL
116+
117+
# extract
118+
Write-Host "Extracting..."
119+
unzip $FILENAME -d $LOCALDIR
120+
121+
# get the first child directory name of the unzipped geosupport install dir
122+
$GEO_DIR_CHILD_NAME = Get-ChildItem $LOCALDIR -Recurse | Where-Object { $_.FullName -like "*$( $env:GEO_VERSION )*" } | Select-Object -First 1 | select -expand Name
123+
$INSTALL_PATH = "$( $pwd )/$( $LOCALDIR )/$( $GEO_DIR_CHILD_NAME )"
124+
125+
# delete .zip
126+
rm $FILENAME
127+
128+
# set Geosupport Environmental variables
129+
$env:GEOFILES = "$( $INSTALL_PATH )/fls/"
130+
$env:LD_LIBRARY_PATH = "$( $INSTALL_PATH )/lib/:$( $env:LD_LIBRARY_PATH )"
131+
132+
Write-Host "Install complete."
133+
}

0 commit comments

Comments
 (0)