UDST / pandana

Pandas Network Analysis by UrbanSim: fast accessibility metrics and shortest paths, using contraction hierarchies :world_map:
http://udst.github.io/pandana
GNU Affero General Public License v3.0
385 stars 84 forks source link

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

Closed smmaurer closed 2 years ago

smmaurer commented 3 years ago

Python packaging standards have evolved in recent years. This PR creates a pyproject.toml file to specify Pandana's build-time requirements, and streamlines setup.py. This was prompted in part by issue #164.

As a result of these updates, the appropriate commands for running unit tests, installing Pandana from source, and building installers for PyPI will change. Read on for details.

Build requirements now in pyproject.toml

Python projects did not used to have a way to specify build-time requirements that are distinct from runtime requirements. This has always caused headaches for Pandana, which requires cython and numpy to be present for compilation. PEP 517/518 solves this with the new pyproject.toml standard.

Build tools (like pip or build) now look in here, create a temporary build environment, compile Pandana, and then install it in the parent environment along with its runtime requirements. This makes installation from source more consistent and reliable.

pyproject.toml can ensure support for an appropriate range of NumPy versions, which resolves issue #164.

Updating setup.py

Cython is only a build-time requirement, so it's now removed from the requirements in setup.py.

New packaging standards discourage arbitrary code in setup.py, so I'm removing the sections for linting, running tests, and CustomBuildExtCommand, which are not really needed.

Updating tests

When I tried to run the tests with a stand-alone command, it raised an error about the test scripts being in /pandana/tests/ rather than the now-standard /tests/. I moved them, this fixed it, and it also resolved the problem where we needed to cap pytest at <4.0.

New commands

Before merging