summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2019-04-15 02:07:03 +0100
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2019-04-22 02:54:56 +0100
commit169ce222289b9a23079276345830cadaa0b281af (patch)
tree7577b103b012a7c246b388049528a122c080f649
parentc87519743222e9579438504c729086c827a4df42 (diff)
downloadpsycopg2-169ce222289b9a23079276345830cadaa0b281af.tar.gz
Build psycopg from Python
-rw-r--r--.appveyor.yml16
-rwxr-xr-xscripts/appveyor.py38
2 files changed, 38 insertions, 16 deletions
diff --git a/.appveyor.yml b/.appveyor.yml
index 8ad507e..0ffa732 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -82,23 +82,17 @@ init:
# Repository gets cloned, Cache is restored
+
install:
- "%PYEXE% C:\\appveyor.py install"
-build: off
+# PostgreSQL server starts now
-#before_build:
+build: off
build_script:
- # Add PostgreSQL binaries to the path
- - PATH=C:\Program Files\PostgreSQL\9.6\bin\;%PATH%
- - CD C:\Project
- - "%PYTHON%\\python.exe setup.py build_ext --have-ssl --pg-config %PGTOP%\\bin\\pg_config.exe -l libpgcommon -l libpgport -L %OPENSSLTOP%\\lib -I %OPENSSLTOP%\\include"
- - "%PYTHON%\\python.exe setup.py build"
- - "%PYTHON%\\python.exe setup.py install"
- - RD /S /Q psycopg2.egg-info
-
-#after_build:
+ - "%PYEXE% C:\\appveyor.py build_script"
+
before_test:
# Create and setup PostgreSQL database for the tests
diff --git a/scripts/appveyor.py b/scripts/appveyor.py
index 4ed758d..896bfc9 100755
--- a/scripts/appveyor.py
+++ b/scripts/appveyor.py
@@ -95,14 +95,11 @@ def setup_env():
def python_info():
logger.info("Python Information")
- out = out_command([py_exe(), '--version'], stderr=sp.STDOUT)
- logger.info("%s", out)
-
- out = out_command(
+ run_command([py_exe(), '--version'], stderr=sp.STDOUT)
+ run_command(
[py_exe(), '-c']
+ ["import sys; print('64bit: %s' % (sys.maxsize > 2**32))"]
)
- logger.info("%s", out)
def step_init():
@@ -131,6 +128,10 @@ def step_install():
build_libpq()
+def step_build_script():
+ build_psycopg()
+
+
def build_openssl():
top = os.path.join(base_dir(), 'openssl')
if os.path.exists(os.path.join(top, 'lib', 'libssl.lib')):
@@ -284,6 +285,33 @@ $config->{openssl} = "%s";
shutil.rmtree(os.path.join(pgbuild))
+def build_psycopg():
+ # Add PostgreSQL binaries to the path
+ setenv(
+ 'PATH',
+ os.pathsep.join(
+ [r'C:\Program Files\PostgreSQL\9.6\bin', os.environ['PATH']]
+ ),
+ )
+ os.chdir(r"C:\Project")
+
+ # Find the pg_config just built
+ path = os.pathsep.join(
+ [os.path.join(base_dir(), r'postgresql\bin'), os.environ['PATH']]
+ )
+ setenv('PATH', path)
+
+ run_command(
+ [py_exe(), "setup.py", "build_ext", "--have-ssl"]
+ + ["-l", "libpgcommon", "-l", "libpgport"]
+ + ["-L", os.path.join(base_dir(), r'openssl\lib')]
+ + ['-I', os.path.join(base_dir(), r'openssl\include')]
+ )
+ run_command([py_exe(), "setup.py", "build_py"])
+ run_command([py_exe(), "setup.py", "install"])
+ shutil.rmtree("psycopg2.egg-info")
+
+
def download(url, fn):
"""Download a file locally"""
logger.info("downloading %s", url)