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

Conversation

smmaurer
Copy link
Member

@smmaurer smmaurer commented May 7, 2021

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

  • To run tests: pytest -s
  • To install Pandana from source: pip install -e . (don't run setup.py directly)
  • To build source and binary distributions: pip install build, then build --sdist --wheel

Before merging

  • update all documentation referring to test, build, and installation procedures
  • disable building wheels with each push
  • iterate version number?
  • drop redundant requirements files?

@smmaurer smmaurer requested a review from sablanchard May 7, 2021 18:30
@smmaurer smmaurer merged commit da0965f into dev Aug 23, 2022
@smmaurer smmaurer deleted the pyproject.toml branch August 23, 2022 22:53
@smmaurer smmaurer mentioned this pull request Jul 25, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants