Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pypi #130

Merged
merged 24 commits into from
Mar 25, 2022
Merged

Pypi #130

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,58 @@ jobs:
with:
name: pacparser-python-${{ matrix.python-version }}-${{ matrix.os }}-dist
path: src/pymod/pacparser-python*

- name: Build wheel non-linux
if: ${{ matrix.os != 'ubuntu-latest' }}
run: |
python -m pip install wheel
cd src/pymod && python setup.py bdist_wheel

- name: Publish package to PyPI (non-linux)
if: ${{ matrix.os != 'ubuntu-latest' }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI }}
run: |
python -m pip install twine
ls -R .
twine upload src/pymod/dist/*

build-linux-wheels:
runs-on: 'ubuntu-latest'

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set env
run: echo "PACPARSER_VERSION=$(git describe --always --tags --candidate=100)" >> $GITHUB_ENV

- name: Set up Python
uses: actions/setup-python@v3

- name: make
run: make -C src pymod

- name: Build sdist
run: cd src/pymod && python setup.py sdist

- name: Install cibuildwheel and twine
run: python -m pip install cibuildwheel twine

- name: Build wheel using cibuildwheel
run: |
cp src/spidermonkey/libjs.a src/pacparser.o src/pacparser.h src/pymod
cd src/pymod && python -m cibuildwheel --output-dir dist
env:
CIBW_BUILD: "cp{37,38,39,310}-manylinux*64"
CIBW_ENVIRONMENT: "PACPARSER_VERSION=${{ env.PACPARSER_VERSION }}"

- name: Publish package to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI }}
run: |
twine upload src/pymod/dist/*

16 changes: 13 additions & 3 deletions src/pymod/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def pacparser_version():
with open(version_file) as f:
return sanitize_version(f.read().replace('VERSION=',''))

return os.environ.get('PACPARSER_VERION', '1.0.0')
return sanitize_version(os.environ.get('PACPARSER_VERSION', '1.0.0'))


class DistCmd(distutils.cmd.Command):
Expand Down Expand Up @@ -109,7 +109,17 @@ def run(self):
def main(patched_func):
python_home = os.path.dirname(sys.executable)

extra_objects = ['../pacparser.o', '../spidermonkey/libjs.a']
extra_objects = []
obj_search_path = {
'pacparser.o': ['..', '.'],
'libjs.a': ['../spidermonkey', '.'],
}
for obj, paths in obj_search_path.items():
for path in paths:
if os.path.exists(os.path.join(path, obj)):
extra_objects.append(os.path.join(path, obj))
break

libraries = []
extra_link_args = []
if sys.platform == 'win32':
Expand All @@ -120,7 +130,7 @@ def main(patched_func):
extra_link_args = ['-static-libgcc', '-L'+python_home]

pacparser_module = Extension('_pacparser',
include_dirs = ['../spidermonkey/js/src', '..'],
include_dirs = ['..'],
sources = ['pacparser_py.c'],
libraries = libraries,
extra_link_args = extra_link_args,
Expand Down