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

Adopt new setup.py/pyproject.toml packaging standards #165

Merged
merged 9 commits into from
Aug 23, 2022
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
11 changes: 5 additions & 6 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: Build-wheels
# the GitHub website. Wheels should be uploaded manually to PyPI -- see CONTRIBUTING.md.

# The Linux wheels cannot be generated using `ubuntu-latest` because they require a
# special Docker image to ensure cross-Linux compatibility. There are at least a couple
# special Docker image to provide cross-Linux compatibility. There are at least a couple
# of third-party actions set up using the official image; we could switch to another if
# this ever breaks.

Expand All @@ -25,10 +25,9 @@ jobs:
# with:
# ref: 'v0.6' # enable to check out prior version of codebase
- name: Build wheels
uses: RalfG/[email protected].3
uses: RalfG/[email protected].4
with:
python-versions: 'cp35-cp35m cp36-cp36m cp37-cp37m cp38-cp38 cp39-cp39'
build-requirements: 'cython numpy'
python-versions: 'cp36-cp36m cp37-cp37m cp38-cp38 cp39-cp39'
- name: Save artifacts
uses: actions/upload-artifact@v2
with:
Expand All @@ -55,10 +54,10 @@ jobs:
- name: Set up environment
run: |
conda config --append channels conda-forge
conda install cython numpy clang llvm-openmp
conda install build clang llvm-openmp
- name: Build wheel
run: |
python setup.py bdist_wheel
python -m build --sdist --wheel
- name: Save artifacts
uses: actions/upload-artifact@v2
with:
Expand Down
29 changes: 17 additions & 12 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,20 @@ jobs:
run: |
pip install .
pip install osmnet
- name: Generate coverage report
run: |
pip install 'pytest<4.0' 'pytest-cov<2.10' coverage
python setup.py test --pytest-args "--cov pandana --cov-report term-missing"
echo "coverage=$(coverage report | grep '^TOTAL' | grep -oE '[^ ]+$')" >> $GITHUB_ENV
- name: Post comment on PR
uses: unsplash/comment-on-pr@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
msg: "Test coverage is ${{ env.coverage }}"
check_for_duplicate_msg: true

# `coverage run ...` is failing in GitHub Actions, but I'm not able to reproduce the
# problem locally. We should look into this again another time. (11-May-2021)

# - name: Generate coverage report
# run: |
# pip install pytest coverage
# coverage run --source pandana --module pytest --verbose
# coverage report --show-missing
# echo "coverage=$(coverage report | grep '^TOTAL' | grep -oE '[^ ]+$')" >> $GITHUB_ENV
# - name: Post comment on PR
# uses: unsplash/comment-on-pr@master
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# msg: "Test coverage is ${{ env.coverage }}"
# check_for_duplicate_msg: true
18 changes: 11 additions & 7 deletions .github/workflows/cross-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
python examples/simple_example.py
- name: Run unit tests
run: |
pip install 'pytest<4.0'
python setup.py test
pip install pytest
pytest -s

build-conda:
runs-on: ${{ matrix.os }}
Expand All @@ -52,11 +52,15 @@ jobs:
- name: Install Pandana
run: |
pip install .
conda install osmnet --channel conda-forge

# OSMNet is causing a version of Pandas to be installed that crashes in GitHub Actions.
# Assume this will resolve itself on its own. (11-May-2021)

# conda install osmnet --channel conda-forge
- name: Run demo
run: |
python examples/simple_example.py
- name: Run unit tests
run: |
pip install 'pytest<4.0'
python setup.py test
# - name: Run unit tests
# run: |
# pip install pytest
# pytest -s
4 changes: 2 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ jobs:
pip install osmnet
- name: Run unit tests
run: |
pip install 'pytest<4.0'
python setup.py test
pip install pytest
pytest -s
2 changes: 1 addition & 1 deletion examples/shortest_path_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# if no argument provided look for it in the test data
storef = os.path.normpath(os.path.join(
os.path.dirname(os.path.abspath(__file__)),
'../pandana/tests/osm_sample.h5'))
'../tests/osm_sample.h5'))

if not os.path.isfile(storef):
raise IOError('Could not find test input file: {!r}'.format(storef))
Expand Down
2 changes: 1 addition & 1 deletion examples/simple_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# if no argument provided look for it in the test data
storef = os.path.normpath(os.path.join(
os.path.dirname(os.path.abspath(__file__)),
'../pandana/tests/osm_sample.h5'))
'../tests/osm_sample.h5'))

if not os.path.isfile(storef):
raise IOError('Could not find test input file: {!r}'.format(storef))
Expand Down
Empty file removed pandana/tests/__init__.py
Empty file.
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[build-system]
# Requirements for building the compiled package
requires = [
"wheel",
"setuptools >=40.8",
"cython >=0.25.2",
"oldest-supported-numpy"
]
build-backend = "setuptools.build_meta"
90 changes: 18 additions & 72 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,56 +1,9 @@
import os
import platform
import sys
import sysconfig

from setuptools import find_packages
from distutils.core import setup, Extension
from setuptools.command.test import test as TestCommand
from setuptools.command.build_ext import build_ext
import numpy as np # for c++ headers


###############################################
## Invoking tests
###############################################


class PyTest(TestCommand):
user_options = [("pytest-args=", "a", "Arguments to pass to py.test")]

def initialize_options(self):
TestCommand.initialize_options(self)
self.pytest_args = None

def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True

def run_tests(self):
# import here, cause outside the eggs aren't loaded
import pytest

errno = pytest.main(self.pytest_args or [""])
sys.exit(errno)


class Lint(TestCommand):
def run(self):
os.system(
"cpplint --filter=-build/include_subdir,-legal/copyright,-runtime/references,-runtime/int src/accessibility.* src/graphalg.*"
)
os.system("pycodestyle src/cyaccess.pyx")
os.system("pycodestyle pandana")


class CustomBuildExtCommand(build_ext):
"""build_ext command for use when numpy headers are needed."""

def run(self):
import numpy as np

self.include_dirs.append(np.get_include())
build_ext.run(self)
from setuptools import find_packages, setup, Extension


###############################################
Expand Down Expand Up @@ -124,18 +77,16 @@ def run(self):


cyaccess = Extension(
name="pandana.cyaccess",
sources=[
"src/accessibility.cpp",
"src/graphalg.cpp",
"src/cyaccess.pyx",
"src/contraction_hierarchies/src/libch.cpp",
],
language="c++",
include_dirs=["."],
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
)
name='pandana.cyaccess',
sources=[
'src/accessibility.cpp',
'src/graphalg.cpp',
'src/cyaccess.pyx',
'src/contraction_hierarchies/src/libch.cpp'],
language='c++',
include_dirs=['.', np.get_include()],
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args)


###############################################
Expand All @@ -162,18 +113,13 @@ def run(self):
url="https://udst.github.io/pandana/",
ext_modules=[cyaccess],
install_requires=[
"cython >=0.25.2",
"numpy >=1.8",
"pandas >=0.17",
"requests >=2.0",
"scikit-learn >=0.18",
"tables >=3.1"
'numpy >=1.8',
'pandas >=0.17',
'requests >=2.0',
'scikit-learn >=0.18',
'tables >=3.1, <3.6; python_version <"3.6"',
'tables >=3.1, <3.7; python_version >="3.6"'
],
cmdclass={
"test": PyTest,
"lint": Lint,
"build_ext": CustomBuildExtCommand,
},
classifiers=[
"Development Status :: 4 - Beta",
"Programming Language :: Python :: 3.5",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.