From fbf9839a91b5e2977fadccb6fc03df8048581ad8 Mon Sep 17 00:00:00 2001 From: Gaetan Perrot Date: Tue, 13 Aug 2024 18:18:22 +0900 Subject: [PATCH] test pypi --- ...thon.yml => build-test-publish-python.yml} | 33 ++++++++++++++++++- libcsp_py3/__init__.py | 1 + manifest.in | 2 ++ pyproject.toml | 3 ++ setup.py | 25 ++++++++++++++ 5 files changed, 63 insertions(+), 1 deletion(-) rename .github/workflows/{build-test-python.yml => build-test-publish-python.yml} (56%) create mode 100644 libcsp_py3/__init__.py create mode 100644 manifest.in create mode 100644 pyproject.toml create mode 100644 setup.py diff --git a/.github/workflows/build-test-python.yml b/.github/workflows/build-test-publish-python.yml similarity index 56% rename from .github/workflows/build-test-python.yml rename to .github/workflows/build-test-publish-python.yml index bf9e647dd..1f315f62c 100644 --- a/.github/workflows/build-test-python.yml +++ b/.github/workflows/build-test-publish-python.yml @@ -38,4 +38,35 @@ jobs: build/examples/zmqproxy & LD_LIBRARY_PATH=buildBinding PYTHONPATH=buildBinding python3 examples/python_bindings_example_server.py & LD_LIBRARY_PATH=buildBinding PYTHONPATH=buildBinding python3 examples/python_bindings_example_client.py -z localhost -s 27 -a 2 - pkill zmqproxy \ No newline at end of file + pkill zmqproxy + + - name: Prepare Python binding for packaging + run: | + mkdir -p libcsp_py3/ + cp buildBinding/libcsp_py3*.so libcsp_py3/libcsp_py3-${{ matrix.os }}.so + ls -l libcsp_py3 + ls -l + + - name: Set up Python environment + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Create and activate virtual environment + run: | + python -m venv venv + source venv/bin/activate + python -m pip install --upgrade pip + python -m pip install setuptools wheel + + - name: Build the Python package + run: | + source venv/bin/activate + python3 setup.py sdist bdist_wheel + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.PYPI_API_TOKEN }} + repository_url: https://test.pypi.org/legacy/ + if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') \ No newline at end of file diff --git a/libcsp_py3/__init__.py b/libcsp_py3/__init__.py new file mode 100644 index 000000000..809ee9ae3 --- /dev/null +++ b/libcsp_py3/__init__.py @@ -0,0 +1 @@ +from .libcsp_py3 import * \ No newline at end of file diff --git a/manifest.in b/manifest.in new file mode 100644 index 000000000..04f196ac7 --- /dev/null +++ b/manifest.in @@ -0,0 +1,2 @@ +include README.md +include LICENSE diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..8fe2f47af --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools>=42", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py new file mode 100644 index 000000000..54611c661 --- /dev/null +++ b/setup.py @@ -0,0 +1,25 @@ +from setuptools import setup, find_packages +from setuptools.extension import Extension + +setup( + name='csp_moonlight', + version='2.0.0', + description='CSP Python bindings', + long_description=open('README.md').read(), + long_description_content_type='text/markdown', + license_text=open('LICENSE').read(), + license_text_content_type='text/markdown', + author='moonlight83340', + author_email='gaetan.perrot@spacecubics.com', + url='https://github.com/moonlight83340/libcsp', + packages=find_packages('libcsp_py3'), + package_dir={'': 'libcsp_py3'}, + package_data={'libcsp_py3': ['libcsp_py3*.so']}, + classifiers=[ + 'Programming Language :: Python :: 3', + 'License :: OSI Approved :: MIT License', + 'Operating System :: POSIX :: Linux', + ], + python_requires='>=3.5', +) +