Skip to content

Commit 22f9198

Browse files
authored
Fix conda package upload (#59)
* Update build scripts * Update readme * Formatting
1 parent f414c9e commit 22f9198

File tree

7 files changed

+41
-28
lines changed

7 files changed

+41
-28
lines changed

.github/workflows/publish.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131

3232
anaconda:
3333
runs-on: ubuntu-latest
34+
needs: pypi
3435
steps:
3536
- uses: actions/checkout@v3
3637
- name: Set up Python
@@ -43,19 +44,23 @@ jobs:
4344
echo $CONDA/bin >> $GITHUB_PATH
4445
- name: Install dependencies
4546
run: |
47+
sudo apt-get update && sudo apt-get install openssl curl
4648
conda install -y anaconda-client conda-build conda-verify
4749
- name: Publish distribution to Anaconda
4850
env:
4951
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
5052
run: |
51-
cd ./conda # go to build dir
53+
mkdir ./conda-build # create the artifact dir
5254
53-
# Build for Linux
54-
conda build --output-folder ./conda_build . .
55+
# Get the version of the library
56+
export TORCHHD_VERSION=$(python -c "with open('torchhd/version.py') as f: exec(f.read()); print(__version__)")
5557
56-
# Convert to other platforms: OSX, WIN
57-
conda convert --platform all ./conda_build/linux-64/*.tar.bz2
58+
# Calculate the HASH of the PyPi package
59+
curl -L --output ./conda-build/torchhd.tar.gz "https://pypi.io/packages/source/t/torch-hd/torch-hd-${TORCHHD_VERSION}.tar.gz"
60+
export TORCHHD_HASH=$(openssl sha256 ./conda-build/torchhd.tar.gz | awk '{print $2}')
5861
59-
anaconda upload --label main ./conda_build/osx-64/*.tar.bz2
60-
anaconda upload --label main ./conda_build/linux-64/*.tar.bz2
61-
anaconda upload --label main ./conda_build/win-64/*.tar.bz2
62+
# Build for noarch platform
63+
conda-build -c pytorch --output-folder ./conda-build ./conda
64+
65+
# Upload noarch version of torchhd to anaconda
66+
anaconda upload -u torchhd --label main ./conda-build/*/*.tar.bz2

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ Torchhd is a Python library for Hyperdimensional Computing.
2121

2222
## Installation
2323

24-
Torchhd is hosted on PyPi, use the following command to install:
24+
Torchhd is hosted on PyPi and Anaconda, use one of the following commands to install:
2525

2626
```bash
2727
pip install torch-hd
2828
```
2929

30-
<!-- ```bash
30+
```bash
3131
conda install -c torchhd torchhd
32-
``` -->
32+
```
3333

3434
## Documentation
3535

@@ -105,7 +105,7 @@ To build the documentation locally, use `pip install -r docs/requirements.txt` t
105105
### Creating a New Release
106106

107107
- A GitHub release triggers a GitHub action that builds the library and publishes it to PyPi and Conda in addition to the documentation website.
108-
- Before creating a new GitHub release, increment the version number in [setup.py](https://github.com/hyperdimensional-computing/torchhd/blob/main/setup.py) using [semantic versioning](https://semver.org).
108+
- Before creating a new GitHub release, increment the version number in [version.py](https://github.com/hyperdimensional-computing/torchhd/blob/main/torchhd/version.py) using [semantic versioning](https://semver.org).
109109
- When creating a new GitHub release, set the tag according to [PEP 440](https://peps.python.org/pep-0440/), e.g., v1.5.2, and provide a clear description of the changes. You can use GitHub's "auto-generate release notes" button. Look at previous releases for examples.
110110

111111
### License

conda/conda_build_config.yaml

Lines changed: 0 additions & 6 deletions
This file was deleted.

conda/meta.yaml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
{% set data = load_setup_py_data() %}
1+
{% set name = "torch-hd" %}
22

33
package:
44
name: torchhd
5-
version: {{ data['version'] }}
5+
version: {{ TORCHHD_VERSION }}
66

77
source:
8-
path: ..
9-
git_url: https://github.com/hyperdimensional-computing/torchhd
8+
url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ TORCHHD_VERSION }}.tar.gz
9+
sha256: {{ TORCHHD_HASH }}
1010

1111
build:
12+
noarch: generic
1213
number: 0
13-
script: python setup.py install --single-version-externally-managed --record=record.txt
14+
script: "{{ PYTHON }} -m pip install . --no-deps --ignore-installed -vv "
1415

1516
requirements:
1617
host:
1718
- pip
1819
- python>=3.6
19-
2020
run:
2121
- python>=3.6
2222
- pytorch
@@ -26,9 +26,15 @@ requirements:
2626
test:
2727
imports:
2828
- torchhd
29+
- torchhd.functional
30+
- torchhd.embeddings
31+
- torchhd.structures
2932
- torchhd.datasets
3033

3134
about:
32-
home: {{ data['url'] }}
33-
license: {{ data['license'] }}
34-
summary: {{ data['description'] }}
35+
home: https://github.com/hyperdimensional-computing/torchhd
36+
license: MIT
37+
license_file: LICENSE
38+
summary: Torchhd is a Python library for Hyperdimensional Computing
39+
dev_url: https://github.com/hyperdimensional-computing/torchhd
40+
doc_url: https://torchhd.readthedocs.io

setup.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@
55
"""
66
from setuptools import setup, find_packages
77

8+
# Read the version without importing any dependencies
9+
version = {}
10+
with open("torchhd/version.py") as f:
11+
exec(f.read(), version)
12+
813
setup(
914
name="torch-hd", # use torch-hd on PyPi to install torchhd, torchhd is too similar according to PyPi
10-
version="2.2.2",
15+
version=version["__version__"],
1116
description="Torchhd is a Python library for Hyperdimensional Computing",
1217
long_description=open("README.md").read(),
1318
long_description_content_type="text/markdown",

torchhd/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
permute,
1414
)
1515

16+
from torchhd.version import __version__
17+
1618
__all__ = [
1719
"functional",
1820
"embeddings",

torchhd/version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "2.2.2"

0 commit comments

Comments
 (0)