pgsql-io / multicorn2

http://multicorn2.org
Other
73 stars 16 forks source link

Use a static version of setup.py rather than one which is edited to include the version number #10

Closed ShaheedHaque closed 2 years ago

ShaheedHaque commented 2 years ago

This facilitates "pip install .", and so makes the package easier to use.

Resolves #9.

ShaheedHaque commented 2 years ago

I should say that I am not a packaging expert, so would welcome feedback. However, it seems to work for me.

luss commented 2 years ago

I'm also not a Pypi packaging expert, but, we defintely should work to get Multicorn2 up there.

On Mon, May 16, 2022 at 11:43 AM ShaheedHaque @.***> wrote:

I should say that I am not a packaging expert, so would welcome feedback. However, it seems to work for me.

— Reply to this email directly, view it on GitHub https://github.com/pgsql-io/multicorn2/pull/10#issuecomment-1127834562, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMWOHWWNKX4Y3MSZM6VY3LVKJUKTANCNFSM5WB5O2FQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

ShaheedHaque commented 2 years ago

In particular, I tried adding a custom get_version command to setup.py, and then to use that from the Makefile so there is exactly one place where the version is fetched, but my Make knowledge seems to have rotted badly and I struggled to get a portable definition of $(PYTHON) where it was needed to set EXTVERSION.

In case this is of interest, this is roughly what I tried...

First, add a custom command to setup.py:

from setuptools import ..., Command

class GetVersion(Command):
    description = 'Get version'
    user_options = []

    def initialize_options(self):
        pass

    def finalize_options(self):
        pass

    def run(self):
        print(get_version())

Then invoke the new custom command in the Makefile, replacing

EXTVERSION   = $(shell grep default_version $(srcdir)/$(EXTENSION).control | sed -e "s/default_version[[:space:]]*=[[:space:]]*'\([^']*\)'/\1/")

with something like

EXTVERSION   = $(shell python3 $(srcdir)/setup.py -q get_version)

The problem is that one cannot replace the hardcoded python3 with $(PYTHON). From what I remember, that would need major surgery to the Makefile.