Skip to content
Merged
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
6 changes: 6 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[bumpversion]
current_version = 0.1.10
commit = True
tag = True

[bumpversion:file:setup.py]
177 changes: 73 additions & 104 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,48 @@
build: &build
working_directory: /mnt/crate
steps:
- checkout
- attach_workspace:
at: "."
- restore_cache:
keys:
- cargo-v1-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}
- run:
name: Print version information
command: rustc --version; cargo --version; python -V;
- run:
name: Build 35
command: |
pip install -r requirement-dev.txt && python compile.py build
- run:
name: Test 35
command: |
cp build/lib/py_sourcemap/*.so py_sourcemap/ && \
nosetests
- run:
name: Prune the output files
command: |
for file in target/release/* target/release/.??*; do
[ -d $file -o ! -x $file ] && rm -r $file
done
- persist_to_workspace:
root: "."
paths:
- ./*

deploy: &deploy
docker:
- image: tsub/ghr:latest
working_directory: /mnt/crate
steps:
- attach_workspace:
at: "."
- run:
name: 'Deploy to Github Release'
command: |
export GIT_TAG="$(git describe --tags $(git rev-list --tags --max-count=1))"; \
ghr -u "${CIRCLE_PROJECT_USERNAME}" -r "${CIRCLE_PROJECT_REPONAME}" "${GIT_TAG}" build/lib/py_sourcemap/*.so

version: 2
jobs:
cargo_fetch:
Expand Down Expand Up @@ -25,128 +70,36 @@ jobs:
- /usr/local/cargo/registry
- /usr/local/cargo/git
build35:
<<: *build
docker:
- image: broooooklyn/rust-python:3.5
working_directory: /mnt/crate
steps:
- checkout
- attach_workspace:
at: "."
- restore_cache:
keys:
- cargo-v1-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}
- run:
name: Print version information
command: rustc --version; cargo --version
- run:
name: Build 35
command: |
python compile.py build
- run:
name: Prune the output files
command: |
for file in target/release/* target/release/.??*; do
[ -d $file -o ! -x $file ] && rm -r $file
done
- persist_to_workspace:
root: "."
paths:
- ./*

build36:
<<: *build
docker:
- image: broooooklyn/rust-python:3.6
working_directory: /mnt/crate
steps:
- checkout
- attach_workspace:
at: "."
- restore_cache:
keys:
- cargo-v1-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}
- run:
name: Print version information
command: rustc --version; cargo --version
- run:
name: Build 36
command: |
python compile.py build
- run:
name: Prune the output files
command: |
for file in target/release/* target/release/.??*; do
[ -d $file -o ! -x $file ] && rm -r $file
done
- persist_to_workspace:
root: "."
paths:
- ./*

build37:
<<: *build
docker:
- image: broooooklyn/rust-python:3.7
working_directory: /mnt/crate
steps:
- checkout
- attach_workspace:
at: "."
- restore_cache:
keys:
- cargo-v1-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}
- run:
name: Print version information
command: rustc --version; cargo --version
- run:
name: Build 37
command: |
python compile.py build
- run:
name: Prune the output files
command: |
for file in target/release/* target/release/.??*; do
[ -d $file -o ! -x $file ] && rm -r $file
done
- persist_to_workspace:
root: "."
paths:
- ./*

deploy35:
docker:
- image: tsub/ghr:latest
working_directory: /mnt/crate
steps:
- attach_workspace:
at: "."
- run:
name: 'Deploy to Github Release'
command: |
export GIT_TAG="$(git describe --tags $(git rev-list --tags --max-count=1))"; \
ghr -u "${CIRCLE_PROJECT_USERNAME}" -r "${CIRCLE_PROJECT_REPONAME}" "${GIT_TAG}" build/lib/py_sourcemap/*.so
deploy35: *deploy

deploy36:
docker:
- image: tsub/ghr:latest
working_directory: /mnt/crate
steps:
- attach_workspace:
at: "."
- run:
name: 'Deploy to Github Release'
command: |
export GIT_TAG="$(git describe --tags $(git rev-list --tags --max-count=1))"; \
ghr -u "${CIRCLE_PROJECT_USERNAME}" -r "${CIRCLE_PROJECT_REPONAME}" "${GIT_TAG}" build/lib/py_sourcemap/*.so
deploy36: *deploy

deploy37: *deploy

deploy37:
pip_deploy:
docker:
- image: tsub/ghr:latest
- image: broooooklyn/rust-python:latest
working_directory: /mnt/crate
steps:
- attach_workspace:
at: "."
- run:
name: 'Deploy to Github Release'
command: |
export GIT_TAG="$(git describe --tags $(git rev-list --tags --max-count=1))"; \
ghr -u "${CIRCLE_PROJECT_USERNAME}" -r "${CIRCLE_PROJECT_REPONAME}" "${GIT_TAG}" build/lib/py_sourcemap/*.so
command: pip install -r requirement-dev.txt && make release

nightly:
machine: true
Expand Down Expand Up @@ -182,6 +135,8 @@ workflows:
filters:
tags:
only: /.*/
branches:
only: master
- build36:
requires:
- cargo_fetch
Expand All @@ -191,6 +146,8 @@ workflows:
filters:
tags:
only: /.*/
branches:
only: master
- build37:
requires:
- cargo_fetch
Expand All @@ -200,3 +157,15 @@ workflows:
filters:
tags:
only: /.*/
branches:
only: master
- pip_deploy:
requires:
- deploy35
- deploy36
- deploy37
filters:
tags:
only: /.*/
branches:
only: master
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ build
*.so
.eggs
*.egg-info
dist

# editor related
.vscode
10 changes: 8 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,26 @@ python:
- "3.6"
- "3.7"
os: osx
osx_image: xcode9.3
cache: cargo
before_install:
- brew update
- brew install rust
- rustup default nightly

install:
- pip install -r requirements-dev.txt

script: |
python compile.py build
python compile.py build && \
cp build/lib/py_sourcemap/*.so py_sourcemap/ && \
nosetests

deploy:
provider: releases
api_key:
secure: $GITHUB_TOKEN
file: build/lib/py_sourcemap/py_sourcemap.so
file: build/lib/py_sourcemap/*.so
skip_cleanup: true
on:
tags: true
31 changes: 16 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
FROM ubuntu:16.04

ENV GHR_VERSION="0.9.0"
FROM ubuntu:18.04

ARG PYTHON_VERSION=3.6

ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=1.28.0
RUST_VERSION=nightly

RUN apt-get update && \
apt-get install software-properties-common python-software-properties -y && \
echo $PYTHON_VERSION && \
apt-get install software-properties-common -y --no-install-recommends && \
add-apt-repository ppa:deadsnakes/ppa -y && \
apt-get update && \
apt-get install python${PYTHON_VERSION} python3-pip wget git curl -y && \
apt-get install python${PYTHON_VERSION} wget build-essential git curl -y --no-install-recommends && \
apt-get upgrade -y && \
apt-get autoremove -y && \
ln -sf /usr/bin/python${PYTHON_VERSION} /usr/bin/python && \
curl -fSL -o ghr.tar.gz "https://github.com/tcnksm/ghr/releases/download/v${GHR_VERSION}/ghr_v${GHR_VERSION}_linux_amd64.tar.gz" && \
tar -xvzf ghr.tar.gz && \
mv ghr_v0.9.0_linux_amd64/ghr /usr/local/bin && \
chown root:root /usr/local/bin/ghr && \
rm -r \
ghr.tar.gz \
ghr_v0.9.0_linux_amd64
if [ $PYTHON_VERSION = '3.6' ]; \
then \
apt-get install python3-pip -y --no-install-recommends && \
ln -sf /usr/bin/pip3 /usr/bin/pip; \
else \
curl https://bootstrap.pypa.io/get-pip.py | python${PYTHON_VERSION}; \
fi && \
pip install --upgrade pip

RUN set -eux; \
dpkgArch="$(dpkg --print-architecture)"; \
Expand All @@ -44,4 +43,6 @@ RUN set -eux; \
rustup default nightly && \
rustup --version; \
cargo --version; \
rustc --version;
rustc --version; \
python -V; \
pip -V;
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2018 LeetCode

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
format:
yapf **/*.py -i

release:
python3 setup.py sdist bdist_wheel
twine upload --repository-url https://upload.pypi.org/legacy/ dist/* -u $PYPI_USERNAME -p $PYPI_PASSWORD
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# py-sourcemap

A tiny [source-map-mappings](https://github.com/fitzgen/source-map-mappings) bindings for python using [PyO3](https://github.com/PyO3/pyo3)
37 changes: 20 additions & 17 deletions compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,26 @@
from setuptools import setup

try:
from setuptools_rust import Binding, RustExtension
from setuptools_rust import Binding, RustExtension
except ImportError:
import subprocess
import subprocess

errno = subprocess.call([sys.executable, "-m", "pip", "install", "setuptools-rust"])
if errno:
print("Please install setuptools-rust package")
raise SystemExit(errno)
else:
from setuptools_rust import Binding, RustExtension
errno = subprocess.call(
[sys.executable, "-m", "pip", "install", "setuptools-rust"])
if errno:
print("Please install setuptools-rust package")
raise SystemExit(errno)
else:
from setuptools_rust import Binding, RustExtension

setup(name='py-sourcemap',
version='0.1',
rust_extensions=[RustExtension('py_sourcemap.py_sourcemap',
'Cargo.toml', binding=Binding.PyO3)],
packages=['py_sourcemap'],
setup_requires=['setuptools_rust>=0.10.2'],
# rust extensions are not zip safe, just like C-extensions.
zip_safe=False
)
setup(
name='py-sourcemap',
version='0.1',
rust_extensions=[
RustExtension(
'py_sourcemap.py_sourcemap', 'Cargo.toml', binding=Binding.PyO3)
],
packages=['py_sourcemap'],
setup_requires=['setuptools_rust>=0.10.2'],
# rust extensions are not zip safe, just like C-extensions.
zip_safe=False)
2 changes: 2 additions & 0 deletions py_sourcemap/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from .py_sourcemap import SourcemapParser

name = 'py_sourcemap'

__all__ = ["SourcemapParser"]
4 changes: 4 additions & 0 deletions requirement-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
yapf==0.23.0
twine==1.11.0
bumpversion==0.5.3
nose==1.3.7
Loading