Browse Source

More documentation on all operations

PYADPT-100
heck 5 years ago
parent
commit
c86c95bd77
  1. 41
      Makefile
  2. 4
      Makefile.conf
  3. 50
      docs/source/install.rst
  4. 6
      src/pEp/__init__.py

41
Makefile

@ -1,7 +1,6 @@
include Makefile.conf include Makefile.conf
.PHONY: all dist dist-egg dist-whl install install-prefix install-sys compile clean devenv envtest docs clean-docs .PHONY: all dist dist-egg dist-whl install install-prefix install-sys compile clean devenv envtest docs clean-docs test
all: dist all: dist
# Build # Build
@ -33,13 +32,6 @@ install: compile
install-user: compile install-user: compile
pip3 install . --user pip3 install . --user
clean: clean-docs
rm -rf $(BUILD_DIR)
rm -rf $(DIST_DIR)
rm -rf $(PYTHON_ARTIFACTS)
rm -rf $(VERSION_FILE)
rm -rf $(BUILD_INPLACE)
# Envrionment # Envrionment
# =========== # ===========
@ -47,20 +39,47 @@ clean: clean-docs
# already set for the prefix specified in local.conf # already set for the prefix specified in local.conf
# Only activates venv if already existing # Only activates venv if already existing
venv: venv:
python3 -m venv _venv python3 -m venv $(VENV_DIR)
LD_LIBRARY_PATH=$(PREFIX)/lib \ LD_LIBRARY_PATH=$(PREFIX)/lib \
DYLD_LIBRARY_PATH=$(PREFIX)/lib \ DYLD_LIBRARY_PATH=$(PREFIX)/lib \
bash --rcfile _venv/bin/activate bash --rcfile $(VENV_DIR)/bin/activate
# Tests if the current environment is able to load the pEp module # Tests if the current environment is able to load the pEp module
envtest: envtest:
python3 -c 'import pEp' python3 -c 'import pEp'
# Test
# ====
# Use these targets only in venv created with 'make venv'
install-test: compile
pip3 install .[test]
test: install-test
pytest
# Development
develop: compile
pip install -e .
# Documentation # Documentation
# ============= # =============
docs: docs:
make html -C docs/ make html -C docs/
# Housekeeping
# ============
clean-all: clean
rm -rf $(VENV_DIR)
clean: clean-docs
rm -rf $(BUILD_DIR)
rm -rf $(DIST_DIR)
rm -rf $(PYTHON_ARTIFACTS)
rm -rf $(VERSION_FILE)
rm -rf $(BUILD_INPLACE)
clean-docs: clean-docs:
make clean -C docs/ make clean -C docs/

4
Makefile.conf

@ -7,8 +7,8 @@ VERSION_FILE = ./src/pEp/__version__.py
BUILD_INPLACE = ./src/pEp/_pEp.cpython-38-darwin.so BUILD_INPLACE = ./src/pEp/_pEp.cpython-38-darwin.so
PYTHON_ARTIFACTS += ./.eggs PYTHON_ARTIFACTS += ./.eggs
PYTHON_ARTIFACTS += ./src/pEp.egg-info PYTHON_ARTIFACTS += ./src/pEp.egg-info
PYTHON_ARTIFACTS += ./.pytest_cache
VENV_DIR = ./_venv
# Build config Defaults # Build config Defaults
DEBUG=0 DEBUG=0

50
docs/source/install.rst

@ -30,7 +30,6 @@ all the build options. You can use this as a template.
``cp local.conf.example local.conf`` ``cp local.conf.example local.conf``
If you have pEp-base installed under a custom prefix (e.g. /home/foo/local) it is important If you have pEp-base installed under a custom prefix (e.g. /home/foo/local) it is important
that you specify "PREFIX". that you specify "PREFIX".
@ -40,29 +39,60 @@ To build the module just type:
``make`` ``make``
This will compile the C/C++ parts of the module and create the python packages in the .egg and .wheel format
in the dist/ dir.
Installation Installation
------------ ------------
You can install this adapter in the in the following ways: You can install the module in the in the following ways:
To install the extension module system wide or into a venv: To install the extension module system wide or into a venv:
``make install`` ``make install``
To install the extension module into you home dir: To install the extension module into you home dir:
``make install-user`` ``make install-user``
If you're working on different Python projects, it's recommended to use Virtualenv
`virtualenv <https://virtualenv.pypa.io/en/stable/>`_ to have different ----------
libraries versions. We recommend using a venv to work on/with the pEpPythonAdapter.
There is a convenience make target that will create and activate a venv that already has the LD_LIBRARY_PATH
or DYLD_LIBRARY_PATH set according to your ```local.conf``.
If the venv is not existing yet it will be created and activated.
If the venv already exists it will only be activated.
``make venv``
After that, to install the pEp module into the venv, do:
``make install``
Test
----
To run the whole testsuite you need to create/activate the venv, and then invoke the make target 'test'.
You can do this from a clean clone of the repo, no prior actions required, the whole module and all dependencies
will be compiled and installed into the venv.
``make venv``
``make test``
Module Development
------------------
To develop on the module itself, first of all create and activate a venv:
``make venv``
Then, in the venv install the module in development mode.
If you're working in a virtualenv you can also install the package with ``make develop``
``pip install .``
To install the package in "develop mode", run ``python setup.py develop`` While developing there are two levels of changes. Changes to the python part of the module (pEp), and
or ``pip install -e .`` changes to the C/C++ part of the module (_pEp). If you change just python code, the changes are effective immediately.
If you do changes to the C/C++ part you need to issue ``make develop`` again, to recompile the extension and install
the new binary (.so/.dylib) of the module into the venv.
Docker Docker

6
src/pEp/__init__.py

@ -30,12 +30,6 @@ from ._pEp import *
# with an underscore (of _pEp), but we dont want to import them into this module # with an underscore (of _pEp), but we dont want to import them into this module
import pEp._pEp import pEp._pEp
# TODO: Commented out until problems solved
# try:
# __version__ = get_distribution(__name__).version
# except DistributionNotFound:
# print("Package is not installed.")
# Executed on module import # Executed on module import
def init(): def init():
print(init, "called") print(init, "called")

Loading…
Cancel
Save