Build psycopg from Python

This commit is contained in:
Daniele Varrazzo 2019-04-15 02:07:03 +01:00
parent c875197432
commit 169ce22228
2 changed files with 37 additions and 15 deletions

View File

@ -82,23 +82,17 @@ init:
# Repository gets cloned, Cache is restored
install:
- "%PYEXE% C:\\appveyor.py install"
# PostgreSQL server starts now
build: off
#before_build:
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
- "%PYEXE% C:\\appveyor.py build_script"
#after_build:
before_test:
# Create and setup PostgreSQL database for the tests

View File

@ -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)