Specify package version just once?

0 views
Skip to first unread message

Skip Montanaro

unread,
Jan 9, 2017, 1:28:25 PM1/9/17
to conda - Public
I'm working on my first Conda package. It was for code which didn't already have a setup.py script, so I wound up creating both setup.py and meta.yaml, each of which contains the same version number. I am at version 0.0.6 right now, and have already forgotten to update one or the other a couple times. I'd really like to avoid DRY. I read the documentation about inheriting environment variables and tried exporting PKG_VERSION from my build.sh script. I also tried creating __conda_version__.txt from build.sh before setup.py was run. Nothing seems to work. I either wind up with an empty version number in the BUILD START line (which I presume causes later problems), or PKG_VERSION or __conda_version__.txt are missing somewhere along the way and I get tracebacks of one sort or another.

My directory structure basically looks like this:

  .../top/
        setup.py
        conda/
            meta.yaml
            build.sh
        src/
            ... actual Python code ...

I executed "conda build conda" from the .../top directory. Have I got things structured incorrectly?

I think my recipe needs some recipe help...

Thx,

Skip Montanaro

Skip Montanaro

unread,
Jan 9, 2017, 1:48:21 PM1/9/17
to conda - Public


On Monday, January 9, 2017 at 12:28:25 PM UTC-6, Skip Montanaro wrote:
.... I'd really like to avoid DRY....

Sorry, scratch "avoid"...
 

Chris Barker

unread,
Jan 9, 2017, 7:38:55 PM1/9/17
to Skip Montanaro, conda - Public
or scratch the "D" -- avoid RY.... :-)

this is a challenge, conda was designed originally to build packages that might be any number of different languages, building schemes, etc. So _usually_ the conda recipe is maintained totally separately from the package itself.

So most of us update a version number in the meta.yaml -- and it then goes and download, etc the right package version. (BTW, are you using templating in the meta.yaml to by DRY in there, at least?)

In addition, meta.yaml is declarative -- so hard to add custom logic.

So I would consider one of:

* if your conda recipe is in your repo alongside your setuup.py (which is looks like it is) you could have setup.py go in an pull the version number from the meta.yaml file. (of course, it would need to hack it into the packages code, too....

* have a higher-level script that "builds" the package -- it could pull a version number from some other declaritive place (I like the packages __init__.py file as the definitive source), and put it in the meta.yaml, and maybe the setup.py, or....

so you wouldn't run conda build directly at all -- you'd run your own build script that would configure everything, and then run conda-build

I wonder if versionear could help here?


I don't know that it does meta.yaml out of the box, but it could probably be extended.

-CHB



Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris....@noaa.gov

Michael Sarahan

unread,
Jan 9, 2017, 8:02:31 PM1/9/17
to Chris Barker, Skip Montanaro, conda - Public
Conda-build itself is an example of what you're trying to do, I think.  It uses git to store tag information, then both versioneer and meta.yaml draw from git.


HTH,
Michael

--
You received this message because you are subscribed to the Google Groups "conda - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to conda+un...@continuum.io.
To post to this group, send email to co...@continuum.io.
Visit this group at https://groups.google.com/a/continuum.io/group/conda/.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/conda/CALGmxEJWXz8Y3OKm-WWueH_ci%2BnV5NoJA2J71wmzytnBiUjhxQ%40mail.gmail.com.

Skip Montanaro

unread,
Jan 10, 2017, 6:43:12 AM1/10/17
to Chris Barker, conda - Public
On Mon, Jan 9, 2017 at 6:38 PM, Chris Barker <chris....@noaa.gov> wrote:
have a higher-level script that "builds" the package

Thanks, this seems the easiest. I'm building everything using Make anyway. One more command in the action shouldn't cause too much heartburn.

Skip

David Hoese

unread,
Jan 10, 2017, 2:21:57 PM1/10/17
to conda - Public, chris....@noaa.gov
I might be missing something, but you can `load_setup_py_data` in your meta.yaml to pull the version from the setup.py file. Put this at the top of your meta.yaml:

{% set data = load_setup_py_data() %}

Then as long as your path to the source is correct you can specify your version by doing:

version: {{ data.get('version') }}

Hope this helps.

Dave

Michael Sarahan

unread,
Jan 10, 2017, 2:26:14 PM1/10/17
to David Hoese, conda - Public, Chris Barker - NOAA Federal
David,

That's another great, fully-supported way.  The only unsupported way at this point is the use of __conda_version__.txt.  That has been deprecated since the 2.0 release, and will be removed in the 3.0 release.

Thanks for chiming in.
Michael

--
You received this message because you are subscribed to the Google Groups "conda - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to conda+un...@continuum.io.
To post to this group, send email to co...@continuum.io.
Visit this group at https://groups.google.com/a/continuum.io/group/conda/.

Skip Montanaro

unread,
Jan 10, 2017, 3:04:30 PM1/10/17
to Michael Sarahan, David Hoese, conda - Public, Chris Barker - NOAA Federal

On Tue, Jan 10, 2017 at 1:25 PM, Michael Sarahan <msar...@gmail.com> wrote:
That's another great, fully-supported way.  The only unsupported way at this point is the use of __conda_version__.txt.  That has been deprecated since the 2.0 release, and will be removed in the 3.0 release.

Sorry, version 3.0 of what? Conda is already at 4.2.something.

Skip

Michael Sarahan

unread,
Jan 10, 2017, 3:08:38 PM1/10/17
to Skip Montanaro, David Hoese, conda - Public, Chris Barker - NOAA Federal
conda-build

Skip Montanaro

unread,
Jan 10, 2017, 3:42:29 PM1/10/17
to David Hoese, conda - Public, Chris Barker
Thanks. Wasn't aware there was any templating going on.

S

On Tue, Jan 10, 2017 at 1:21 PM, David Hoese <dho...@gmail.com> wrote:

--
Reply all
Reply to author
Forward
0 new messages