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

Demo for setuptools / pip-ready packaging #29

Closed
wants to merge 8 commits into from

Conversation

jonathansick
Copy link
Member

@jonathansick jonathansick commented Oct 28, 2020

The purpose of this experimental PR is to explore how the packaging for sphgeom might be modified so that third-party packages can consume it via pip (and possibly even be distributed via PyPI and conda-forge in the future). The related ticket is DM-27354.

The main change is that the build dependencies are installed using a pyproject.toml (using the PEP 517 mechanism). This replaces the use of a requirements.txt file for installing setuptools_cpp and other dependencies, and which isn't really a solution for a pip-installable package.

I also introduced a tox-based build to help isolate builds and tests from the development environment.

At this point, it seems that the extensions are compiled successfully. Unfortunately, the extensions aren't importable. I don't know why yet. It works now that I'm setting packages and package_dir correctly for the last namespace package layout.

This adds a pyproject.toml file. This lets us specify Python
dependencies that are needed to build the package (before setup.py is
run). This replaces the previous approach of using "setup_requires"
dependencies which are only installed *after* the setup function is run,
which is too late in this case (setup_requires is intended more for
setuptools plugins that integrate with a setuptools hook).

Since setup.py is integral here, I've also moved all packaging-related
content out of setup.cfg to setup.py to simplify matters. This may not
be necessary, and its possible that we can have packaging config in both
the setup.cfg and setup.py, but I wanted to avoid this opportunity for
confusion for now.
The advantage of tox here is that it sets up a clean environment for
building and testing the package that doesn't depend on the development
environment. If sphgeom can be built and tested in this environment, it
should be buildable in general.
This does two things. Firstly, it adopts tox for running the build and
test, which is beneficial because it makes CI similar to the development
testing set up.

Second, it removes the artificial crutch of the requirements.txt, which
can't be used if this package is expected to be installed by downstream
packages using pip alone.
See if this allows the include files to be included when building.
This replaces setuptools_cpp with a pybind11-based compilation based on
https://github.com/pybind/python_example/blob/master/setup.py

This change still doesn't solve the issue of not being able to import
the "built" modules.
These should work with the lsst package layout.
This moves all packaging configuration and metadata back to setup.cfg,
leaving setup.py only for driving the pybind11 configuration and
installing the version module.

There are a couple improvements to the previous setup.cfg:

- long_description is now set in the setup.cfg file.
- license is set only through the classifiers, which is recommended when
  using a standard license.
- stopped using tests_require and instead created a "test" extra because
  "tests_require" is deprecated.
@jonathansick
Copy link
Member Author

Superseded by #30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant