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

override version via an environment variable #199

Open
teto opened this issue Jul 3, 2019 · 8 comments
Open

override version via an environment variable #199

teto opened this issue Jul 3, 2019 · 8 comments
Labels

Comments

@teto
Copy link

teto commented Jul 3, 2019

Is it possible to ovveride the version via an environment variable ? if not would it be possible to add the feature ? setuptools provides the convenient variable SETUPTOOLS_SCM_PRETEND_VERSION="0.25.0"; for instance.

My usecase is that pandas if (very) often broken for me so I often need to use the development version.
When fetching the code from github via nix, it fetches a tarball thus it misses the .git files.
This ends up with pandas having a 0+unknown version. Because my setup.py enforces pandas >= 0.24.2, the pip check fails:

Collecting pandas>=0.24.2 (from mptcpanalyzer==0.3.2.dev0)
  Using cached https://files.pythonhosted.org/packages/b2/4c/b6f966ac91c5670ba4ef0b0b5613b5379e3c7abdfad4e7b89a87d73bae13/pandas-0.24.2.tar.gz
Requirement already satisfied: cmd2>=0.9.12 in /nix/store/9f7v64ns4xwfgm1dmn2aqy5vjmxspi85-python3.7-cmd2-0.9.14/lib/python3.7/site-packages (from mptcpanalyzer==0.3.2.dev0) (0.9.14)
Requirement already satisfied: pbr!=2.1.0,>=2.0.0 in /nix/store/xczj8g0l84dls0sx98j4zpi3cklvba3p-python3.7-pbr-5.1.3/lib/python3.7/site-packages (from stevedore->mptcpanalyzer==0.3.2.dev0) (5.1.3)
Requirement already satisfied: six>=1.10.0 in /nix/store/imf48xfhb9dg8453gx131icwxrgwnwdv-python3.7-six-1.12.0/lib/python3.7/site-packages (from stevedore->mptcpanalyzer==0.3.2.dev0) (1.12.0)
Requirement already satisfied: numpy>=1.10.0 in /nix/store/3ml16mnq11in68sdg8w4jipm7bqcvmh8-python3.7-numpy-1.16.4/lib/python3.7/site-packages (from matplotlib>=3.0.3->mptcpanalyzer==0.3.2.dev0) (1.16.4)
Requirement already satisfied: python-dateutil>=2.1 in /nix/store/p59ycm2ijqgbl3x9fzl9968ppyc5wlyl-python3.7-python-dateutil-2.8.0/lib/python3.7/site-packages (from matplotlib>=3.0.3->mptcpanalyzer==0.3.2.dev0) (2.8.0)
Requirement already satisfied: cycler>=0.10 in /nix/store/a8dhnlh3j584rkx2mnd9q88yjx0gs3dj-python3.7-cycler-0.10.0/lib/python3.7/site-packages (from matplotlib>=3.0.3->mptcpanalyzer==0.3.2.dev0) (0.10.0)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /nix/store/rfb33kzfnbm5j7ph9j7qp54cg5y1kgvy-python3.7-pyparsing-2.3.1/lib/python3.7/site-packages (from matplotlib>=3.0.3->mptcpanalyzer==0.3.2.dev0) (2.3.1)
Requirement already satisfied: kiwisolver>=1.0.1 in /nix/store/b60xdslw4sxy2mhfc8wl3sx4kll9rav1-python3.7-kiwisolver-1.0.1/lib/python3.7/site-packages (from matplotlib>=3.0.3->mptcpanalyzer==0.3.2.dev0) (1.0.1)
Requirement already satisfied: pytz>=2011k in /nix/store/qiri3zhvgb05cccf5mhbricxv95q2pni-python3.7-pytz-2019.1/lib/python3.7/site-packages (from pandas>=0.24.2->mptcpanalyzer==0.3.2.dev0) (2019.1)
Requirement already satisfied: attrs>=16.3.0 in /nix/store/nmzcj7vdqfch4jl4ndmkf1mvdyda4xs4-python3.7-attrs-18.2.0/lib/python3.7/site-packages (from cmd2>=0.9.12->mptcpanalyzer==0.3.2.dev0) (18.2.0)
Requirement already satisfied: pyperclip>=1.5.27 in /nix/store/xs2v9yhg3pgr6wnql2v3b5zwlz5rm145-python3.7-pyperclip-1.7.0/lib/python3.7/site-packages (from cmd2>=0.9.12->mptcpanalyzer==0.3.2.dev0) (1.7.0)
Requirement already satisfied: wcwidth>=0.1.7 in /nix/store/lnzp91myfangqfpdw18sk2yp1x7wyf3r-python3.7-wcwidth-0.1.7/lib/python3.7/site-packages (from cmd2>=0.9.12->mptcpanalyzer==0.3.2.dev0) (0.1.7)
Requirement already satisfied: colorama in /nix/store/xx29yp120h6p9fjwwgvazdr8iharpj01-python3.7-colorama-0.4.1/lib/python3.7/site-packages (from cmd2>=0.9.12->mptcpanalyzer==0.3.2.dev0) (0.4.1)
Requirement already satisfied: setuptools in /nix/store/pwqjs8nz67h4rid05vwma9z8fbsfmm16-python3.7-bootstrapped-pip-19.1.1/lib/python3.7/site-packages (from kiwisolver>=1.0.1->matplotlib>=3.0.3->mptcpanalyzer==0.3.2.dev0) (41.0.1)
Building wheels for collected packages: pandas
  Building wheel for pandas (setup.py) ... done
  Stored in directory: /home/teto/.cache/pip/wheels/47/0a/bf/fd3647f5bc74698ed95dbdbb3d8d120cfe0280969c212cdb6c
Successfully built pandas
Installing collected packages: pandas, mptcpanalyzer
  Found existing installation: pandas 0+unknown
    Uninstalling pandas-0+unknown:
ERROR: Could not install packages due to an EnvironmentError: [Errno 30] Read-only file system: 'METADATA'

The most straightforward solution in my case would be to export the VERSIONEER_VERSION="0.25.0"; to fix the install. Right now, I remove the pandas' version check from program's setup.py, which is annoying.

@costrouc
Copy link

I have the exact same issue here. It is frustrating that there is no environment override. I am trying to test several packages from the git repo and this is the hack I have to perform to set the package version https://github.com/costrouc/python-downstream-testing/blob/master/overrides.nix#L37.

@costrouc
Copy link

costrouc commented Dec 30, 2019

Since it doesn't look like this issue has gained much traction here is the workaround I am using with nix. Note that dask/_version.py will need to be changed

  postPatch = ''
    # versioneer hack to set version of github package
    echo "def get_versions(): return {'dirty': False, 'error': None, 'full-revisionid': None, 'version': '${version}'}" > dask/_version.py

    substituteInPlace setup.py \
      --replace "version=versioneer.get_version()," "version='${version}'," \
      --replace "cmdclass=versioneer.get_cmdclass()," ""
  '';

@hroncok
Copy link

hroncok commented Apr 20, 2020

This is what Fedora uses in nb2plots:

sed -i 's/HEAD -> master/tag: %{version}/' nb2plots/_version.py

@xkortex
Copy link

xkortex commented Aug 11, 2020

This would be helpful for building inside Docker containers. Sometimes it's handy to .dockerignore various files e.g. dockerfiles, docker-compose.yml, CI configs, etc, stuff that isn't part of the code path so you can leverage the layer cache. However if you .dockerignore anything which is git-tracked, then the repo itself will end up in the dirty state.

@effigies
Copy link
Contributor

I think there's a common issue of finding some fallback version, and I've tagged the open issues that bring up different aspects of this with the fallback label.

It would be good to try to address this with each of these use cases in mind.

@effigies
Copy link
Contributor

Hi @teto @costrouc @hroncok @xkortex, would you care to have a look at #234?

@nbren12
Copy link

nbren12 commented Apr 29, 2021

I could also use this e.g. for adding an external project as a subtree in a git repository.

@effigies
Copy link
Contributor

I started an override-only PR at #238, but don't have time to put into writing the tests right now. If you'd like to take over the PR, I should be able to review.

HippocampusGirl added a commit to HALFpipe/HALFpipe that referenced this issue Jul 2, 2021
- Otherwise `versioneer` will report that the version is "dirty" as
  explained under python-versioneer/python-versioneer#199
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants