Skip to content

Commit

Permalink
do not use the whl file, patch version
Browse files Browse the repository at this point in the history
  • Loading branch information
lorepirri committed Nov 4, 2024
1 parent c390ad0 commit 99ca078
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 13 deletions.
25 changes: 12 additions & 13 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,21 @@ package:
version: {{ version }}

source:
- url: https://pypi.io/packages/py3/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}-py3-none-any.whl
sha256: 01473c225231927d2ad718351f78ebf7cffe6af3bed464c4f1ba1ef0f7cdda27
# use github raw file for license file (not included in the wheel file)
- url: https://raw.githubusercontent.com/Lyken17/pytorch-OpCounter/{{ commit_id }}/LICENSE
sha256: 36f577ad288f1beae8188b6ec09808eaed278c08b8284bacc694bb56ffbf3dfc
# use github archive release for tests
- url: https://github.com/Lyken17/pytorch-OpCounter/archive/{{ commit_id }}.tar.gz
sha256: cbda9dc83ad9b78a9fbc8d89f8f1fb1da8ca284b39faab3e9ed697fb2bee909f
folder: gh_src
# use github archive release for tests, LICENSE, and because there is no sdist on PyPi
url: https://github.com/Lyken17/pytorch-OpCounter/archive/{{ commit_id }}.tar.gz
sha256: cbda9dc83ad9b78a9fbc8d89f8f1fb1da8ca284b39faab3e9ed697fb2bee909f
patches:
- patches/0001-use-conda-build-version-for-pkg.patch

build:
number: 0
# install the wheel,because the sdist not available
script: {{ PYTHON }} -m pip install ./{{ name }}-{{ version }}-py3-none-any.whl -vv --no-deps --no-build-isolation
skip: True # [py<38]
script: {{ PYTHON }} -m pip install . -vv --no-deps --no-build-isolation

requirements:
build:
- patch # [not win]
- m2-patch # [win]
host:
- python
- pip
Expand All @@ -40,10 +38,11 @@ test:
- pip
- pytest
source_files:
- gh_src/tests
- tests
commands:
- pip check
- cd gh_src
# check that pip gets the correct version
- python -c "from importlib.metadata import version; assert(version('{{ name }}')=='{{ version }}')"
- pytest tests

about:
Expand Down
43 changes: 43 additions & 0 deletions recipe/patches/0001-use-conda-build-version-for-pkg.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
From bd8bdee45c2584f3633e2534979657f659546e9f Mon Sep 17 00:00:00 2001
From: Lorenzo Pirritano <[email protected]>
Date: Mon, 4 Nov 2024 14:22:12 +0100
Subject: [PATCH] use conda build version for pkg

The version is generated with the timestamp as suffix each time
setup.py is run (every time we build the package).

With this patch we override the package version to the conda build
one (from the environment variable PKG_VERSION).

---
setup.py | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/setup.py b/setup.py
index 100bd16..d14cace 100644
--- a/setup.py
+++ b/setup.py
@@ -8,8 +8,8 @@ from setuptools.command.install import install

readme = open("README.md").read()

-fp = open("thop/__version__.py", "r").read()
-VERSION = eval(fp.strip().split()[-1])
+# fp = open("thop/__version__.py", "r").read()
+# VERSION = eval(fp.strip().split()[-1])

requirements = [
"torch",
@@ -18,7 +18,8 @@ requirements = [
# import subprocess
# commit_hash = subprocess.check_output("git rev-parse HEAD", shell=True).decode('UTF-8').rstrip()
# VERSION += "_" + str(int(commit_hash, 16))[:8]
-VERSION += "_" + datetime.datetime.now().strftime("%Y%m%d%H%M")[2:]
+# VERSION += "_" + datetime.datetime.now().strftime("%Y%m%d%H%M")[2:]
+VERSION = os.environ['PKG_VERSION']
print(VERSION)

setup(
--
2.39.1

0 comments on commit 99ca078

Please sign in to comment.